akhauriyash/Code-Regression huggingface dataset:
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int cnt=0;
  reverse(s.begin(),s.end());
  while(cnt<s.size()-1) {
   if(s.substr(cnt,5)=="maerd") {
      cnt+=5;
    }
    else if(s.substr(cnt,7)=="remaerd") {
      cnt+=7;
    }
    else if(s.substr(cnt,5)=="esare") {
      cnt+=5;
    }
    else if(s.substr(cnt,6)=="resare") {
      cnt+=6;
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 512
using System;

namespace ITP1_5_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int H, W;
            while(true)
            {
                string[] str = Console.ReadLine().Split(' ');
                H = int.Parse(str[0]);
                W = int.Parse(str[1]);

                if((H == 0)&&(W == 0))
                    break;

                for(int i = 0;i < H; ++i)
                {
                    for(int j = 0;j < W;++j)
                    {
                        if((i*j == 0)||((H-1-i)*(W-1-j)==0))
                            Console.Write("#");
                        else
                            Console.Write(".");
                    }
                    Console.Write("\n");
                }

                Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
using namespace std;
int m,k;
int fac[31];
int main(){
    fac[0] = 1;
    for(int i = 1;i <= 30;++i){
        fac[i] = fac[i-1] * 2;
    }
    cin >> m >> k;
    if(m == 1 && k == 1)
        cout << "-1\n";
    else if(fac[m] - 1 < k) cout << "-1\n";
    else if(m == 1 && k == 0)
        cout << "0 0 1 1\n";
    else{
        for(int i = 0;i <= fac[m] - 1;++i){
            if(i == k)continue;
            cout << i << " ";
        }
        cout << k << " ";
        for(int i = fac[m]-1;i >= 0;--i){
            if(i == k)continue;
            cout << i << " ";
        }
        cout << k << "\n";
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string s;
	cin >> s;
	int x = s.size();
	for (int i = 0; i < x-1; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 
 int N;
 int x;
 int y;
 
 scanf("%d", &N);
 
 x = N % 100;
 y = x % 10;
 
 switch(y){
 case 3:
  printf("bon");
  break;
 case 0:
 case 1:
 case 6:
 case 8:
  printf("pon");
  break;
 default:
  printf("hon");
 }
 
 return 0;
}


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

typedef long long lint;
typedef long double ldouble;
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

const int MAX_N = (int)1e5 + 10;
vector<bool> isPrime(MAX_N, true);

void eratosthenes(int N){
    rep(i, 2){
        isPrime[i] = false;
    }
    for(int i = 2 ; i * i <= N ; i++){
        if(isPrime[i]){
            for(int j = 2 ; i * j <= N ; j++){
                isPrime[i*j] = false;
            }
        }
    }
    return;
}

int main(){
    eratosthenes(MAX_N-1);
    vector<int> sum(MAX_N);
    sum[0] = 0;
    REP(i, 1, MAX_N){
        if(i % 2 == 1 && isPrime[i] && isPrime[(i+1)/2]){
            sum[i] = 1;
        }else{
            sum[i] = 0;
        }
        sum[i] += sum[i-1];
    }
    int q;
    cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l-1] << endl;
    }
    return 0;
}

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

int main() {
	//int input[3000][2];
	int x, y;
	//int count=0;

	// for(int i=0; i<3000; i++) {
	// 	input[i][0] = 0;
	// 	input[i][1] = 0;
	// }

	while(cin >> x >> y) {
		if((x == 0) && (y == 0)) break;
		if(x>y) cout << y << " " << x << endl;
		else{
			cout << x << " " << y << endl;
		}


		// if((x != 0) && (y != 0)) {
		// 	if(x > y) {
		// 		input[count][1] = x;
		// 		input[count][0] = y;
		// 	}else{
		// 		input[count][0] = x;
		// 		input[count][1] = y;
		// 	}
		// 	count++;
		// }else{
		// 	break;
		// }
		
	}

	// for(int i=0; i<count; i++) {
	// 	cout << input[i][0] << " " << input[i][1] << endl;
	// }
	return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int main(){
    Fast;
    ll n;
    cin>>n;
    vector<ll>v(n);
    ll sum=0;
    map<ll,ll>mp;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
        mp[v[i]]++;
    }
    int q;
    cin>>q;
    while(q--){
        ll l,r;
        cin>>l>>r;
        ll temp=mp[l];
        mp[l]=0;
        mp[r]+=temp;
        sum+=(r*temp);
        sum-=(l*temp);
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 10052
#include <iostream>
using namespace std;
int main(){
  string S; cin >> S;
  int max_len = 0;
  int cnt = 0;
  for(int i = 0; i < S.size(); i++){
    if(S.at(i) == 'A' or S.at(i) == 'C' or S.at(i) == 'G' or S.at(i) == 'T') cnt++;
    else{
      max_len = max(cnt, max_len);
      cnt = 0;
    }
  }
  max_len = max(cnt, max_len);
  cout << max_len << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける

int main(){
  int N, count=0;
  cin >> N;
  if (N>=10000)
  {
    count += min(90000,N-10000+1);
  }
  if (N>=100)
  {
    count += min(900,N-100+1);
  }
  if (N>=10)
  {
    count += 9;
  }
  if (N<10)
  {
    count += N;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define loop(n) for(ll i=0;i<n;i++)
#define loop4(i,n) for(ll i=0;i<n;i++)
#define rng(i,a,b,c) for(ll i = a; i<b;i+=c)
#define loop2(i,a,b) for(long long i = a; i>=b;i--)
#define loop3(j,a,b) for(int j = a; j<b;j++)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long   
#define ld long double
#define SET set<ll>
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked

using namespace std; 

//cout<<setprecision(4) << fixed;
/*int compare(string str1, string str2){
   if(str1.length() < str2.length())
   return 1;
   return 0;
}*/
/* int to string-
int c=0;
stringstream ss;
ss<<c;
string str=ss.str();*/
/* STRING TO INT
string s;
	cin>>s;
	reverse(s.begin(),s.end());
	stringstream ss(s);
	ll a=0;
	ss>>a;*/
//about maps
/*unordered_map <int,int> g;
loop(n)
{
	g.insert(make_pair(b[i],i));
}
 int* i1; 
    i1 = std::min_element(v + 2, v + 5); 
    cout<<*i1;
 
//getline

cin.ignore();
getline(cin,s);    

*/
// no getchar_unlocked on Windows so call _getchar_nolock
/*

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

inline int getchar_unlocked() { return _getchar_nolock(); }
inline ll read() {  
 ll n=0;  
 char p=getchar_unlocked();  
 while((p<'0'||p>'9')&&p!=EOF)  
 p=getchar_unlocked();  
 while(p>='0'&&p<='9')  
 {  
 n = (n<< 3) + (n<< 1) + (p - '0');  
 p=getchar_unlocked();}  
 return n;
}

void dfs(vector<ll> adj[],ll vis[],ll u)
{

	if(vis[u]==0)
	{
		cout<<u<<' ';
		vis[u]=1;
		for(auto x:adj[u])
		{
			if(vis[x]==0 )
			{
			dfs(adj,vis,x);
		    }
		}
	}
}
*/

void go()
{
	string n;
	
	cin>>n;
	
	
	
	ll ans=0;
	
	loop(n.length())
	{
		ans+=n[i]-'0';
	}
	if(ans%9==0)
	cout<<"Yes"<<'\n';
	else
	cout<<"No"<<'\n';
//
}

int main() 
{
ll t;

fast;

//cin>>t; 

//while(t--)
go();
}


Measured memory_bytes: 3720
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        boolean d = false;
        if(a == 5 && b == 5 && c == 7){
             d = true;
        }else if(a == 5 && b == 7 && c == 5){
            d = true;
        }else if(a == 7 && b == 5 && c == 5){
            d = true;
        }
        if(d){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  
  for(int i = 1; i <= n; i++){
    long long ans = 0;
    for(int x = 1; x * x < n; x++){
      for(int y = x; y * y < n; y++){
        for(int z = y; z * z < n; z++){
          int k = x * x + y * y + z * z + x * y + y * z + z * x;
          if(k != i) continue;
          int cnt = 1;
          if(x != y){
            if(y != z) cnt *= 6;
            else cnt *= 3;
          }
          else if(y != z) cnt *= 3;
          ans += cnt;
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll>v[100005];
ll indegree[100005],dp[100005];

int main()
{
    ll n,m; cin>>n>>m;
    queue<ll>q;
    for(ll i=0;i<m;i++)
    {
        ll x,y; cin>>x>>y;
        v[x].push_back(y);
        indegree[y]++;
    }
    for(ll i=1;i<=n;i++)
    {
        if(indegree[i]==0)
        {
            q.push(i);
        }
    }
    ll top[n+1];
    ll i=0;
    while(!q.empty())
    {
        ll x=q.front();
        q.pop();i++;
        top[i]=x;
        for(ll i=0;i<v[x].size();i++)
        {
            indegree[v[x][i]]--;
            if(indegree[v[x][i]]==0)
            {
                q.push(v[x][i]);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        ll x=top[i];
        for(ll j=0;j<v[x].size();j++)
        {
            dp[v[x][j]]=max(dp[v[x][j]],dp[x]+1);
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        ans=max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11356
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;
using namespace chrono;

//  https://ja.wikipedia.org/wiki/Xorshift
int xor64(void) {
	static unsigned long long x = 88172645463325252ULL;
	x ^= x << 13;
	x ^= x >> 7;
	x ^= x << 17;
	return int(x & 0x7fffffff);
}

int main()
{
	//  入力
	int D;
	cin >> D;
	vector<int> C(26);
	for (int &c : C)
		cin >> c;
	vector<vector<int>> S(D, vector<int>(26));
	for (auto &s : S)
		for (auto &x : s)
			cin >> x;

	auto start = system_clock::now();

	//  選んだコンテスト
	vector<int> T(D, -1);

	int score = 0;
	for (int t = 0; t < 26; t++)
		score -= C[t] * D*(D + 1) / 2;

	//  d日目にコンテストtを開く
	auto add = [&](int d, int t)
	{
		int d0 = d;
		while (d0 >= 0 && T[d0] != t)
			d0--;
		int d1 = d;
		while (d1 < D && T[d1] != t)
			d1++;
		score += C[t] * (d - d0)*(d1 - d);
		score += S[d][t];
		T[d] = t;
	};

	//  d日目のコンテストを止める
	auto remove = [&](int d)
	{
		int t = T[d];
		T[d] = -1;
		int d0 = d;
		while (d0 >= 0 && T[d0] != t)
			d0--;
		int d1 = d;
		while (d1 < D && T[d1] != t)
			d1++;
		score -= C[t] * (d - d0)*(d1 - d);
		score -= S[d][t];
	};

	for (int d = 0; d < D; d++)
		add(d, d % 26);

	double time = 0.0;
	double limit = 1.925;

	int step;
	for (step = 0; time < limit; step++)
	{
		if (step % 10000 == 0)
			time = duration_cast<microseconds>(system_clock::now() - start).count() * 1e-6;

		if (step % 2 == 0)
		{
			//  1日のコンテストの種類を変えてみる
			int d = xor64() % D;
			int t = xor64() % 26;
			int old_score = score;
			int old_t = T[d];
			remove(d);
			add(d, t);

			//  悪くなったら戻す
			if (score < old_score)
			{
				remove(d);
				add(d, old_t);
			}
		}
		else
		{
			//  1週間以内のコンテストを交換してみる
			int d0 = xor64() % D;
			int d1 = d0 + xor64() % 15 - 7;
			if (d1 != d0 && 0 <= d1 && d1 < D)
			{
				int old_score = score;
				int t0 = T[d0];
				int t1 = T[d1];
				remove(d0);
				remove(d1);
				add(d0, t1);
				add(d1, t0);

				//  悪くなったら戻す
				//  ただし、ある程度までは許容する
				//  許容範囲は時間とともに狭める（焼きなまし）
				if (score < old_score - int(10000 * (limit - time) / limit))
				{
					remove(d0);
					remove(d1);
					add(d0, t0);
					add(d1, t1);
				}
			}
		}
	}

	for (int t : T)
		cout << t + 1 << endl;

	cerr << "score: " << max(0, score + 1000000) << endl;
	cerr << "step: " << step << endl;
}


Measured memory_bytes: 3604
N,K=map(int,input().split())
xy=[]
X=[]
Y=[]
for i in range(N):
    x,y=map(int,input().split())
    xy.append([x,y])
xy.sort()
X=[i[0] for i in xy]
Y=[i[1] for i in xy]
ans=10**30
for i in range(K,N+1):
    for j in range(N+1-i):
        X_=X[j:j+i]
        Y_=Y[j:j+i]
        Y_.sort()
        a=max(X_)-min(X_)
        for k in range(i-K+1):
            z=Y_[k:k+K]
            b=max(z)-min(z)
            ans=min(ans,a*b)
print(ans)


Measured memory_bytes: 41948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll N;
	cin >> N;
	vector<ll> A(N+2, 0);
	vector<ll> cAo(N+2, 0); // 1からの累積和
	vector<ll> cAe(N+2, 0); // 2からの累積和

	// 累積の計算
	ll ao = 0;
	ll ae = 0;
	ll cmin = 0;
	A.at(0) = 0;
	cAo.at(0) = 0;
	cAe.at(0) = 0;
	for (ll i = 1; i <= N; i++) {
		ll a;
		cin >> a;
		A.at(i) = a;
		if (i % 2 == 1) {
			ao += a;
		}
		else {
			ae += a;
		}
		cAo.at(i) = ao;
		cAe.at(i) = ae;
		if (a < 0) {
			cmin += a;
		}
	}
	A.at(N + 1) = 0;
	cAo.at(N + 1) = ao;
	cAe.at(N + 1) = ae;

	ll cmax = cmin;
	// 累積和の計算
	if (N % 2 == 0) {
		// N is even
		for (ll i = 1; i <= N + 1; i = i + 2) {
			ll c = cAo.at(i-1) + cAe.at(N) - cAe.at(i);
			if (cmax < c) { cmax = c; }
		}
		cout << cmax << endl;
	}
	else { 
		// n is odd
		vector<ll> cAimax(N + 2, 0);
		cAimax.at(0) = cAo.at(0) - cAe.at(1);
		for (ll i = 1; i <= N+1; i++) {
			cAimax.at(i) = max(cAimax.at(i-1), cAo.at(i - 1) - cAe.at(i));
		}
		vector<ll> cAkmax(N + 2, 0);
		cAkmax.at(N + 1) = cAe.at(N) - cAo.at(N + 1);
		for (ll k = N; k >= 1; k--) {
			cAkmax.at(k) = max(cAkmax.at(k+1), cAe.at(k - 1) - cAo.at(k));
		}
		// 加算
		for (ll i = 1; i <= N; i++) {
			ll c = cAimax.at(i) + cAkmax.at(i+1) + cAo.at(N);
			if (cmax < c) { cmax = c; }
		}
		cout << cmax << endl;
	}
}


Measured memory_bytes: 11120
#include <iostream>
using namespace std;
int main(void){
	int dp[31];
	dp[0]=dp[1]=1;
	dp[2]=dp[1]+1;
	for(int i=3;i<=30;i++)
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	for(int i=1;i<=30;i++)
		dp[i]=dp[i]/3650+1;
	int n;
	while(cin >> n,n){
		cout << dp[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
a,b = list(map(int, input().split()))

c = []
if a%2 == 0:
    if b%2 == 0:
        # e e 
        c = [int(((b - 1 - a + 1)/2)%2), b]
    else:
        # e o
        c = [int(((b - a + 1)/2)%2)]
else:
    if b%2 == 0:
        # o e
        c = [a, (int((b - a)/2)%2), b]
    else:
        # o o
        c = [a, int(((b + 1 - a)/2)%2)]

d = 0
for cc in c:
#     print(c)
    d += int(bin(cc)[2:])
    d = str(d)
    d = d.replace('2', '0')
    d = int(d)
    
print(int(str(d), 2))

Measured memory_bytes: 3064
#include <iostream>
 
using namespace std;
 
int main()
{
    char a = 'a';
    int val = 0;
    
    cin >> a;
    
    val = a;
    val++;
    
    if (val > 122){
        a = val - 26;
    }
    else{
        a = val;
    }
    cout << a;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
 bool compare(string a1, string b1) {
     return a1<b1;
 }
 
int main() {
	int n, l;
	cin >> n >> l;
	string arr[n];
	for(int i=0; i<n; i++)
	    cin >> arr[i];
	  
	 sort(arr, arr+n, compare);

	 for(int i=0; i<n; i++)
	    cout << arr[i];
	 return 0;
}

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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i < N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

constexpr ll inf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    ll n;
    ll ans;
    in(n);
    ll h[n];
    floop(i, n) in(h[i]);
    ll dp[n];
    floop(i, n) dp[i] = inf;
    dp[0] = 0;
    floop1(i, n)
    {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1)
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    out(dp[n - 1]);
}

Measured memory_bytes: 1792
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  if(c == 'A') cout << "T" << endl;
  if(c == 'T') cout << "A" << endl;
  if(c == 'G') cout << "C" << endl;
  if(c == 'C') cout << "G" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int main(void){
    int h,w;
    cin >> h >> w;

    vector<vector<int>> dist(h,vector<int>(w,-1));
    queue<pair<int,int>> q;
    for(int i = 0;i < h;i++){
        string s;
        cin >> s;
        for(int j = 0;j < w;j++){
            if(s[j] == '#'){
                dist[i][j] = 0;
                q.push(pair<int,int>(i,j));
            }
        }
    }
    int cnt = 0;
    while(!q.empty()){
        auto p = q.front();
        q.pop();
        for(int k = 0;k < 4;k++){
            int x = p.first + dx[k],y = p.second + dy[k];
            if(x < 0 || x >= h || y < 0 || y >= w) continue;
            if(dist[x][y] == -1){
                dist[x][y] = dist[p.first][p.second] + 1;
                cnt = max(cnt,dist[x][y]);
                q.push(pair<int,int>(x,y));
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
  int n, d;
  cin >> n >> d;
  int x[n][d];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
    }
  }
  
  int ans = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      double dis = 0;
      for(int k = 0; k < d; k++){
        dis += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      dis = sqrt(dis);
      if(dis == (int)dis) ans++;
    }
  }
  
  cout << ans << endl;    
}


Measured memory_bytes: 256
N,K = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(K*2)]
T = [True for _ in range(N)]
for i in range(len(S)):
  if i%2 == 1:
    for s in S[i]:
      T[s-1] = False
      
print(sum(T))
    


Measured memory_bytes: 67628
a,b,x=map(int,input().split())
import math
arg=0
if 2*x>=a**2*b:
  arg=math.degrees(math.atan((2*a**2*b-2*x)/(a**3)))
else:
  arg=math.degrees(math.atan((a*b**2)/(2*x)))
print(arg)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int sum=0;
  int m=n;
  for (int i=1;i<=3;i++)
  {
    sum+=m;
    m*=n;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	double l;
	cin >> l;

	l /= 3;

	printf("%.10f\n", l*l*l);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
        double r,area,circumference;

        cin >> r;

        area = 2*M_PI*r;
        circumference = M_PI*r*r;
        
        cout << fixed << setprecision(6);
        cout << circumference << " " << area << endl;
return 0;
}



Measured memory_bytes: 3288
# https://abc100.contest.atcoder.jp/tasks/abc100_d
# D - Patisserie ABC

# D_Patisserie_ABC.py

#import collections

N, M = map(int, input().strip().split(" "))
A = [[] for i in range(8)]
for n in range(N):
    # 「綺麗さ」「おいしさ」「人気度」
    x, y, z = map(int, input().strip().split(" "))

    A[0].append(x+y+z)
    A[1].append(-x+y+z)
    A[2].append(x-y+z)
    A[3].append(x+y-z)
    A[4].append(x-y-z)
    A[5].append(-x+y-z)
    A[6].append(-x-y+z)
    A[7].append(-x-y-z)


T = []
for i in range(8):
    A[i].sort()
    total = 0
    for _ in range(M):
        total += A[i].pop()
    T.append(total)

T.sort()
print(T[-1])


Measured memory_bytes: 3316
import math
from collections import *
import sys
inp=sys.stdin.readline

def linp(x):
    return list(map(int,x.split()))
def minp(x):
    return map(int,x.split())
    
def main():
    l,r,d = minp(inp())
    rem = l%d
    if rem!=0:
        l += d-rem
    if l>r:
        print(0)
    else:
        c=0
        while l<=r:
            c+=1
            l+=d
        print(c)



if __name__ == "__main__":
    main()

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define filename "I"
#define freop freopen(filename ".out","w",stdout);freopen(filename ".in","r",stdin)
const long long int N = ((long long int)1e5) + 5;
const long long int M = ((long long int)1e3) + 5;
const long long int llinf = (long long int)1e18;
const int inf = INT_MAX;
typedef long long int lli;

lli n;
lli arr[N];
lli prime[3000 * 2];
vector<lli> prim;
map<lli,lli> tamlayan;
map<lli,lli> cnt;
lli ans;
map<lli,bool> aldim;

void init ()
{
	for (lli i = 2; i <= 3000; i++)
	{
		if (prime[i] != 0)
			continue;
		prim.pb(i);
		for (lli j = i * i; j <= 3000; j += i)
		{
			prime[j] = i;
		}
	}
}

void aciz (lli ind, lli x)
{
	vector<pair<lli,lli> > v;
	lli t = x;
	for (auto i : prim)
	{
		if (t % i != 0)
			continue;
		lli cnt = 0;
		while (t % i == 0)
		{
			cnt++;
			t /= i;
		}
		cnt %= 3;
		if (cnt != 0)
		{
			v.pb({i,cnt});
		}
	}

	lli tam = 1;
	lli sayi = 1;

	for (auto i : v)
	{
		for (lli j = 1; j <= i.second; j++)
			sayi *= i.first;
	}
	for (auto i : v)
	{
		for (lli j = 1; j <= ((3 - i.second) + 3) % 3; j++)
			tam *= i.first;
	}
	if (t != 1)
	{
		if ((lli)sqrt(t) * (lli)sqrt(t) == t)
		{
			sayi *= t;
			tam *= (lli)sqrt(t);
		}
		else
		{
			sayi *= t;
			tam *= t * t;
		}
	}
	arr[ind] = sayi;
	tamlayan[sayi] = tam;
	cnt[sayi]++;
}

int main ()
{
	fast;
	//freop;
	cin >> n;
	init();
	for (lli i = 1; i <= n; i++)
	{
		cin >> arr[i];
	}
	for (lli i = 1; i <= n; i++)
	{
		aciz(i,arr[i]);
	}
	for (lli i = 1; i <= n; i++)
	{
		if (aldim[arr[i]] || aldim[tamlayan[arr[i]]])
			continue;
		if (arr[i] == 1)
		{
			ans++;
			aldim[1] = true;
			continue;
		}
		ans += max(cnt[arr[i]],cnt[tamlayan[arr[i]]]);
		aldim[arr[i]] = true;
		aldim[tamlayan[arr[i]]] = true;
	}
	cout << ans << "\n";
}


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


#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}
bool vis[100009];
vi g[100009];
set<pii> ans;
int cnt[100009];
void dfs(int v){
	vis[v] = 1;
	trav(i,g[v]){
		if(!vis[i]){
			dfs(i);
			if(cnt[i]%2){
				if(ans.find(mp(v,i))==ans.end()){
					ans.erase(mp(i,v));
					ans.insert(mp(v,i));
					cnt[i]++;
					cnt[v]--;
				}
				else {
					ans.erase(mp(v,i));
					ans.insert(mp(i,v));
					cnt[i]++;
					cnt[v]--;
				}
			}
		}
	}
}
int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	int m;cin>>m;
	if(m%2){
		cout<<-1;
	}
	else{
		rep(i,m){
			int u,v;cin>>u>>v;
			g[u].pb(v);
			cnt[u]++;
			ans.insert(mp(u,v));
			g[v].pb(u);
		}
		dfs(1);
		trav(i,ans) cout<<i.fst<<' '<<i.snd<<'\n';
	}
	return 0;
}



Measured memory_bytes: 18304
#include <iostream>
#include <fstream>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
#ifdef LOCAL
    ifstream cin("input.txt");
    ofstream cout("output.txt");
#else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#endif // LOCAL

    int n;
    cin >> n;
    vector<int> pos(n + 1);
    for (int i =0; i < n; ++i)
    {
        int k;
        cin >> k;
        pos[k] = i;
    }
    long long ans = 0;
    set<int> taken_pos;
    for (int i = 1; i <= n; ++i)
    {
        int l = -1, r = n;
        auto it = taken_pos.lower_bound(pos[i]);
        if (it == taken_pos.end())
        {
            r = n;
            if (!taken_pos.empty())
                l = *taken_pos.rbegin();
        }
        else
        {
            r = *it;
            if (it != taken_pos.begin())
            {
                --it;
                l = (*it);
            }
        }
        ans += (long long)i * (pos[i] - l) * (r - pos[i]);
        taken_pos.insert(pos[i]);
    }
    cout << ans << "\n";

#ifdef LOCAL
    cin.close();
    cout.close();
#endif // LOCAL
    return 0;
}


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

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  string a, b;
  cin >> a >> b;

  enum { LESS, EQUAL, GREATER };
  array <string, 3> table = {"LESS", "EQUAL", "GREATER"};

  size_t ans = EQUAL;
  if (a.length () < b.length ()) ans = LESS;
  else if (a.length () > b.length ()) ans = GREATER;
  else
  {
    if (a < b) ans = LESS;
    else if (a > b) ans = GREATER;
    else if (a == b) ans = EQUAL;
    else assert (false);
  }

  cout << table [ans] << endl;
}


Measured memory_bytes: 256
# B　解２
S = input()
K = 'keyence'
lenK = len(K)
for i in range(len(S)+1):
    rem = S[:i]
    rem2 = S[-lenK+i:]
    if len(rem2)>7: rem2 = ''
    rem += rem2
    #print(rem)#
    if rem==K:
        res = 'YES'
        break
else: res = 'NO'        
print(res)

Measured memory_bytes: 3060
#include <iostream>

int main()
{
	int A, B;
	std::cin >> A >> B;
	
	if ( A == 1 ){
		A = 14;
	}	

	if (  B == 1 ){
		B = 14;
	}

	if ( A > B ){
		std::cout << "Alice" << std::endl;
	}else if ( A < B ){
		std::cout << "Bob" << std::endl;
	}else{
		std::cout << "Draw" << std::endl;
	}

	return 0;
}

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

int main(int argc, char const *argv[]) {
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int cnt = 0;

  for (int r = 0; r * R <= N; r++) {
    for (int g = 0; r * R + g * G <= N; g++) {
      if ((N - r * R - g * G) % B == 0) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,c,ah,bh,ch,cou=0;
    scanf("%d %d %d",&a,&b,&c);
  	if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
      printf("0\n");
      return 0;
    }
    if (a==b&&b==c) {
        printf("%d\n",-1);
    }else{
        for(;;){
            ah=a/2;bh=b/2;ch=c/2;
            a=bh+ch;b=ah+ch;c=ah+bh;
            cou++;
            if(a%2==1||b%2==1||c%2==1)break;
        }printf("%d\n",cou);
    }
    return 0;
}

Measured memory_bytes: 128
def ALDS1_1_A():
    """
    1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
    2   for i が 1 から N-1 まで
    3     v = A[i]
    4     j = i - 1
    5     while j >= 0 かつ A[j] > v
    6       A[j+1] = A[j]
    7       j--
    8     A[j+1] = v

    ＜問題＞
    N 個の要素を含む数列 A を昇順に並び替える挿入ソートのプログラムを作成してください。
    上の疑似コードに従いアルゴリズムを実装してください。アルゴリズムの動作を確認するため、
    各計算ステップでの配列（入力直後の並びと、各 i の処理が終了した直後の並び）を出力してください。

    ＜入力＞
    入力の最初の行に、数列の長さを表す整数 N が与えられます。2 行目に、N 個の整数が空白区切りで与えられます。

    ＜出力＞
    出力は N 行からなります。挿入ソートの各計算ステップでの途中結果を 1 行に出力してください。
    配列の要素は１つの空白で区切って出力してください。最後の要素の後の空白など、余計な空白や改行を含めると
    Presentation Error となりますので注意してください。

    ＜制約＞
    1 ≤ N ≤ 100
    0 ≤ A の要素 ≤ 1,000
    """
    N = int(input())
    A = [int(e) for e in input().split(" ")]
    print(" ".join(map(str, A)))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j += -1
            A[j+1] = v
        print(" ".join(map(str, A)))


def main():
    ALDS1_1_A()


if __name__ == '__main__':
    main()


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

int main() {
	char a;
	rep(i, 3) {
		cin >> a;
		if (a == '1') {
			cout << 9;
		}
		else {
			cout << 1;
		}
	}
	printf("\n");
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var height, width int
	fmt.Scan(&height, &width)

	rows := make([]string, height)
	for i := 0; i < height; i++ {
		fmt.Scan(&rows[i])
	}

	for i := 0; i < height; i++ {
		for j := 0; j < width; j++ {
			if rows[i][j] == '#' {
				fmt.Print("#")
			} else {
				count := 0
				for k := i - 1; k < i+2; k++ {
					for l := j - 1; l < j+2; l++ {
						if isIn(k, l, height, width) {
							if rows[k][l] == '#' {
								count++
							}
						}
					}
				}
				fmt.Printf("%d", count)
			}
		}
		fmt.Printf("\n")
	}
}

func isIn(i int, j int, h int, w int) bool {
	return (i > -1 && i < h) && (j > -1 && j < w)
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

    private static final int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int g = 1;
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            g = gcd(g, A[i]);
        }

        List<Integer> primes = createPrimes();
        Map<Integer, Integer> lcmSpec = new HashMap<>();
        for (int i = 0; i < N; i++) {
            int a = A[i]/g;
            for (int prime : primes) {
                int count = 0;
                while (a%prime == 0) {
                    count++;
                    a /= prime;
                }
                int old = lcmSpec.getOrDefault(prime, 0);
                lcmSpec.put(prime, Math.max(old, count));
            }
            lcmSpec.put(a, 1);
        }

        long lcmMod = g;
        for (Map.Entry<Integer, Integer> entry : lcmSpec.entrySet()) {
            int p = entry.getKey();
            int c = entry.getValue();
            lcmMod *= powMod(p, c);
            lcmMod %= MOD;
        }

        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += (lcmMod*powMod(A[i], MOD-2))%MOD;
            ans %= MOD;
        }

        System.out.println(ans);
    }

    private static long powMod(int a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b%2 == 1) {
            return (a*powMod(a, b-1))%MOD;
        }
        long half = powMod(a, b/2);
        return (half*half)%MOD;
    }

    private static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a%b);
    }

    private static List<Integer> createPrimes() {
        List<Integer> primes = new ArrayList<>();
        for (int a = 2; a <= 1_000; a++) {
            boolean isPrime = true;
            for (int i = 2; i*i <= a; i++) {
                if (a%i == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                primes.add(a);
            }
        }
        return primes;
    }
}


Measured memory_bytes: 47456
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		ArrayList<Integer> input = new ArrayList<Integer>();

		Scanner scanner = new Scanner(System.in);
		Integer n = Integer.valueOf(scanner.nextLine());
		String line = scanner.nextLine();
		
		Arrays.asList(line.split(" "))
			.forEach(it -> input.add(Integer.valueOf(it)));
		
		List<Integer> evenList = IntStream.rangeClosed(0, input.size() - 1)
			.filter(i -> i % 2 == 0)
			.map(i -> input.get(i))
			.boxed()
			.collect(Collectors.toList());
		
		List<Integer> oddList = IntStream.rangeClosed(0, input.size() - 1)
				.filter(i -> i % 2 == 1)
				.map(i -> Integer.valueOf(input.get(i)))
				.boxed()
				.collect(Collectors.toList());
		
		ArrayList<Integer> result = new ArrayList<Integer>();
		if (n % 2 == 0) {
			Collections.reverse(oddList);
			result.addAll(oddList);
			result.addAll(evenList);
		} else {
			Collections.reverse(evenList);
			result.addAll(evenList);
			result.addAll(oddList);
		}
		result.forEach(it -> System.out.print(it.toString() + " "));
		System.out.println("");
	}
}

Measured memory_bytes: 90720
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
static const int dx[] = {0,0,1,-1};
static const int dy[] = {1,-1,0,0};
typedef pair< int,int > PII;
typedef pair< int,pair<int,int> > PPII;

int N,T;
int a[100005];
int ans;

signed main(){
    cin>>N>>T;
    for(int i=0;i<N;++i)cin>>a[i];
    int mincost=INF;
    int d=0;
    for(int i=0;i<N;++i){
        if(mincost>a[i])mincost=a[i];
        if(d<a[i]-mincost){
            d=a[i]-mincost;
            ans=1;
        }
        else if(d==a[i]-mincost)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <utility>
#include <string>
using namespace std;
typedef int64_t I;
typedef vector<I> vI;
typedef pair<I, I> II;
typedef vector<II> vII;
typedef vector<vII> vvII;

template<typename T>
ostream& operator<<(ostream& os, vector<T> const& v) {
  os << "[";
  for (size_t i = 0; i < v.size(); i++) {
    os << (i == 0 ? "" : ",") << v[i];
  }
  return os << "]";
}

template<typename S, typename T>
ostream& operator<<(ostream& os, tuple<S, T> const& v) {
  return os << "<" << get<0>(v) << "," << get<1>(v) << ">";
}

template<typename S, typename T, typename U>
  ostream& operator<<(ostream& os, tuple<S, T, U> const& v) {
  return os << "<" << get<0>(v) << "," << get<1>(v) << "," << get<2>(v) << ">";
}

const I M = 1000000007;

I pow(I x, I y) {
  if (y == 0) return 1;
  else if (y == 1) return x;
  I y2 = y / 2;
  return pow(x, y2) * pow(x, y - y2) % M;
}

vI make(vII const& r) {
  vI rr(1, 1);
  for (size_t l = 0; l < r.size(); l++) {
    I i = r[l].first, v = r[l].second;
    vI newrr(rr);
    for (size_t j = 0; j < rr.size(); j++) {
      I jj = rr[j];
      for (I k = 0; k < v; k++) {
        newrr.push_back(jj * pow(i, (k + 1)));
      }
    }
    rr.swap(newrr);
  }
  return rr;

}
vI factors(I n) {
  I k = n;
  I i = 2;
  vII r;
  while (i * i <= k) {
    I v = 0;
    while (k % i == 0) {
      v += 1;
      k /= i;
    }
    if (v > 0) {
      r.push_back(II(i, v));
    }
    i += 1;
  }
  if (k > 1) {
    r.push_back(II(k, 1));
  }
  return make(r);
}

int main() {
  I n, k; cin >> n >> k;
  vI counts(k + 1);
  for (I i = 1; i <= k; i++) {
    I k1 = k / i;
    if (i > 1 && k1 == k / (i - 1))
      counts[i] = counts[i - 1];
    else
      counts[i] = pow(k1, n);
  }
//  cerr << "counts=" << counts << endl;
  for (I i = k; i >= 1; i--) {
    vI f = factors(i);
//    cerr << "factors(i=" << i << ")=" << f << endl;
    for (auto j : f) {
      if (j != i) {
        counts[j] = (counts[j] - counts[i] + M) % M;
      }
    }
  }
//  cerr << "counts=" << counts << endl;
  I r = 0;
  for (I i = 1; i <= k; i++) {
    r = (r + counts[i] * i) % M;
  }
  cout << r << endl;
}



Measured memory_bytes: 4044
def main():
    N = int(input())
    pt, px, py = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        tmp = t - pt - (abs(x-px) + abs(y-py))
        if tmp < 0 or tmp % 2 == 1:
            print("No")
            return
        pt, px, py = t, x, y
    print("Yes")


if __name__ == "__main__":
    main()


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

int main(){
    using namespace std;
    size_t n;
    cin >> n;
    
    vector<size_t> a(n);
    for(auto& i : a)cin >> i;
    
    unsigned long ans{0};
    
    bool f{true};
    while(f){
        f = false;
        for(size_t i = 1; i < n; ++i)if(a[i] < a[i - 1] && ++ans && (f = true))swap(a[i], a[i - 1]);
    }
    copy(a.begin(), a.end() - 1, ostream_iterator<size_t>(cout, " "));
    cout << a.back() << endl << ans << endl;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,x[105],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
		if(i%2==1&&x[i]%2==1)ans++;
	}
	cout<<ans;
	return 0;
}

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

int data[30];

void solve(int a,int c){
    if(a==0){
        for(int i=0;i<c;i++){
            cout<<data[i];
            (i==c-1)?cout<<endl:cout<<" ";
        }
        return;
    }
    if(a<0)return;
    for(int i=a;i>0;i--){
        if(c==0||data[c-1]>=i){
            data[c]=i;
            solve(a-i,c+1);
        }
    }
    return;
}

int main(void){
    int n;
    while(cin>>n,n!=0){
        solve(n,0);
    }
    return 0;
}

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

int main() {
  int a, b, ans;
  cin >> a >> b;
  if (a >= 13) ans = b;
  else if (a <= 5) ans = 0;
  else ans = b / 2;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long

//#define int long long

using namespace std;
const int MN = 1e3+7;
const int MOD = 1e9+7;

int n, m, dp[MN][MN], a[MN][MN];

signed main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        for(int j = 0; j < m; j++){
            a[i][j] = s[j] == '.';
        }
    }
    dp[0][0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(i > 0){
                dp[i][j] += dp[i-1][j];
            }
            if(j > 0){
                dp[i][j] += dp[i][j-1];
            }
            dp[i][j] = a[i][j] * dp[i][j];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n-1][m-1] % MOD;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  ll n, k;
  cin >> n >> k;

  n = n - k * (n / k);
  while (1)
  {
    ll tmp = abs(n - k);

    if (n <= tmp)
    {
      cout << n << endl;
      return 0;
    }
    else
    {
      n = tmp;
    }
  }
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

const int N=2e5+20;

int n,k,a[N];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);

	for(int i=k;i<n;i++)
		if(a[i]>a[i-k]) puts("Yes");
		else puts("No");
}

Measured memory_bytes: 4424
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll n,m,s=0;
		cin>>n>>m;
		ll a[m];
		for(int i=0;i<m;i++){
			cin>>a[i];
			s+=a[i];
		}
		if(s>n){
			cout<<-1;
		}
		else
			cout<<n-s;
		
	}
	return 0;
}

Measured memory_bytes: 3720
import sys
n=int(input())
data=[[] for i in range(n+1)]
for i in range(1,n+1):
    s=[None]+list(input())
    for j in range(1,n+1):
        if s[j]=="1":
            data[i].append(j)

#二部グラフ判定
flag=[-1]*(n+1)
for i in range(1,n+1):
    if flag[i]==-1:
        que=[[i]]
        flag[i]=0
        k=1
        while que[0]:
            h=que[0]
            H=[]
            for u in h:
                for v in data[u]:
                    if flag[v]==-1:
                        flag[v]=k
                        H.append(v)
                    else:
                        if flag[v]==k:
                            continue
                        else:
                            print(-1)
                            sys.exit()
            k=(k+1)%2
            que=[H]

#washall
inf=float("inf")
d=[[inf]*(n+1) for i in range(n+1)]
for i in range(1,n+1):
    d[i][i]=0
for i in range(1,n+1):
    for u in data[i]:
        d[i][u]=1
for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        ans=max(ans,d[i][j])

print(ans+1)

Measured memory_bytes: 66396
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;

  ll n; cin >> n;

  vector<int> a;
  while(n > 0) {
    n-=1;
    a.push_back(n % 26);
    n /= 26;
  }
  reverse(ALL(a));
  REP(i,a.size()) {
    cout << (char)('a' + a[i]);
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200005;
char str[N];
int n , cnt[26];

int main() {
    scanf("%s" , str);
    n = strlen(str);
    LL res = (LL)n * (n - 1) / 2 + 1;
    for (int i = 0 ; i < n ; ++ i) {
        ++ cnt[str[i] - 'a'];
        /*for (int j = 0 ; j < n ; ++ j) {

          }*/
    }
    for (int i = 0 ; i < 26 ; ++ i) {
        res -= (LL)cnt[i] * (cnt[i] - 1) / 2;
    }
    cout << res << endl;

}


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

constexpr int INF = 1e9;
int V, E;
vector<vector<int>> dp, dist;

int dfs(int vis, int v) {
    if (vis == ((1<<V)-1)) return v ? INF : 0;
    int& res = dp[vis][v];
    if (res > 0) return res;
    res = INF;
    for (int i = 0; i < V; i++) {
        if ((vis>>i)&1) continue;
        res = min(res, dist[v][i]+dfs(vis|(1<<i), i));
    }
    return res;
}

int main() {
   cin >> V >> E;
   dist = vector<vector<int>>(V, vector<int>(V, INF));
   for (int i = 0; i < E; i++) {
       int s, t, d;
       cin >> s >> t >> d;
       dist[s][t] = d;
   }
   dp = vector<vector<int>>(1<<V, vector<int>(V, -1));
   int res = dfs(0, 0);
   cout << (res < INF ? res : -1) << endl;
}

Measured memory_bytes: 4432
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String[] atcoder = sc.next().split("");
        String[] s = sc.next().split("");
        String[] contest = sc.next().split("");
        
        System.out.println(atcoder[0] + s[0] + contest[0]);
    }
}

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


int main(){

  vector<int> tim(5);
  int minwk=125;
  int min_index=0;
  for(int i=0;i<5;i++){
    cin>>tim.at(i);
    int rem=tim.at(i)%10;
    
    if(rem<minwk&&rem!=0){
      min_index=i;
      minwk=rem;
    }
  }

  int sum=0;
  for(int i=0;i<5;i++){
    if(i!=min_index)
      sum+=((tim.at(i)+9)/10)*10;
  }

  cout<<sum+tim.at(min_index)<<endl;

  return 0;

}


Measured memory_bytes: 256
using System;

namespace AOJ.Volume2
{
    public class BigHit
    {
        public static int Main()
        {
            while (true)
            {
                var input = Console.ReadLine().Split(' ');
                int b = int.Parse(input[0]);    // ????????°????????????
                int r = int.Parse(input[1]);    // ??????????????????
                int g = int.Parse(input[2]);    // ??¶??????
                int c = int.Parse(input[3]);    // ?????§??????
                int s = int.Parse(input[4]);    // ?????????
                int t = int.Parse(input[5]);    // ??????????????°
                if (b + r + g + c + s + t == 0) { break; }

                int coin = 100; // 100?????????????????????
                // ????????????????????????????????????2?????\????????¨15???????????????(?????????????????????????????°*13???????????????)
                // 7????????£????????¨BAR????????£?????????12????????????????¢???????
                coin += (b + r) * 12;

                int bonus = (b * 5) + (r * 3);
                coin += bonus * 13;
                t = t - b - r - bonus;
                // ??¶?????????????????¨7???????????????(??¶??????????????£????????°*4???)
                coin += g * 4;
                t -= g;
                // ?????§?????????????????¨2???????????????(?????§??????????????£????????°*(-1)???)
                coin -= c;
                t -= c;
                // ????????????????????¨?¬?????????????(?????????????¢?????????????)
                t -= s;

                // ??????????????°??§?????£????????????????????¬????????§????????¬?????°*(-3)???
                coin -= t * 3;

                Console.WriteLine(coin);
            }
            return 0;
        }
    }
}

Measured memory_bytes: 9040
ans = 0
n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
  
l = sorted(make_divisors(n))

a = l[len(l) // 2]
print(len(str(a)))

Measured memory_bytes: 3060