akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ_Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            var rowNum = inputs[0];
            var columnNum = inputs[1];

            var tableList = new List<List<int>>();
            for (int i = 0; i < rowNum; i++)
            {
                var oneLine = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
                tableList.Add(oneLine);
            }

            foreach (var aRow in tableList)
            {
                var sum = aRow.Sum();
                aRow.Add(sum);
                Console.WriteLine($"{string.Join(" ", aRow)}");
            }

            var columnSumList = tableList.SelectMany(x => x).Select((x, i) => new { x, i }).ToLookup(x => x.i % tableList[0].Count).ToList();

            Console.WriteLine($"{string.Join(" ", columnSumList.Select(x => x.Sum(y => y.x)))}");
        }
    }
}



Measured memory_bytes: 18608
#include <bits/stdc++.h>

using namespace std;

#define endl           '\n'
#define LL             long long
#define ULL            unsigned long long
#define all(x)         x.begin(), x.end()

const LL MOD = 1000000007;
const LL LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 5;

LL a[N * 3];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= 3 * n; i++) scanf("%lld", a + i);
    sort(a + 1, a + 3 * n + 1);
    LL res = 0;
    for (int i = 3 * n - 1, j = n; j; j--, i -= 2) res += a[i];
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

const int MAX_N = 200005;

vector<int> vec[MAX_N];

int N, M, mx[MAX_N << 3], tag[MAX_N << 3];

void build(int x, int l, int r) {
  if (l == r) {
    mx[x] = -M + l - 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid), build(x << 1 | 1, mid + 1, r);
  mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}

void push_down(int x) {
  if (tag[x]) {
    mx[x << 1] += tag[x], tag[x << 1] += tag[x];
    mx[x << 1 | 1] += tag[x], tag[x << 1 | 1] += tag[x];
    tag[x] = 0;
  }
}

void update(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R) {
    mx[x]++, tag[x]++;
    return;
  }
  push_down(x);
  int mid = (l + r) >> 1;
  if (mid >= L) update(x << 1, l, mid, L, R);
  if (mid < R) update(x << 1 | 1, mid + 1, r, L, R);
  mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}

int query(int x, int l, int r, int L, int R) {
  if (L <= l && r <= R)
    return mx[x];
  push_down(x);
  int mid = (l + r) >> 1, res = -100000000;
  if (mid >= L) res = query(x << 1, l, mid, L, R);
  if (mid < R) res = max(res, query(x << 1 | 1, mid + 1, r, L, R));
  return res;
}

int main() {
  scanf("%d%d", &N, &M);
  
  for (int i = 1, L, R; i <= N; ++i) {
    scanf("%d%d", &L, &R);
    vec[L].push_back(R);
  }

  build(1, 1, M + 1);
  
  int res = N - M;

  for (int i = 0; i <= M; ++i) {
    for (int x : vec[i]) 
      update(1, 1, M + 1, 1, x);

    res = max(res, query(1, 1, M + 1, i + 1, M + 1) - i);
  }
  
  printf("%d\n", res);
  return 0;
}


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))
#define cio ios::sync_with_stdio(false);
ll s[200010];
ll q[200010];
int main()
{
	ll n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> s[i];
	ll p = 0;
	ll po = 1;
	map<ll,ll>jud;
	while(jud[po]==0){
		jud[po] = 1;
		q[++p] = po;
		po = s[po];
	}
	ll x = 0;
	for(int i = 1; i <= p; i++){
		if(q[i]==po){
			x = i;
			if(k<x){
				cout << q[k+1] << endl;
				return 0;
			}
			k -= (i-1);
			break;
		}
	}
	k++;
	k %= (p-x+1);
	if(k==0) k = (p-x+1);
	cout << q[k+x-1] << endl;
    return 0;
}



Measured memory_bytes: 18896
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//えびちゃんの気持ちが分かってきた気がしたけど無意味だったかな
char cn[2400000], * ci = cn, * di = cn, ct, buf[8];
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	memcpy(buf, ci, 8);
	ll tmp = *(ll*)buf;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = (tmp << dig) & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3) + 1;
	return tmp;
}

const int MAX = 200000;
class shuturyoku_unko {
public:
	char C[MAX * 6 + 10];
	int K[MAX + 10];
	constexpr shuturyoku_unko() : C(), K() {
		auto di = C + 1;
		C[0] = '0';
		K[1] = 1;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			K[i + 1] = K[i] + keta;
		}
	}
} f;
inline void putint(ll X) {
	int ue = X / 100000;
	if (ue) {
		for (int i = f.K[ue]; i < f.K[ue + 1]; i++)* di++ = f.C[i];
		int sita = X - ue * 100000ll;
		rep(i, 5 - f.K[sita + 1] + f.K[sita])* di++ = '0';
		for (int i = f.K[sita]; i < f.K[sita + 1]; i++)* di++ = f.C[i];
	}
	else for (int i = f.K[X]; i < f.K[X + 1]; i++)* di++ = f.C[i];
	*di++ = '\n';
}

int A[200000];
int B[200010];

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	fread(cn, 1, 1400100, stdin);

	int N = getint();
	ll kotae = 0;
	rep(i, N) kotae += B[(A[i] = getint())]++;
	rep(i, N) putint(kotae - B[A[i]] + 1);
	fwrite(cn, 1, di - cn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int N,K;
		String S;
		Scanner sc=new Scanner(System.in);

		N=sc.nextInt();
		S=sc.next();
		K=sc.nextInt();

		for(int i=0;i<N;i++) {
			if(S.charAt(i)==S.charAt(K-1)) {
				System.out.print(S.charAt(i));
			}
			else {
				System.out.print("*");
			}
		}
		System.out.println();
		sc.close();
	}

}

Measured memory_bytes: 22600
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

s = input()
if s[-1] == 's':
    s = s + 'es'
else:
    s = s + 's'
print(s)

Measured memory_bytes: 8992
#include <iostream>
#include <vector>
int INF = 1e9;
int main(){
    int n;
    std::cin >> n;
    std::vector<int> g(n), re(n);
    for(int i = 0; i < n; i++) std::cin >> g[i] >> re[i];
    int dp[n + 1][n + 1];
    for(int i = 0; i < n + 1; i++){
        for(int j = 0; j < n + 1; j++) dp[i][j] = INF;
        if(i < n) dp[i][i + 1] = 0;
        dp[i][i] = 0;
    }
    for(int w = 1; w < n + 1; w++){
        for(int l = 0; l < n; l++){
            int r = l + w;
            if(r > n) break;
            if(r - l == 2) dp[l][r] = g[l]*re[l + 1]*g[r - 1];
            for(int mid = l + 1; mid < r; mid++){
                dp[l][r] = std::min(dp[l][mid] + dp[mid][r] + g[l]*re[r- 1]*re[mid - 1], dp[l][r]);
            }
        }
    }
    std::cout << dp[0][n] << std::endl;
}


Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
    
using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int H, W, D;
    cin >> H >> W >> D;

    int numberMap[H][W];
    vector<pair <int, int> > number(H*W+1);
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cin >> numberMap[h][w];
            number[ numberMap[h][w] ] = make_pair(h, w);
        }
    }

    ll costMap[H * W + 1] = {0};
    for(int i = 0; i < H * W + 1; i++){
        if(i - D > 0){
            int h = abs(number[i].first - number[i-D].first);
            int w = abs(number[i].second - number[i-D].second);
            ll cost =  h + w;
            costMap[i] = costMap[i-D] + cost;
        }
    }

    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int l, r;
        cin >> l >> r;
        cout << costMap[r] - costMap[l] << endl;
    }

}



Measured memory_bytes: 2816
n = int(input())
h = [int(i) for i in input().split()] + [(10 ** 9) + 1]

ans = cnt = 0
for i in range(n):
    if h[i] >= h[i + 1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
using ll=long long;

vector<bool> isprime(1000005);

void eratos(int n){
    for(int i=0;i<n+1;i++){
        isprime[i]=true;
    }
    isprime[0]=isprime[1]=false;
    for(int i=2;i*i<=n;i++){
        if(isprime[i]){
            int j=i+i;
            while(j<=n){
                isprime[j]=false;
                j=j+i;
            }
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;
    cin>>n;

    ll ans=0;
    eratos(1000005);
    for(ll i=2;i<1000006;i++){
        if(!isprime[i]) continue;
        ll j=i;
        while(1){
            if(n%j==0){
                n/=j;
                ans++;
                j*=i;
            }
            else{
                break;
            }                        
        }
        while(n%i==0){
            n/=i;
        }
    }
    if(n!=1){
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		char s, t, b; cin >> s >> t >> b;
		int start, elec, goal;
		start = s - 'A';
		elec = t - 'A';
		goal = b - 'A';
		vector<vector<ld>>pers(N + 1, vector<ld>(9));
		pers[0][start] = 1;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 9; ++j) {
				int x = j / 3;
				int y = j % 3;
				for (int way = 0; way < 4; ++way) {
					int nextx = x + dx[way];
					int nexty = y + dy[way];
					if (nextx >= 0 && nextx <= 2 && nexty >= 0 && nexty <= 2) {
						int nextj = nextx * 3 + nexty;
						if (nextj == goal) {
							pers[i + 1][j] += pers[i][j] / 4;
						}
						else {
							pers[i + 1][nextj] += pers[i][j] / 4;
						}
					}
					else {
						pers[i + 1][j] += pers[i][j] / 4;
					}
				}
			}
		}
		cout <<setprecision(10)<<fixed<< pers[N][elec] << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <iostream>

using namespace std;

void Solve() {
	string s;
	cin >> s;

	for (int i = 0; i + 1 < s.length(); ++i) {
		if (s[i] == 'A' && s[i+1] == 'C') {
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
}

int main() {
	int tests = 1;

	for (;tests; --tests) {
		Solve();
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	vector<int> B(N);
	vector<int> C(N - 1);
	int answer = 0;
	int lastA = 0;
	
	for (int i = 0; i < N; i++)	cin >> A.at(i);
	for (int i = 0; i < N; i++) cin >> B.at(i);
	for (int i = 0; i < N - 1; i++) cin >> C.at(i);

	for (int i = 0; i < N; i++)
	{
		answer += B.at(A.at(i) - 1);

		if (lastA && A.at(i) == lastA + 1)
		{
			answer += C.at(lastA - 1);
		}

		lastA = A.at(i);
	}

	cout << answer << endl;


	return 0;
}

Measured memory_bytes: 256
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp::{max}; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;
#[allow(dead_code)]
const N_PRIME : i64 = 1000000007;

////////////////////////////////////////////////

fn main(){
    let n = read_int();
    let h = read_int();
    let w = read_int();
    let x1 = max(n+1-h,0);
    let x2 = max(n+1-w,0);

    println!("{}",x1*x2);
}

Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,m,q=map(int,input().split())
    LR=[tuple(map(int,input().split())) for i in range(m)]
    PQ=[tuple(map(int,input().split())) for i in range(q)]
    dp=[[0]*(n+1) for _ in range(n+1)] #i(1-)以上j(1-)以下の間に完全に含まれる列車の本数
    for l,r in LR:
        dp[l][r]+=1
    for i in range(n+1):
        for j in range(n):
            dp[i][j+1]+=dp[i][j]
    for i in range(n-1,0,-1):
        for j in range(n+1):
            dp[i][j]+=dp[i+1][j]
    for p,q in PQ:
        print(dp[p][q])

if __name__=='__main__':
    main()

Measured memory_bytes: 93276
#include<bits/stdc++.h>

using namespace std;

int main()
{

    string s;

    cin >> s;

    int sz = s.size();

    int cnt = 0;

    char a;

    for(int i = 0; i < sz; i++)
    {
        if(s[i] == s[i+1])
        {
            cnt++;

            if(s[i] == '1')
                a = '0';
            else
                a = '1';
             s[i+1] = a;

        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 512
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
void solve()
{
 ll n;
 cin>>n;
 if(n>=30)
  cout<<"Yes";
else
  cout<<"No";
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3636
// ＡＢＣのＡ過去問を解くだけだよ
// フォント    x:小文字(ｘ)    X:大文字(Ｘ)

#include <bits/stdc++.h>

using namespace std;

int main()
{
    string s;
    cin >> s;

    sort(s.begin(), s.end());

    if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c')
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Bits
import Data.List

main = do
  li <- BS.getLine
  let Just (n,_) = BS.readInt li
  xs <- BS.getLine
  mapM_ print $ compute n xs

-- xsの2進数をbで割った余り
stepBS :: BS.ByteString -> Int -> Int
stepBS xs b = BS.foldl' (\acc c -> mod (acc+acc+digitToInt c) b) 0 xs

compute :: Int -> BS.ByteString -> [Int]
compute n xs = zipWith3 g (BS.unpack xs) rems0 rems1
  where
    (pc, pc0, pc1) = (BS.count '1' xs, succ pc, pred pc)
    rems0 = rems n pc0
    rems1 = rems n pc1
    stepBS0 = stepBS xs pc0
    stepBS1 = stepBS xs pc1
    g '0' rem0 _ = h pc0 (stepBS0+rem0)
    g '1' _ rem1 = h pc1 (stepBS1-rem1)
    h 0 _ = 0
    h pc r = f $ mod r pc

--rems n 0 = replicate n 0 -- ??
rems n 1 = replicate n 0
rems n b = reverse $ take n $ iterate (\r -> (r*2) `mod` b) 1

step x = x `mod` popCount x

f = succ . length . takeWhile (0 /=) . iterate step
{-
最大2万桁の2進数を扱うのは、Integerでやればできるかもしらんがどうかという。
最初のpopCountはたかだか2万なので、あまりもそれ未満。だから初回さえ乗り切ればあとは普通の整数で間に合う。
をちゃんと実装してみよう。
TLE
毎回 foldl (acc+acc+b `mod` pc1) するのは重いか。
(p,q) = divMod a b とは a = pb + q すると
divMod 2a b = (2p+x,y) where (x,y) = divMod 2q b
なぜなら 2q = bx+y, 2a = b(2p+x) + y = 2pb + bx + y = 2pb + 2q = 2(pb + q)
なので、xsを初めにsucc pcとpred pcで割った余りを求めておいて、
あとbit iの分は1から始めて2倍しては余りを求めるをi-1回繰り返した結果を求め、
さらに両者を足して余りをとればよい。
あっ1のときは引き算だ！
-}

Measured memory_bytes: 52996
# frozen_string_literal: true

S = gets.chomp
N = S.size
S1 = S[0..((N - 1) / 2 - 1)]
S2 = S[((N + 3) / 2 - 1)..-1]

if S == S.reverse && S1 == S1.reverse && S2 == S2.reverse
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

ll comb(ll a, ll b)
{
	ll res = 1;
	REP(i, b)
	{
		res *= a - i;
		res /= i + 1;
	}
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, p; cin >> n >> p;
	int a[2] = {};
	REP(i, n)
	{
		int t; cin >> t;
		a[t % 2]++;
	}
	ll ans = 0;
	REP(i, a[0] + 1)REP(j, a[1] + 1)
	{
		if (p == 0 && j % 2 == 1) continue;
		if (p == 1 && j % 2 == 0) continue;
		ans += comb(a[0], i) * comb(a[1], j);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int n;
  cin>>n;
  if(n>=64)cout<<64<<endl;
  else if(n>=32)cout<<32<<endl;
  else if(n>=16)cout<<16<<endl;
  else if(n>=8)cout<<8<<endl;
  else if(n>=4)cout<<4<<endl;
  else if(n>=2)cout<<2<<endl;
  else cout<<1<<endl;




return 0;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>

#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define IN(x) int (x); cin >> x
#define INS(x) string (s); cin >> s
#define INL(x) ll (x); cin >> x
#define VINT(a,n) vector<int> a(n)
#define VIN(a,n) VINT(a,n); REP(i,n){cin >> a[i];}
#define ALL(x) (x).begin(),(x).end()

int main () {
  IN(n);
  VIN(w, n);
  int ans=10001;
  REP(i,n){
    int s1=accumulate(w.begin(), w.begin()+i+1, 0);
    int s2=accumulate(w.begin()+i+1, w.end(), 0);
    ans=min(ans,abs(s1-s2));
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N;
  cin >> N;
  int Ans=0;
  int Pre=0;
  int Now=0;
  for(int i=0; i<N; i++){
    cin >> Now;
    Ans+=max(0, Now-Pre);
    Pre=Now;
  }
  cout << Ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

D,G = list(map(int, input().rstrip().split()))
pc_list = [list(map(int, input().rstrip().split())) for i in range(D)]
#-----

bit = 1 << D
min_cnt = 10*100

for b in range(bit):
    score = 0
    cnt = 0
    
    for i in range(D):
        if b & (1 << i):
            p = pc_list[i][0]
            c = pc_list[i][1]
            
            score += p * (100*(i+1)) + c
            cnt += p
    
    if score >= G:
        min_cnt = min(min_cnt, cnt)
    
    else:
        flag = False
        
        for i in reversed(range(len(pc_list))):
            if flag:
                break
            
            if b & (1 << i):
                continue
            
            p = pc_list[i][0]
            
            for j in range(p-1):
                score += 100*(i+1)
                cnt += 1
                
                if score >= G:
                    min_cnt = min(min_cnt, cnt)
                    flag = True
                    break

print(min_cnt)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;

bool second_compare(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> work(N, pair<int, int>());
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        work[i] = {a, b};
    }
    sort(work.begin(), work.end(), second_compare);
    long int time = 0;
    bool check = true;
    for (int i = 0; i < N; i++) {
        time += work[i].first;
        if (time > work[i].second) {
            check = false;
            break;
        }
    }
    if (check) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 1792
def prime(n)
  primes = Array.new(n + 1){|i|i}
  primes[1] = nil
  for i in 2..n ** 0.5
    if primes[i]
      for j in 2..n / i
        primes[i * j] = nil
      end
    end
  end
  return primes[2..-1].select{|f|f}
end
def main(input = STDIN)
  primes = prime(50000)
  num = Array.new(50001, 0)
  primes.each_with_index{|i, idx|
    while primes[idx] and primes[idx] + i <= 50000
      num[i + primes[idx]] += 1
      idx += 1
    end
  }
  while (n = input.gets.to_i) != 0
    puts num[n]
  end
end
main

Measured memory_bytes: 6868
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define me(a,b) memset(a,b,sizeof(a))
#define INIT() std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int MAX_N=200000+5;
const int MAX_M=100000+5;
const int INF=0x7fffffff;
const int inf=1000000000;
const double EPS=1e-6;
const ull base=123;
const ll mod=1e9+7;
const double pi=4*atan(1.0);
int main()
{
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0)
        x=-x;
    ll u=x/d;
    ll num=x-d*u;
    if(d-num<=num)
    {
        num-=d;
        u++;
    }
    if(u>=k)
    {
        cout<<abs(x-d*k)<<endl;
    }
    
    else
    {//cout<<num<<' '<<u<<endl;
        k-=u;
        if(k&1){
        k=1;}
        else
        {
            k=0;
        }
        cout<<min(abs(num+d*k),abs(num-d*k))<<endl;
    }
    
    //system("pause");
    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

using namespace std;

int main(int argc, const char* argv[]) {
    int N;
    scanf("%d", &N);
    VI a(N), ind(N+1);
    for (int i = 0; i < N; i++) {
        scanf("%d", &a[i]);
        ind[a[i]] = i;
    }
    set<int> done{-1, N};
    ll ret = 0;
    for (ll i = 1; i <= N; i++) {
        int j = ind[i];
        auto it = done.lower_bound(j);
        int right = *it;
        it--;
        int left = *it;
//        cerr << i << ": " << left << ' ' << j << ' ' << right << endl;
        ret += i * (j - left) * (right - j);
//        cerr << ret << endl;
        done.insert(j);
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 11264
n = int(input())

ans = 0
A = 0
B = 0
BA = 0
for _ in range(n):
    s = input()
    ans += s.count('AB')
    if (s[0], s[-1]) == ('B', 'A'):
        BA += 1
        continue
    if s[-1] == 'A':
        A += 1
    if s[0] == 'B':
        B += 1
else:
    if BA:
        ans += BA-1
        if A:
            A -= 1
            ans += 1
        if B:
            B -= 1
            ans += 1
    ans += min(A, B)
print(ans)


Measured memory_bytes: 9116
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val shops = (1..n).map {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        a to b
    }.sortedBy { shop -> shop.first }
    var amt = 0L
    var qty = 0
    for (shop in shops) {
        val q = Math.min(m - qty, shop.second)
        amt += shop.first.toLong() * q
        qty += q
        if (qty == m) break
    }
    println(amt)
}


Measured memory_bytes: 78988
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <stack>
#include <algorithm>
using namespace std;
 
 
int main(){
    int i, k, n, contador=0;
    int arr[100000];
    cin >> n >> k;
    for (i=0; i<n; i++){
    	cin >> arr [i];
    	if (arr[i]>=k){
    		contador++;
		}
	}
	cout << contador;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long

void solve()
{
    // 入力の処理
    ll N;
    cin >> N;

    for (int i = 1; i <= 9; i++)
    {
        for (int j = 1; j <= 9; j++)
        {
            if (N == i * j)
            {
                printf("Yes\n");
                return;
            }
        }
    }
    printf("No\n");
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main() {

   int r, c;
   cin >> r >> c;

   vector<int> A(c, 0);
   for (int i = 0; i < r; i++) {
      int t = 0;
      for (int j = 0; j < c; j++) {
         int v;
         cin >> v;
         t += v;
         A[j] += v;
         cout << v << " ";
      }
      cout << t << endl;
   }
   int t = 0;
   for (int i = 0; i < c; i++) {
      t += A[i];
      cout << A[i] << " ";
   }
   cout << t << endl;

   return 0;

}

Measured memory_bytes: 1196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N,A;
	cin>>N>>A;
	if(N%500<=A)puts("Yes");
	else puts("No");
}


Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(m)]
ans = -1
for i in range(10**n):
    i = str(i)
    flag = 1
    for j in range(m):
        try:
            if not i[sc[j][0]-1] == str(sc[j][1]):
                flag = 0
                break
        except:
            flag = 0
            break
    if flag == 1:
        if len(i) == n:
            ans = int(i)
            break

print(ans)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main()
{
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A+B>C+D){
        cout<<"Left"<<endl;
    }else if(A+B<C+D){
        cout<<"Right"<<endl;
    }else{
        cout<<"Balanced"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if(a+b == 15){
    cout << "+" << endl;
  }
  else if(a*b == 15){
    cout << "*" << endl;
  }
  else{
	cout << "x" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
//It is known that the area of a regular dodecagon inscribed in a circle of radius a is 3a^2
//Given an integer r, find the area of a regular dodecagon inscribed in a circle of radius r

#include <stdio.h>

int main ()
{
	int r;
	scanf("%d", &r);
	
	int rumus;
	rumus = 3*(r*r);
	
	printf("%d", rumus);
	
	return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n;

struct struk{
		ll waktu, batas;
	};

bool cmp(struk s1, struk s2){
		if(s1.batas!=s2.batas){
			return s1.batas<s2.batas;
		}
		else{
			return s1.waktu<s2.waktu;
		}
	}

int main(){
	IOS
	cin >> n;
	vector<struk>v;
	for(int i=0;i<n;i++){
		ll a, b;
		cin >> a >> b;
		v.pb({a, b});
	}
	sort(v.begin(), v.end(), cmp);
	ll temp=0;
	for(int i=0;i<n;i++){
		temp+=v[i].waktu;
		if(temp>v[i].batas){
			cout << "No" << '\n';
			return 0; 
		}
	}
	cout << "Yes" << '\n';
}


Measured memory_bytes: 7476
#include <iostream>
#include <array>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        array<int, 3> a;
        cin >> a[0] >> a[1] >> a[2];
        sort(a.begin(), a.end());
        if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    ll H,W;
    cin >> H >> W;
    if (H==1 || W==1) {
        cout << 1 << endl;
        return;
    }
    ll setH = H/2;
    ll ans = setH * (((W+1)/2)+(W/2));
    if (H%2==1) ans+= (W+1)/2;
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;

// O(N (log N)^2)
vector<int> suffix_array(string const & s){
	int n = s.length();
	vector<int> sa(n+1);
	vector<int> rank(n+1);
	
	for(int i=0;i<n+1;i++){
		sa[i] = i;
		rank[i] = i < n ? s[i] : -1;
	}
	
	auto rankf = [&](int i) { return i <= n ? rank[i] : -1; };
	vector<int> nxt(n+1);
	
	for(int k=1;k<=n;k<<=1){
		auto cmp = [&](int i, int j) { return make_pair(rank[i], rankf(i + k)) < make_pair(rank[j], rankf(j + k)); };
		sort(sa.begin(), sa.end(), cmp);
		nxt[sa[0]] = 0;
		
		for(int i=1;i<n+1;i++){
			nxt[sa[i]] = nxt[sa[i-1]] + (cmp(sa[i-1], sa[i]) ? 1 : 0);
		}
		rank.swap(nxt);
	}
	
	return sa;
}


int main() {
	int k;
	string s;
	cin >> k >> s;
	vector<int> sa = suffix_array(s);
	vector<int> rank(sa.size());
	
	for(int i=0;i<sa.size();i++)
		rank[sa[i]] = i;
	
	int l = (s.length()+k) / (k+1);
	
	function<bool (int)> pred = [&](int a) {
		int used = 0;
		for(int i=0;i<s.length();++used){
			int delta = rank[i] < a ? l : l-1;
			if (delta == 0)
				return false;
			i += delta;
		}
		return used <= k+1;
	};
	
	int low = 0, high = rank.size();
	
	while (low + 1 < high){
		int mid = (low + high) / 2;
		(pred(mid) ? high : low) = mid;
	}
	
	int a = low;
	cout << s.substr(sa[a], l) << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  ll sum = 0;
  REP(i, 0, N) {
    cin >> A[i];
    sum += A[i];
  }
  ll avg = round((double) sum / N);

  ll ans = 0;
  REP(i, 0, N) {
    ans += (A[i] - avg) * (A[i] - avg);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>

using namespace std;

int main() {

	int A, B;

	cin >> A >> B;

	if (A > 12) {
		cout << B << endl;
	}
	else if(A>5){
		cout << B / 2 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i =0;i<n;i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  ll n,k;
  cin >> n >> k;
  ll min=0,max=0;
  ll ans=0,mod=(pow(10,9)+7);
  rep(i,k){
    min+=i;
    max+=n-i;
    //cout << min << " " << max << endl;
  }
  for(ll i = k;i<=n+1;i++){
    ans+=(max-min+1);
    //cout << "ans:" << ans << endl;;
    max+=n-i;min+=i;
  }
  ans%=mod;
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int X, Y;
	cin >> X >> Y;
	int now = X;
	int cnt = 0;
	while (now <= Y) {
		cnt++;
		now *= 2;
	}
	cout << cnt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<ll> h(n);
  for (int i = 0; i < n; i++){
    cin >> h[i];
  }
  for (int i = 0; i < n - 1; i++){
    if(h[i] < h[i + 1]){
      h[i + 1]--;
    }
    if(h[i] > h[i + 1]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(){
    // int n;
    // cin >> n;
    // string s;
    // cin >> s;
    // int i = 0;
    // while(s[i]==')' && i<n){
    //     cout << '(';
    //     i++;
    // }
    // int sum = 0;
    // while(i<n){
    //     if(s[i]=='(')sum--;
    //     else sum++;
    //     i++;
    // }
    // if(sum>0){
    //     for(int i = 0; i < sum;i++){
    //         cout << '(';
    //     }
    // }
    // cout << s;
    // if(sum<0){
    //     for(int i = 0; i > sum;i--){
    //         cout << ')';
    //     }
    // }
    // cout << endl;
    int N;
    string S,ans;
    cin >> N >> S;
    int c = 0;
    int x = 0;
    for(int i = 0; i < N; i++) {
        if (S[i] == '(') {
            c++;
        } else {
            if (c > 0) c--;
            else x++;
        }
    }
    for(int i = 0; i < x; i++) ans += '(';
    ans += S;
    for(int i = 0; i < c; i++) ans += ')';
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
lis1 = list(map(int,input().split()))
lis2 = list(map(int,input().split()))
lis3 = list(map(int,input().split()))
n = int(input())
b_lis = [int(input()) for _ in range(n)]
for i,l1 in enumerate(lis1):   
    if l1 in b_lis:
        lis1[i] = 0
for j,l2 in enumerate(lis2):   
    if l2 in b_lis:
        lis2[j] = 0
for k,l3 in enumerate(lis3):   
    if l3 in b_lis:
        lis3[k] = 0
if lis1 == [0,0,0]:
    print('Yes')
    sys.exit()
if lis2 == [0,0,0]:
    print('Yes')
    sys.exit()
if lis3 == [0,0,0]:
    print('Yes')
    sys.exit()
if lis1[0] == 0 and lis2[0] == 0 and lis3[0] == 0:
    print('Yes')
    sys.exit()
if lis1[1] == 0 and lis2[1] == 0 and lis3[1] == 0:
    print('Yes')
    sys.exit()
if lis1[2] == 0 and lis2[2] == 0 and lis3[2] == 0:
    print('Yes')
    sys.exit()
if lis1[0] == 0 and lis2[1] == 0 and lis3[2] == 0:
    print('Yes')
    sys.exit()
if lis1[2] == 0 and lis2[1] == 0 and lis3[0] == 0:
    print('Yes')
    sys.exit()
#print(b_lis)
#print(lis1,lis2,lis3)
print('No')

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
#define int long long 
const int mod=1e9+7;
map<int,int>d;
inline int qread() 
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int x)
{
	if(d[x])
		return d[x];
	else
	return d[x]=((solve(x/2)+solve((x-1)/2)+solve((x-2)/2)))%mod;
}
signed main()
{
	//初始条件
	d[0]=1;//a=b=0一组 
	d[1]=2; //a=b=0一组 ，a=b=1第二组； 
	int n;
	n=qread(); 
	int ans=solve(n);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

long long dp[100000][3];

int main() {
  long long N;
  cin >> N;
  vector<long long> a(N), b(N), c(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (int i = 1; i < N; i++) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2])+a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2])+b[i];
    dp[i][2] = max(dp[i-1][0], dp[i-1][1])+c[i];
  }
  long long result = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4992
import itertools

t = ('.,!? ','abc','def','ghi','jkl','mno','pqrs','tuv','wxyz')

for i in range(int(raw_input())):
    r = ''
    for i,j in itertools.groupby(raw_input()):
        j = ''.join(j)
        if i != '0':
            r += t[int(i) - 1][(len(j) - 1) % len(t[int(i) - 1])]
    print r

Measured memory_bytes: 4364
//
//  main.c
//  ITP1_5_C
//
//  Created by k16031kk on 2018/05/22.
//  Copyright © 2018年 AIT. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int H=0, W=0;
    scanf("%d %d", &H, &W);
    while(H!=0 || W!=0) {
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if((i+j)%2==0) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d", &H, &W);
    }
    
    return 0;
}




Measured memory_bytes: 2108
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n , sum ; 
    cin >> n >> sum ; 
    int  ans = sum/n ; 
    sum = sum-ans*n;
    while (sum%ans){
        sum += n; ans--;
    }
    cout << ans << endl; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		StringBuilder wk1 = new StringBuilder(next());
		StringBuilder wk2 = new StringBuilder(next());

		if (wk1.toString().equals(wk2.reverse().toString())) {
			out.println("YES");
		} else {
			out.println("NO");
		}

	}

	private void solveB() {
		int numN = nextInt();

		int wk = (int) Math.sqrt(numN);

		out.println((int) Math.pow(wk, 2));
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  string t="",r="";
  ll ans=0;
  rep(i,s.size()) {
    t+=s[i];
    if(t!=r) {
      r=t;
      t="";
      ans++;
    }
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 720
#include<iostream>
using namespace std;
typedef long long llong;
llong gcd( llong x, llong y ){
  //int r;
  llong r;
  
  if ( x < y ) swap( x, y );

  while ( y > 0 ){
    r = x % y;
    x = y;
    y = r;
  }

  return x;
}

main(){
llong a,b;
while(cin>>a>>b)cout << gcd(a,b) << " " << a*b/gcd(a,b) << endl;
}

Measured memory_bytes: 0
N = int(input())

ans = []

if N == 0:
    print("0")
else:
    while N != 1:
        if N%2 == 0:
            ans.append("0")
            N = N//(-2)
        else:
            ans.append("1")
            N = (N-1)//(-2)
    else:
        ans.append("1")

print("".join(ans[::-1]))


Measured memory_bytes: 3060
from collections import defaultdict


def main():
    d = defaultdict(int)
    N = int(input())
    for _ in range(N):
        d[input()] += 1
    freq, words = 0, set()
    for key in d.keys():
        if freq < d[key]:
            words = {key}
            freq = d[key]
        if freq == d[key]:
            words.add(key)
    print('\n'.join(sorted(words)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 115744
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/


int main() {
	
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	printyn((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d);
	
	Please AC;
}


Measured memory_bytes: 256