akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int room[23][23];
int main(){
	
	while(1){
		int w,h;
		cin>>w>>h;
		if(w==0&&h==0)break;
		int sh,sw;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				char a;
				cin>>a;
				if(a=='.')room[i][j]=0;
				if(a=='#')room[i][j]=-1;
				if(a=='@'){
					room[i][j]=1;
					sh=i;sw=j;
				}
			}
		}
		int ans=1;
		queue<pair<int,int> > q;
		q.push(pair<int,int>(sh,sw) );
		while(q.size()){
			pair<int,int> pp=q.front();q.pop();
			if(pp.first>0&&room[pp.first-1][pp.second]==0){
				q.push(pair<int,int>(pp.first-1,pp.second));
				room[pp.first-1][pp.second]=1;
				ans++;
			}
			if(pp.first<h-1&&room[pp.first+1][pp.second]==0){
				q.push(pair<int,int>(pp.first+1,pp.second));
				ans++;
				room[pp.first+1][pp.second]=1;
			}
			if(pp.second>0&&room[pp.first][pp.second-1]==0){
				q.push(pair<int,int>(pp.first,pp.second-1));
				ans++;
				room[pp.first][pp.second-1]=1;
			}
			if(pp.second<w-1&&room[pp.first][pp.second+1]==0){
				q.push(pair<int,int>(pp.first,pp.second+1));
				ans++;
				room[pp.first][pp.second+1]=1;
			}
		}
		cout<<ans<<endl;
		for(int i=0;i<23;i++){
			for(int j=0;j<23;j++){
				room[i][j]=0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3080
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    int x,k,d;
    cin>>x>>k>>d;
  if(x<0)x*=-1;
    int mn = x/d;
    
    
    if(k<=mn){
        x-=k*d;
        cout<<x<<"\n";
    }
    else{
        x-=mn*d;
        int left = k-mn;
        if(left%2==0){
            cout<<x<<"\n";
        }
        else{
            cout<<abs(x-d)<<"\n";
        }
    }
}


Measured memory_bytes: 5984
#include <stdio.h>
#include<string.h>
#define N 6
int main()
{ 
    char s[N],l;
    
   scanf("%s", &s);
   l=strlen(s);
  if(l==6){
      for(int i=0;i<l;i++){
          if(s[i]>='a' && s[i]<='z'){
            if(s[l-1]==s[l-2] && s[l-3]== s[l-4]){
                printf("Yes");
                break;
           }else{
              printf("No");
              break;
                }  
          }
      }
      
      
      
  }
  

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int n)
{
  if (n < 2)
    return false;
  if (n == 2)
    return true;
  if (n % 2 == 0)
    return false;
  for (int i = 3; i * i <= n; i += 2)
    if (n % i == 0)
      return false;
  return true;
}
int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  int cnt = 0;
  for (int i : a)
  {
    cnt += is_prime(i);
  }
  cout << cnt << endl;
  return 0;
}



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


int main() {
	int X;
	cin >> X;
	while (true)
	{

		int div = X-1;
		bool hav = false;
		while (true)
		{
			if (div == 1) {
				hav = true;
				break;
			}
			if (X % div == 0)
			{
				
				break;
			}
			div--;
			
		}
		
		if (hav)break;
		
		X++;
	}
	cout << X << endl;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a,b;
        while(true){
            a=sc.nextInt();b=sc.nextInt();
            if(a==0 && b==0)break;
            for(int i=0;i<a;i++){
                for(int j=0;j<b;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 35140
N, M = map(int, input().split())

K = [0, -1, -1, -1]
ans = -1
for i in range(M):
    s, c = map(int, input().split())
    if not N == 1 and s == 1 and c == 0:
        break
    if K[s] >= 0 and not K[s] == c:
        break
    K[s] = c
else:
    if K[1] == -1 and N >= 2:
        K[1] = 1
    if K[1] == -1 and N == 1:
        K[1] = 0
    if K[2] == -1:
        K[2] = 0
    if K[3] == -1:
        K[3] = 0

    ans = ''.join(map(str, K[1:N + 1]))

print(ans)


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

int main(){
	long long int n;
	cin>>n;
	vector<long long int> a(n);
	for(long long int i=0;i<n;i++){
		cin>>a[i];
	}
	long long int tmp;
	long long int x=2;
	for(long long int i=n-1;i>=0;i--){
		tmp=x/a[i];
		tmp*=a[i];
		while(x>tmp){
			tmp+=a[i];
		}
		x=tmp;
	}
	
	long long int tst=x;
	for(int i=0;i<n;i++){
		tst-=tst%a[i];
	}
	if(tst!=2){
		cout<<-1<<endl;
		return 0;
	}
	
	long long int y=2;
	
	for(long long int i=n-1;i>=0;i--){
		tmp=y/a[i];
		tmp*=a[i];
		while(y>tmp){
			tmp+=a[i];
		};
		tmp+=a[i]-1;
		if(i!=0){
			tmp-=tmp%a[i-1];
		}
		y=tmp;
		//cout<<y<<endl;
	}
	
	cout<<x<<" "<<y<<endl;
	
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
const int maxn = 15;
using namespace std;

int a;
char s[maxn];

int main(){
    while(~scanf("%d%s",&a,s)){
        if(a < 3200)    printf("red\n");
        else printf("%s\n",s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N;
    cin >> N ;
    
    ll sum = 0 ;
    ll m = 0 ;
    rep(i, N){
        ll l;
        cin >> l;
        sum += l;
        m = max(l, m);
    }
    sum -= m;
    
    if(sum > m) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())

Pmax = [0 for _ in range(N+1)]
Pmax[0] = 1-A[0]
for i in range(1, N+1):
    Pmax[i] = 2*Pmax[i-1] - A[i]

ans = 0
v = 0
for i in range(N, -1, -1):
    if Pmax[i]*2 < v:
        ans = -1
        break
    v = min(v, Pmax[i])+A[i]
    ans += v

print(ans)


Measured memory_bytes: 700500
inf=(10**9)+7
N=int(input().strip())
a=list(map(int, input().split()))


a.sort()
fl=True

fl=True
if N%2==0:
    for i in range(0,N,2):
        if a[i]!=i+1 or a[i+1]!=i+1:
            fl=False
            break
else:
    if a[0]!=0:
        fl=False
    for i in range(1,N,2):
        if a[i]!=i+1 or a[i+1]!=i+1:
            fl=False
            break

if fl:
    print((2**(N//2))%inf)
else:
    print(0)

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int A, B; cin >> A >> B;
  int result = (A+B-3)/(A-1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void swap(int *a, int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int *A, int p, int r){
  int x = A[r];
  int i = p-1;
  int j;
  for(j=p; j<r; j++){
    if(A[j] <= x){
      i++;
      swap(&A[i],&A[j]);
    }
  }
  swap(&A[i+1],&A[r]);
  return i+1;
}

int main(){
  int *A;
  int i,n,q;

  // input and allocation
  scanf("%d",&n);
  A = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    if(i == n-1) scanf("%d",&A[i]);
    else scanf("%d ",&A[i]);
  }

  // partition
  q = partition(A,0,n-1);

  // output
  for(i=0; i<n; i++) printf((i == q) ? ((i == n-1) ? "[%d]\n" : "[%d] ")
                            : (i == n-1) ? "%d\n"
                            : "%d " ,A[i]);

  free(A);

  return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int N;
  scanf("%d", &N);
  int  cnt = N % 1000;
  if (N < 1000){
    printf("%d\n", 1000 -N);
  }else if(cnt == 0) {
      printf("0\n");
  }else{
    printf("%d\n", (((N/1000)+1)*1000) -N);
  }
  return 0;
}

Measured memory_bytes: 1736
import java.util.*;

public class Main {
    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        String s = sc.next();

//        Character change = s.charAt(k-1);
        String change = s.substring(k-1, k);
        change = change.toLowerCase();


        String before = s.substring(0, k-1);
        String after = s.substring(k);


        System.out.print(before + change + after);

    }
}




Measured memory_bytes: 21972
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

long long int INF = 1e18;
using namespace std;

typedef pair<long long int, long long int> P;

int main(){
	
	int N;
	cin >> N;
	
	int A[200];
	
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	
	vector<int> v;
	for(int i = 0; i < N - 1; i++){
		v.push_back(A[i]);
		sort(v.begin(), v.end());
		for(int j = 0; j < v.size(); j++){
			cout << v[j] << " ";
		}
		for(int j = v.size(); j < N - 1; j++){
			cout << A[j] << " ";
		}
		cout << A[N - 1] << endl;
	}
	v.push_back(A[N - 1]);
	sort(v.begin(), v.end());
	for(int j = 0; j < v.size() - 1; j++){
		cout << v[j] << " ";
	}
	cout << v[v.size() - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

struct query {

	int l, r, idx;

};

bool cmp(const query x, const query y) {

	return y.r > x.r;


}

const int maxn = 5e5 + 5;

int fenwick[maxn];

void update(int pos, int val) {


	for (; pos <= maxn; pos += (pos & (-pos))) {

		fenwick[pos] += val;

	}



}


int sum(int pos) {


	int res = 0;


	for (; pos > 0; pos -= (pos & (-pos))) {

		res += fenwick[pos];

	}


	return res;

}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif



	int n, q;
	cin >> n >> q;

	vector<int>a(n + 1);
	vector<int>lst(n + 1);

	vector<query>queries(q);

	int cnt = 0;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < q; i++) {

		int left, right;
		cin >> left >> right;

		queries[i].l = left;
		queries[i].r = right;

		queries[i].idx = i;


	}




	for (int i = 0; i <= n; i++) {
		lst[i] = -1;
	}



	vector<int>ans(q);




	sort(queries.begin(), queries.end(), cmp);


	for (int i = 1; i <= n; i++) {




		if (lst[a[i]] != -1) {

			update(lst[a[i]], -1);


		}


		lst[a[i]] = i;

		update(i, 1);






		while (cnt < q && queries[cnt].r == i) {



			ans[queries[cnt].idx] = sum(queries[cnt].r) - sum(queries[cnt].l - 1);



			cnt++;


		}




	}




	for (int i = 0; i < q; i++) {
		cout << ans[i] << endl;
	}





}

Measured memory_bytes: 17480
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

ll a[55];
ll dp[55][55];
map<ll, ll, std::greater<ll> >mp;
int main(int argc, char const *argv[])
{
    // freopen("input.txt", "r", stdin);
    int N, A, B;
    memset(dp, 0, sizeof(dp));
    cin >> N >> A >> B;
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
    }
    sort(a, a+N, greater<ll>());
    double sum = 0.;
    for (int i = 0; i < A; ++i)
    {
        sum += a[i];
    }
    double ave = sum / A;
    int to = 0;
    for(int i = 0; i < N; ++i){
        if(a[i] == a[A-1])to++;
    }
    int m = 0;
    for (int i = 0; i < A; ++i)
    {
        if(a[i] == a[A-1])m++;
    }
    for(int i = 1; i <= N; ++i){
        for(int j = 0; j <= i; ++j){
            dp[i][j] = (i == j || j == 0 ? 1 : dp[i-1][j-1] + dp[i-1][j]);
        }
    }
    ll res = 0;
    if(a[0] == a[A-1]){
        res += dp[to][m];
        for (int i = A; i < B; ++i)
        {
            if(a[i] == a[A-1])m++;
            else break;
            res += dp[to][m];
        }
    }
    else {
        res = dp[to][m];
    }
    cout << fixed << setprecision(10);
    cout << ave << endl;
    cout << res << endl;
    return 0;
}


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

int main(){


    int N,D;
    cin >> N >> D;
    int xy[2*N];
    int count = 0,i;

    for (i = 0; i < 2*N; i=i+2)
    {
        cin >> xy[i] >> xy[i+1];
    }
    
    for (i = 0; i < 2*N; i=i+2)
    {
       if(double(D) >= sqrt(pow(double(xy[i]),2)+pow(double(xy[i+1]),2))) count++;
    }
 
    cout << count << endl;

}

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


int main(){   
    int n;
    cin >> n;
    vector<int> ans(n);
    rep (i, n-1){
        int a;
        cin >> a;
        ans[a-1]++;
    }
    for(int x : ans){
        cout << x << endl;
    }
}


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

A = 0
B = 0
for i in range(b):
    A += a * (10 ** i)

for j in range(a):
    B += b * (10 ** j)

l = [str(A), str(B)]
l2 = sorted(l)
print(int(l2[0]))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)


int main() {
    int N;
    cin>>N;
    vector<ld>X(N);
    vector<string>Y(N);
    ld ans=0;
    rep(i,N){
        cin>>X[i];
        cin>>Y[i];
        if(Y[i]=="JPY"){
            ans+=X[i];
        }
        else{
            ans+=X[i]*380000.0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n],dp[n];
	memset(dp,1000000,sizeof(dp));
	for(int i=0;i<n;i++)
	cin>>a[i];
	
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<3;j++){
			if((i+j)<n){
				dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main() {
	int H, W, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, w;

	for (a = 0;; a++) {
		cin >> H >> W;
		if (H == 0 && W == 0)
			break;

		h = H / 2;
		w = W / 2;

		if (H % 2 == 0 && W % 2 == 0) {

			for (b = 0; b < h; b++) {

				for (c = 0; c < w; c++) {
					cout << "#" << ".";
				}
				cout << endl;

				for (d = 0; d < w; d++) {
					cout << "." << "#";
				}
				cout << endl;
			}
		}

		if (H % 2 == 1 && W % 2 == 0) {

			for (e = 0; e < h; e++) {

				for (f = 0; f < w; f++) {
					cout << "#" << ".";
				}
				cout << endl;

				for (g = 0; g < w; g++) {
					cout << "." << "#";
				}
				cout << endl;
			}
			for (i = 0; i < w; i++) {
				cout << "#" << ".";
			}
			cout << endl;
		}

		if (H % 2 == 0 && W % 2 == 1) {

			for (j = 0; j < h; j++) {
				for (k = 0; k < w; k++) {
					cout << "#" << ".";
				}
				cout << "#" << endl;

				for (l = 0; l < w; l++) {
					cout << "." << "#";
				}
				cout << "." << endl;
			}
		}

		if (H % 2 == 1 && W % 2 == 1) {

			for (m = 0; m < h; m++) {

				for (n = 0; n < w; n++) {
					cout << "#" << ".";
				}
				cout << "#" << endl;

				for (o = 0; o < w; o++) {
					cout << "." << "#";
				}
				cout << "." << endl;
			}
			for (p = 0; p < w; p++) {
				cout << "#" << ".";
			}
			cout << "#" << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		ll a,b,c,d;
		scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
		if(a<b){puts("No");continue;}
		if(d<b){puts("No");continue;}
		if(a==c)a+=d;
		ll t=(a-c-1)/__gcd(b,d);
		a=a-t*__gcd(b,d);
		a-=b;
		if(a<0)puts("No");else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

int main() {
	double H, A;
	cin >> H >> A;

	cout << ceil(H/A) << endl;
}

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


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

	for(int d; cin >> d, d;) {
		int n, m;
		cin >> n >> m;

		vector<int> store;
		store.reserve(n + 1);
		store.push_back(0);
		store.push_back(d);
		for(int i = 0; i < n - 1; ++i) {
			int dist;
			cin >> dist;
			store.push_back(dist);
		}

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

		int ans = 0;
		for(int i = 0; i < m; ++i) {
			int destination;
			cin >> destination;
			vector<int>::iterator it = upper_bound(store.begin(), store.end(), destination);
			ans += min(abs(destination - *it), abs(destination - *(it - 1)));
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1504
import scala.collection.mutable._
import io.StdIn.readInt
import io.StdIn.readLine

object Main extends App {
  val out = new java.io.PrintWriter(System.out)

  def calculate(q:Array[Int],d:Array[Array[Int]]):Int = {
    val ts = q(0)
    val te = q(1)
    val st = q(2)

    val a = d.filter(_(2) == st)
    val map = HashMap.empty[Int,Array[Int]]
    val log = ListBuffer.empty[Tuple2[Int,Int]]
    a.foreach(l => {
      if(l(3) == 1) map.put(l(1),l)
      else {
        val e = map(l(1))
        log += {( e(0), l(0) )}
        }
    })
    // println(log.mkString)

    val time = Array.ofDim[Boolean](721)
    log.foreach(t => {
      val s = math.max(ts, t._1) -540
      val e = math.min(te, t._2) -540
      (s until e).foreach(time(_) = true)
    })
    time.count(_ == true)
  }

  def solve(s:String):Unit = {
    val Array(n, m) = s.split(" ").map(_.toInt)
    val r = readInt
    val d = Iterator.continually(readLine)
      .take(r)
      .map(_.split(" ").map(_.toInt))
      .toArray
    val q = readInt
    Iterator.continually(readLine)
      .take(q)
      .map(_.split(" ").map(_.toInt))
      .foreach(qd => out.println(calculate(qd,d)))
  }

  Iterator.continually(readLine)
    .takeWhile(_ != "0 0")
    .foreach(solve(_))
  
  out.flush
}


Measured memory_bytes: 59460
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[5],k;
	for(int i=0;i<5;i++) cin>>a[i];
	cin>>k;
	for(int i=0;i<5;i++)
	{
		for(int j=0;j<5;j++)
		{
			if(abs(a[i]-a[j])>k)
			{
				cout<<":(";
				return 0;
			}
		}
	}
	cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		sc.close();
		System.out.printf("%c%c%c\n", s1.charAt(0), s2.charAt(1), s3.charAt(2));
	}
}

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

using namespace std;
int main(void) {
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int j = 0;int sum = 0;
    while(j <n){
        if(a[j] == a[j+1]){
            j+=2;
        }else{
            sum += 1;
            j+=1;
        }
    }
    cout<<sum <<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	ll N; cin >> N;
	vector<ll> cnt(N+1);
	repr(i,1,N+1){
		ll d = i;
		repr(j,2,N+1){
			while(d % j == 0){
				d /= j;
				cnt[j]++;
			}
		}
	}
	ll ans = 1;
	repr(i,2,N+1){
		ans *= (cnt[i]+1);
		ans %= MOD;
	}
	cout << ans << endl;
	


}



Measured memory_bytes: 256
#include <cstdio>
#include <bitset>
#include <algorithm>
#define rep(i,j,k) for (i=j;i<=k;i++)
#define down(i,j,k) for (i=j;i>=k;i--)
using namespace std;
const int N=405,M=1e5+5;
int n,m,i,j,ans,u[M],v[M],kill[N];
bitset<N> b[N];
int main()
{
//	freopen("turkey.in","r",stdin);
//	freopen("turkey.out","w",stdout);
	scanf("%d%d",&n,&m);
	rep(i,1,m) scanf("%d%d",&u[i],&v[i]);
	rep(i,1,n)
	{
		b[i][i]=1;
		down(j,m,1)
			if (b[i][u[j]] || b[i][v[j]])
			{
				if (b[i][u[j]] && b[i][v[j]])
				{
					kill[i]=1; break;
				}
				b[i][u[j]]=b[i][v[j]]=1;
			}
	}
	rep(i,1,n-1)
	if (!kill[i])
		rep(j,i+1,n)
			if (!kill[j] && (b[i]&b[j]).none()) ans++;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)
typedef long long ll;

const int N = 1000300;
const int mod =  998244353;
const ll inf = 1e18;
int n;
int x[N], y[N];
int used[N];
ll ans = 0;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    fo(i, n) cin >> x[i] >> y[i];
    sort(x, x + n + 1); reverse(x, x + n + 1);
    sort(y, y + n + 1);
    for(int i = 0; i <= n; ++i) ans += max(0, 2 * (x[i] - y[i]));
    cout << ans;

    return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include <cmath>
//for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;

int main(){
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
#define MD 2019
long long L;
long long R;
int main(){
  long long i, j, k, res;
  rd(L);
  rd(R);
  if(R-L > 4100){
    R = L+4100;
  }
  res = 1073709056;
  for(i=L;i<R+1;i++){
    for(j=i+1;j<R+1;j++){
      chmin(res, (i*j)%MD);
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190707-1

// --- original code ---
// #define MD 2019
// 
// ll L, R;
// {
//   ll i, j, k;
//   ll res;
// 
//   rd(L,R);
// 
//   if(R-L > 4100) R = L+4100;
// 
//   res = int_inf;
//   rep(i,L,R+1) rep(j,i+1,R+1){
//     res <?= (i*j)%MD;
//   }
//   wt(res);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    ll ans;
    cin >> ans;
    rep(i, N - 1){
        ll a;
        cin >> a;
        ans = gcd(ans, a);
    }
    print(ans);

    
    return 0;
}

Measured memory_bytes: 256
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n  = read_line(int)

as_ = [int(col) for col in input().split()]

max_a = -1
max_aa = -1

count = {}

for a in as_:
    if a not in count:
        count[a] = 1
    else:
        count[a] += 1

        if a == max_a:
            pass
        elif a > max_a:
            max_aa = max_a
            max_a = a
        elif a > max_aa:
            max_aa = a
    # print(count, max_a, max_aa)

if max_a > 0 and count[max_a] >= 4:
    print(max_a * max_a)
    exit()

if max_a > 0 and max_aa > 0:
    print(max_a * max_aa)
    exit()

print(0)


Measured memory_bytes: 18060
#include<bits/stdc++.h>
#define crap ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define int ll

using namespace std;
const int mod = 1e9+7;
int n,m;
char A[1005][1005];
int dp[1005][1005];


int solve(int i,int j){
	if(i==0 && j==0) return 1;
	//if(i==0 || j==0) return 1;
    if(i<0 || j<0) return 0;
	if(dp[i][j]!=-1) return dp[i][j];
	int a=0,b=0;
	if(i-1>=0 && A[i-1][j]!='#') a =  max(a, solve(i-1,j));
	if(j-1>=0 && A[i][j-1]!='#') b = max(b,solve(i,j-1));

	return dp[i][j]= (a+b)%mod;
}

int32_t main()
{
   
    crap;
    memset(dp,-1,sizeof(dp));
    
    cin>>n>>m;
    for(int i=0;i<n;i++){
    	for(int j=0;j<m;j++)
    		cin>>A[i][j];
    }

    int ans = solve(n-1,m-1);

    cout<<ans%mod<<endl;
   
   
}

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
    string s;
    cin >> s;
    string t="";
    for(int i=0;i<s.size();i++){
        if(i%2==0)t.push_back(s[i]);
    }
    cout << t << endl;
}

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


Measured memory_bytes: 512
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself
        
*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define mp make_pair
#define d(x) cout<<x<<"\n"

int mod(int k, int n) {
    return ((k %= n) < 0) ? k+n : k;
}

int32_t main(void)
{
    fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;cin>>n;
        int ar[n];
        for(int i=0;i<n;i++)
        cin>>ar[i];
        sort(ar,ar+n,greater<int>());
        int sum=0;
        for(int i=1;i<n;i++)
        sum+=ar[i/2];
        cout<<sum<<"\n";
        
    }
    
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vi v(N);

    Rep(i,N){
        Scd(v[i]);
    }

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

    double ans = v[0];

    Rep(i,N-1){
        ans += v[i+1];
        ans /= 2;
    }

    printf ("%lf\n", ans );

    return 0;
}



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

using namespace std;

int main(){
        int N,Sn=0;
        cin >> N;
        for(int i=9;i>=0;i--){
                Sn=Sn+N/(int)pow(10,i)%10;
        }
        if(N%Sn==0) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}


Measured memory_bytes: 256
l = []                                                                                                                                                                                                       
while True:
    try:

        stn,a,b = map(float,raw_input().split(","))

        bmi = a/(b**2)
        if bmi >= 25:
            l.append(int(stn))



    except EOFError:
        break

if len(l) == 0:
    print "not found"
else:
    for i in range(len(l)):
        print l[i]

Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//template<class T> inline void
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct edge{
    int to;
    ll cost;
    ll fee;
};

struct state{
    int from;
    ll cost;
    ll money;
};

auto compare = [](const state a, const state b) {
    return a.cost > b.cost;
};

int n, m, s;
int C[60], D[60];
vector<edge> G[60];
ll dist[60][3030];

void dijkstra(int S) {

    priority_queue<state, vector<state>, decltype(compare)> pq(compare);
    pq.push({S, 0, s});
    while(pq.size()){
        state now = pq.top(); pq.pop();
        for(auto nxt : G[now.from]) {
            ll cost = now.cost + nxt.cost;
            ll money = now.money - nxt.fee;
            if (money < 0) continue;
            if (chmin(dist[nxt.to][money], cost)) {
                pq.push({nxt.to, cost, money});
            }
        }
        ll money = now.money + C[now.from];
        chmin(money, (ll)50 * n);
        ll cost = now.cost + D[now.from];
        if (chmin(dist[now.from][money], cost)){
            pq.push({now.from, cost, money});
        }
    }
    return;
}

void solve() {
    cin >> n >> m >> s;
    chmin(s, 50 * n);
    rep(i, m) {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        G[u].pb({v, b, a});
        G[v].pb({u, b, a});
    }
    rep(i, n) {
        cin >> C[i] >> D[i];
    }
    rep(i, 60) rep(j, 3030) dist[i][j] = LINF;
    dist[0][s] = 0;
    dijkstra(0);
    rep(i, n) {
        if (!i) continue;
        ll ret = LINF;
        rep(j, 3030) {
            chmin(ret, dist[i][j]);
        }
        cout << ret << endl;
    }
    return ;
}

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


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

int main() {
	string s, t;
	cin >> s;
	t = s;
	reverse(t.begin(), t.end());
	int ans = 0;
	rep(i, s.size()) if (s[i] != t[i]) ans++;
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int ans = 0;
            String n = sc.next();
            for (int i = 0 ; i < n.length(); i++) {
                ans +=  Character.getNumericValue(n.charAt(i));
            }
            System.out.println(Integer.parseInt(n) % ans == 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 26964
#include <stdio.h>

int main()
{
	int i, N, D, X, A[101];
	scanf("%d", &N);
	scanf("%d %d", &D, &X);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int ans = X;
	for (i = 1; i <= N; i++) ans += (D - 1) / A[i] + 1;

	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int a[3]={3600,60,1};

int scnd(int h,int m,int s){
  int inpt[3]={h,m,s};
  int i;
  int n=0;
  for(i=0;i<3;i++){
    n=n+a[i]*inpt[i];
  }

  return n;
}

int lefttape(int h,int m,int s,int f){
  int scd=scnd(h,m,s);
  int t;
  if(f==0){
    t=1;
  }
  else{
    t=3;
  }

  return t*(7200-scd);
}

int whttm(int s,int f){
  if(f/3==0){
    return s/a[f%3];
  }
  else{
    return s%a[f%3];
  }
}

void ans(int h,int m,int s){
  int answer[6];
  int i;
  for(i=0;i<2;i++){
    int sc=lefttape(h,m,s,i);
    int j;
    for(j=0;j<3;j++){
      answer[i*3+j]=whttm(sc,j);
      sc=whttm(sc,j+3);
    }
  }
  for(i=0;i<6;i++){
    if(answer[i]<10){
      printf("0");
    }
    printf("%d",answer[i]);
    if(i%3==2){
      printf("\n");
    }
    else{
      printf(":");
    }
  }
}

void doit(){
  int h,m,s;
  scanf("%d %d %d",&h,&m,&s);
  if(h!=-1){
    ans(h,m,s);
    doit();
  }
}

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

Measured memory_bytes: 604
fun main(args: Array<String>) {
    val l = readLine()!!.toString().map { it.toInt() - 48}
    var over = l.sum() - 7
    var vct = mutableListOf<String>("+", "+", "+")
    var bit = mutableListOf(0, 0, 0)
    var bitminussum = 0
    var tmp = 0
    var bitweight = 0
    for(i in 0 until 8){
        tmp = i
        bit = mutableListOf(0, 0, 0)
        bitminussum = 0
        for(j in 0 until 3) {
            bitweight = Math.pow(2.0, (2 - j).toDouble()).toInt()
            if (tmp >= bitweight) {
                bit[j] = tmp / bitweight
                tmp -= bitweight
            }
        }
        for (j in 0 until 3){
            bitminussum += l[j + 1] * bit[j]
        }
        if(bitminussum * 2 == over){
            for (j in 0 until 3){
                if(bit[j] == 1){
                    vct[j] = "-"
                }
            }
            break
        }
    }
    println(l[0].toString() + vct[0] + l[1] + vct[1] + l[2] + vct[2] + l[3] + "=7")
}

Measured memory_bytes: 33716
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input! { n: usize }
    println!("{}", n/3);
}

Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
	string str = "";

	getline (cin, str );

	if (str.length() != 1){
		reverse (str.begin(), str.end() );
	} // end if

	cout << str << endl;	
		
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> m;
    REP(i,n) {
        int x; cin >> x;
        auto it = m.find(x);
        if (it == m.end()) m[x] = 0;
        m[x]++;
    }

    bool ans = false;

    if (m.size() == 1 && m.begin()->first == 0) ans = true;

    if (n % 3 == 0) {
        if (m.size() == 2 ) {
            for(auto kv : m) {
                if (kv.first == 0) {
                    if (kv.second * 3 == n ) ans = true;
                }
            }
        } else if (m.size() == 3) {
            vector<int> k;
            vector<int> v;
            for(auto kv : m) {
                k.emplace_back(kv.first);
                v.emplace_back(kv.second);
            }
            if (v[0] == v[1] && v[1] == v[2]) {
                if ((k[2] ^ k[1]) == k[0]) ans = true;
                if ((k[2] ^ k[0]) == k[1]) ans = true;
                if ((k[0] ^ k[1]) == k[2]) ans = true;
            }
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>
#include<vector>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	vector<int> L;

	cin >> N;
	for(int i=0;i<N;i++)
	{
		int tmp;
		cin >> tmp;
		L.push_back(tmp);
	}
	L.push_back(1e7);

	sort(L.begin(),L.end());
	
	int ans=0;
	for(int i=0;i<N;i++)
	{
		for(int j=i+1;j<N;j++)
		{
			auto r=lower_bound(L.begin(),L.end(),L[i]+L[j]);
			ans+=max(0,(int)distance(L.begin(),r)-j-1);
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint N;
  lint addcount=0,ans=0;
  cin >> N;
  lint A[N],B[N];
  rep(i,N) cin >> A[i] >> B[i];
  reprev(i,N){
    lint add=B[i]-(A[i]+addcount)%B[i];
    if(add==B[i]) add=0;
    ans+=add;
    addcount+=add;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
h,w=map(int,input().split())
c=[list(input()) for _ in range(h)]
cc=[0]*(h*2)
for i in range(h):
    cc[i*2]=c[i]
    cc[i*2+1]=c[i]
for i in range(h*2):
    print("".join(cc[i]))


Measured memory_bytes: 3188
fn dfs(x: &Vec<i32>, i: usize, s: i32, res: String) -> Option<String> {
    if i == x.len() {
        if s == 7 {
            return Some(res + "=7");
        } else {
            return None;
        }
    } else {
        {
            let mut ns = res.clone();
            ns += "+";
            ns += &x[i].to_string();
            if let Some(r) = dfs(x, i + 1, s + x[i], ns) {
                return Some(r);
            }
        }
        {
            let mut ns = res.clone();
            ns += "-";
            ns += &x[i].to_string();
            if let Some(r) = dfs(x, i + 1, s - x[i], ns) {
                return Some(r);
            }
        }
    }
    None
}
fn main() {
    let s: Vec<char> = readln();
    let x: Vec<i32> = s.iter().map(|&x| (x as u8 - '0' as u8) as i32).collect();

    let ans = dfs(&x, 1, x[0], x[0].to_string()).unwrap();
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352