akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)55;
const int mod = (int)1e9 + 7;
 
#define inf mod
 
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

int n, dp[maxn], a[maxn], b[maxn];
vi ans;
bool check(ll msk){
	forn(i, 1, n){
		memset(dp, 0, sizeof(dp));
		dp[a[i]] = 1;
		forev(val, 50, 0){
			if(!dp[val]) continue;
			forn(u, 1, 50){
				if((msk >> u) & 1)
					dp[val % u] = 1;
			}
		}
		if(!dp[b[i]]) return 0;
	}
	return 1;
}
void solve(){
	cin >> n;
	forn(i, 1, n) scanf("%d", &a[i]);
	forn(i, 1, n) scanf("%d", &b[i]);
	ll msk = (1ll << 51) - 1;
	if(!check(msk)){
		puts("-1");
		return;
	}
	forev(k, 50, 0){
		msk ^= (1ll << k);
		if(!check(msk)) msk ^= (1ll << k);
	}
	printf("%lld", msk);
}

int main () {
  solve();
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cn count;
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
    ll a,b,c,d,lcm,ans;
    cin>>a>>b>>c>>d;
    lcm= c*d/__gcd(c,d);
    ans = b-a;
    ans -= (b/c)-(a/c);
    ans -= (b/d)-(a/d);
    ans += (b/lcm)-(a/lcm);
    if(a%d!=0 && a%c!=0)ans++;
    cout<<ans<<"\n";
    
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 3660
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    char string[7];
    char *str1 = "Yes";
    char *str2 = "No";

    scanf("%s",string);
    if(string[2]==string[3] && string[4]==string[5]){
        printf("%s\n",str1);
    }
    else{
        printf("%s\n",str2);
    }
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define N (int)(1e5+7)
#define inf (int)(1e9+7)
#define INF (long long) (1e18*7)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int M = (int)(2e6 + 239);

int n,m,x;
long long a[20][20],v[22];

bool f(){
    for(int i=1;i<=m;i++){
        if(v[i] < x)return false;
    }
    return true;
}

void solve(){
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        for(int j=0;j<=m;j++){
            cin>>a[i][j];
        }
    }
    long long ans=INF,cnt=0;
    for(int i=1;i<=4100;i++){
        //cout<<i<<'\n';
        cnt=0;
        for(int j=0;j<12;j++){
            if((i&(1<<j))){
                //cout<<j<<' ';
                cnt+=a[j][0];
                for(int k=1;k<=m;k++){
                    v[k]+=a[j][k];
                }
            }
            //cout<<'\n';
        }
        //cout<<cnt<<'\n';
        if(f()){
            ans=min(ans,cnt);
            cnt=0;
        }
        for(int k=0;k<20;k++){
            v[k]=0;
        }
    }
    cout<<(ans == INF ? -1 : ans)<<'\n';
    return;
}
 
int main(){
    fastio;
    solve();
    return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main()
{
    int X,Y;

    char S[20];
    char T[20];
    char U[20];

    scanf("%s %s",S,T);
    scanf("%d %d",&X,&Y);
    scanf("%s",U);


    if(strcmp(S,U)==0)
    {


    X--;
    printf("%d %d",X,Y);
    }


  else
    {

    Y--;
    printf("%d %d",X,Y);
    }

    return 0;
}


Measured memory_bytes: 1712
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M, K = sc.nextInt()
  val as = Array.fill(N)(sc.nextLong()).scanLeft(0L)(_ + _)
  val bs = Array.fill(M)(sc.nextLong()).scanLeft(0L)(_ + _)

  @scala.annotation.tailrec
  def loop(diff: Long, j: Int): Int = if (diff < bs(j)) loop(diff, j - 1) else j

  val (max, _) = as.indices.foldLeft((0, M)) {
    case ((acc, m), i) =>
      if (K < as(i)) acc -> m
      else {
        val j = loop(K - as(i), m)
        acc.max(i + j) -> j
      }
  }
  println(max)
}


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

int main(){
    int a;
    int b;
    string ans = "";
    cin >> a >> b;
    if(a == b){
        for(int i = 0; i < a; i++) ans += to_string(a); 
    }
    else
    {
        int c = min(a, b);
        int d = max(a, b);
        for(int i = 0; i < d; i++) ans += to_string(c);
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define dupli(a)     unique(all(a)),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;


int main(){

   
    int n;
    cin>>n;
    int c=n%1000;
   	if(n%1000==0) pt(c);
   	else pt(1000-c);

    
    
    

}


/*

// 

*/

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  int takahashiAT = C / B;
  if(C % B > 0) ++ takahashiAT;
  int aokiAT = A / D;
  if(A % D > 0) ++ aokiAT;

  string ans = "Yes";
  if(takahashiAT > aokiAT) ans = "No";

  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>

int data[1001][1001];
char set1[1000], set2[1000];
int shori(int, int);
void shokika();

int main(){
  
  int n, i, x, y, max, temp; /*x:横 y:縦*/

  for(i = 0; i <= 1000; i++)
    {
      data[0][i] = 0;
      data[i][0] = 0;
    }

  scanf("%d",&n);
  
  for(i = 0; i < n; i++)
    {
      shokika();
      scanf("%s%s",set1,set2);
      for(y = 0; y <= 1000; y++)
	{
	  //printf("set2[%d] = %c\n",y,set2[y]);
	  if(set2[y] == NULL)break;
	  for(x = 0; x <= 1000/*set1[x] != NULL*/; x++)
	    {
	      //printf("set1[%d] = %c\n",x,set1[x]);
	      if(set1[x] == NULL)break;
	      temp = shori(x + 1, y + 1);
	      if(temp > max || x == 0)max = temp;
	    }
	}
      printf("%d\n",max);
    }
  
  return 0;
}

int shori(int x, int y)
{
  int n, flag = 0;
  
  if(set1[x - 1] == set2[y - 1])flag = 1;
  
  switch(flag)
    {
    case 0:
      
      if(data[x-1][y] > data[x][y-1])return data[x][y] = data[x-1][y];
      
      else return data[x][y] = data[x][y-1];
      
    case 1:
      
      return data[x][y] = data[x-1][y-1] + 1;
    }
}

void shokika()
{
  int i;
  for(i = 0; i <= 1000 && set1[i] != NULL; i++)set1[i] = NULL;
  for(i = 0; i <= 1000 && set2[i] != NULL; i++)set2[i] = NULL;
}



Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  int ans=a;
  int cu=1;
  while(ans<b){
    ans+=a-1;
    cu++;
  }
  if(b==1){
    cu=0;
  }
  cout<<cu<<endl;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}

int b[200005][22];
int cnt[22];

signed main() {
	int n, ans = 0;
	cin >> n;
	int a[200005];
	rep(i, n) cin >> a[i];
	rep(i, n) {
		rep(j, 21) {
			b[i][j] = a[i] / (1 << j) % 2;
		}
	}
	int r = -1;
	int l = 0;
	for (;;) {
		bool bou = true;
		while (r < n) {
			rep(i, 21) {
				if (cnt[i] > 1) {
					bou = false;
					break;
				}
			}
			if (!bou) break;
			r++;
			rep(i, 21) cnt[i] += b[r][i];
		}
		if (l == n) break;
		ans += r - l;
		rep(i, 21) {
			cnt[i] -= b[l][i];
		}
		l++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 36224
import numpy as np
H, W, K = map(int,input().split())
S = np.array([ [0 if j == '.' else 1 for j in list(input())] for i in range(H)])
sharp = 0
ans = np.array([0] * H * W)
ans = ans.reshape([H, W])
flg = 0
count = 0

ww = 0
for k in reversed(range(W)):
  if sum(S[:, k]) == 0:
    ww +=1
    break

for i, s in enumerate(S):
  ss=sum(s)
  if ss > 0:
    if flg == 0:
      top = ans[i, :]
      flg += 1
    for j in range(W-ww):
      x = s[j]
      if j == 0:
        sharp += 1
        sharp_ = sharp
      if x == 0:
        ans[i, j] = sharp
      else:
        ans[i, j] = sharp
        if sharp < sharp_ + ss - 1:
          sharp += 1
  else:
    if flg == 0:
      count += 1
    if i > 0:
      ans[i, :] = ans[i-1, :]

for i in range(count):
  ans[i, :] = top

if ww > 0:
  right = ans[:, W - ww - 1]
  for i in range(W - ww, W):
    ans[:, i] = right
  

for s in list(ans):
  print(' '.join(map(str,list(s)) ))


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

int main(){
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        cout << a-1 << " " << b << endl;
    }else{
        cout << a << " " << b-1 << endl;
    }
}


Measured memory_bytes: 3620
import java.util.Scanner;
public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int cnt = 0;
		int []ans = new int [n];
		
		for(int i = n ;i >= 1 ;i--) {
			int temp = 0;
			for(int j = 2 ; j * i <= n; j++) {
				if(ans[j*i-1] == 1) {
					temp++;
				}
			}
			if(temp % 2 == a[i-1]) {
				continue;
			}
			else {
				cnt++;
				ans[i-1]++;
			}
		}
		
		System.out.println(cnt);
		for(int i = 0 ;i < n ;i ++) {
			if(ans[i] != 0) {
				System.out.println(i+1);
			}
		}
		
	}
}


Measured memory_bytes: 51280
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int H = sc.nextInt();
            int A = sc.nextInt();
            System.out.println(H / A + (H % A == 0 ? 0 : 1));
        }
    }
}


Measured memory_bytes: 27068
#include <stdio.h>
#include <math.h>
#define MAX 1000000
int main(){
    int i,j,max,ch[MAX];

    max=sqrt(MAX);

    for(i=0;i<MAX;i+=2){ch[i]=0;ch[i+1]=1;}

    ch[1]=0;
    ch[2]=1;

    for(i=3;i<max;i+=2) if(ch[i]) for(j=i<<1;j<MAX;j+=i) ch[j]=0;

    for(i=3;i<MAX;i++) ch[i]+=ch[i-1];

    while(scanf("%d",&i)!=EOF) printf("%d\n",ch[i]);

    return 0;
}

Measured memory_bytes: 4500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderTest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            List<int> gA = new List<int>() { 1, 3, 5, 7, 8, 10, 12 };
            List<int> gB = new List<int>() { 4, 6, 9, 11 };
            List<int> gC = new List<int>() { 2 };

            string[] s = Console.ReadLine().Split();
            int x = int.Parse(s[0]);
            int y = int.Parse(s[1]);
            
            if(gA.Contains(x) == true && gA.Contains(y) == true)
            {
                Console.WriteLine("Yes");
            }
            else if(gB.Contains(x) == true && gB.Contains(y) == true)
            {
                Console.WriteLine("Yes");
            }
            else if(gC.Contains(x) == true && gC.Contains(y) == true)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    ll cv = 1;
    while((cv * 2) <= n) {
        cv *= 2;
    }
    cout << cv << endl;
    return 0;
}


Measured memory_bytes: 256
/***********************************************************************************
*           Falling down is an accident, Staying down is a choice.                 *
***********************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) //Fast IO
#define _USE_MATH_DEFINES
#define PI acos(-1.0) //3.14159265358
#define EPS 1e-9 //epsilon, 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
const int inf=1e9+7; //10^9 +7
const int modc=998244353;
typedef long long int ll;
void solve();int main(){ios;solve();return 0;}
/***********************************************************************************/
void solve()
{
	int n;cin>>n;
	ll ans=n*n*n;
	cout<<ans<<endl;
}

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

int main()
{
	fast;
	string s;
	cin >> s;
	ll ans = 0;
	for (char c: s) {
		ans+=c-'0';
	}
	cout << (ans%9 ? "No" : "Yes");
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
// #define fore(i,a) for(auto &i:a)
// #define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// 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; }

using namespace std;

int main()
{
  int n,k;
  cin>>n>>k;
  
  vector<int> dk;
  vector<vector<int>> A;
  dk.resize(k);
  A.resize(k);
  
  rep(i,0,k){
    cin>>dk[i];
    A[i].resize(dk[i]);
    rep(j,0,dk[i]){
      cin>>A[i][j];
    }
  }
  
  vector<int> sunuke;
  sunuke.resize(n);
  
  rep(i,0,n){
    sunuke[i]=0;
  }
  
  rep(i,0,k){
    rep(j,0,dk[i]){
      sunuke[A[i][j]-1]++;
    }
  }
  
  int count=0;
  rep(i,0,n){
    if(sunuke[i]==0) count++;
  }
  
  cout<<count<<endl;
  
  return 0;
}

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

using namespace std;

int main() {
    // 締め切りが早い順に片付ける以外の方法はない
    int N;
    cin >> N;

    int timeSpent = 0;
    string ans = "Yes";
    vector<pair<int,int>> jobs; // deadlineでソートするため(deadline, timeframe)

    for (int i = 0; i < N; ++i) {
        int A, B; // timeframe, deadline
        cin >> A >> B;
        jobs.emplace_back(B, A);
    }

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

    for (auto job : jobs){
        timeSpent += job.second;
        if (timeSpent > job.first){
            ans = "No";
            break;
        }
    }

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


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    int ans=0;
    for(int i=1; i<=n; i++){
        ans+=i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::str::FromStr;
use std::io::{ self, stdin };
use std::io::BufRead;

fn main() {
    let N: u32 = input();

    for _ in 0..N {
        let mut val_vec: Vec<u32> = input_vec();
        val_vec.sort();
        let mut val_iter = val_vec.into_iter();
        let v1 = val_iter.next().unwrap().pow(2);
        let v2 = val_iter.next().unwrap().pow(2);
        let v3 = val_iter.next().unwrap().pow(2);
        if v1 + v2 == v3 {
            println!("YES");
        } else {
            println!("NO");
        }

    }
}

pub fn input<T>() -> T
where T:FromStr
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).expect("input error");
    let parse_result = buf.trim().parse::<T>();
    if let Ok(v) = parse_result {
        v
    } else {
        panic!("parse error");
    }
}

pub fn input_vec<T>() -> Vec<T>
where T: FromStr
{
    let mut buf = String::new();
    stdin().read_line(&mut buf).expect("input error");
    let split_vec: Vec<_> = buf.trim().split(" ").collect();
    split_vec.iter()
        .map(|&v|{
            let parse_result = v.parse::<T>();
            if let Ok(v) = parse_result { v }
            else {panic!("parse error");}
        })
        .collect::<Vec<T>>()
}


Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}
int ctoi(char ch) { return ch - '0'; }

int main() {
  string S;
  cin >> S;
  int ans;
  rep(i, 1 << 3) {
    int temp = ctoi(S[0]);
    vector<int> sign(3);
    rep(j, 3) {
      sign[j] = ((i >> j) & 1) * 2 - 1;
      temp += sign[j] * ctoi(S[j + 1]);
    }

    if (temp == 7) {
      cout << S[0];
      rep(j, 3) {
        char sig = (sign[j] == 1) ? '+' : '-';
        cout << sig << S[j + 1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,a=2,b=1,c;
int main()
{
	cin>>n;
	if(n<1) {cout<<2<<endl;return 0;} else if(n<2) {cout<<1<<endl;return 0;}
	for(int i=1;i<=n;i++)
	{
		c=a+b;
		a=b;
		b=c;
	} 
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int count=0,bb=0;
  long long int N,A,B;
  cin>>N>>A>>B;
  
     bb = ((N/(A+B))*A) + min(N%(A+B),A);
     cout<<bb<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        long[][] ab = new long[n][2];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
            ab[i][0] = a[i] + b[i];
            ab[i][1] = i;
        }
        Arrays.sort(ab, Comparator.comparingLong(o -> o[0]));
        long ans = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                ans += a[(int) ab[n - 1 - i][1]];
            } else {
                ans -= b[(int) ab[n - 1 - i][1]];
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 65160
//============================================================================
// Name        : ATcoder.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main() {

	ll x=0;
	ll n;

	cin>>n;
	ll m=n;
	ll k=10;
	for(int i=1; i<11; ++i){
		x+=n%k;
		n=n/k;
	}
	if(m%x==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}




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

using namespace std;

int main(){
//int W,H,x,y,r;
    int N,M;
    cin>>N;
    vector<int> X(N);

for(int i=0;i<N;i++){
    cin>>X.at(i);    
}

cin>>M;
vector<int> A(M);

for(int i=0;i<M;i++){
    cin>>A.at(i);
}

for(int i=0;i<M;i++){
    if(A[i]!=N){
        if(X.at(A.at(i)-1)+1 != X.at(A.at(i)))
        X.at(A.at(i)-1)++;
    }else{
        if(X.at(A.at(i)-1) !=2019)
        X.at(A.at(i)-1)++;   
    }
}  
  
  for(int i=0;i<N;i++){
  cout<<X.at(i)<<endl;
  }
  return 0;
}


Measured memory_bytes: 3076
from collections import defaultdict

N = int(input())
*A, = map(int, input().split())
INF = 10**20
dp = [[defaultdict(lambda :-INF) for _ in range(N+1)] for _ in range(2)]
dp[0][0][0] = 0

for i in range(1, N+1):
    for j in range(i//2-1, i//2+2):
        dp[1][i][j] = max(dp[1][i][j], dp[0][i-1][j-1]+A[i-1])
        dp[0][i][j] = max(dp[1][i-1][j], dp[0][i-1][j])

ans = max(dp[1][N][N//2], dp[0][N][N//2])
print(ans)


Measured memory_bytes: 291220
#include<iostream>
using namespace std;
int main(){
  	int h,n,i,a,x=0;
  	cin >> h >> n;
  	for(i=0;i<n;i++){
    	cin >> a;
      	x+=a;
    }
  	if(x>=h){
    	cout << "Yes" << endl;
    }
  	else{
    	cout << "No" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    string[] val = Console.ReadLine().Split();
    int a = int.Parse(val[1]);
    int b = int.Parse(val[2]);

    if ((b - a) % 2 == 0) {
      Console.WriteLine("Alice");
    }
    else {
      Console.WriteLine("Borys");
    }
  }
}


Measured memory_bytes: 13140
# エクサウィーズ2019C

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))


n,q = map(int, input().split())
S = input()
ts = [None] * q
ds = [None] * q
for i in range(q):
    ts[i], ds[i] = input().split()

d2v = {"L": -1, "R": 1}
def sub(i, left=True):
    # i番目が左(右)に落ちるかどうか
    for t,d in zip(ts, ds):
        c = S[i]
        if c==t:
            i += d2v[d]
        if (left and i<0) or (not left and i>=n):
            return True
        if (left and i>=n) or (not left and i<0):
            return False
        
    return False

s = 0
t = n-1
if not sub(s):
    lnum = 0
elif sub(t):
    lnum = n
else:
    while True:
        if abs(s-t)<=1:
            lnum = s+1
            break
        m = (s+t)//2
        if sub(m):
            s = m
        else:
            t = m

s = 0
t = n-1
if sub(s, False):
    rnum = n
elif not sub(t, False):
    rnum = 0
else:
    while True:
        if abs(s-t)<=1:
            rnum = n-t
            break
        m = (s+t)//2
        if sub(m, False):
            t = m
        else:
            s = m
print(n-(lnum+rnum))

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

int main(){

    int N; cin >> N;
    int A[N];
    int x[N][N]; bool y[N][N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
        for(int j = 0; j < A[i]; j++){cin >> x[i][j] >> y[i][j]; x[i][j] -= 1;} 
    }

    bool checker;
    int tmp;
    int ans = 0;

    for(int flag = 0; flag < (1 << N); flag++){ //1:honest 0:unkind

        checker = 1;
        tmp = 0;

        for(int i = 0; i < N; i++){
            if(flag & (1 << i)){
                tmp++;
                for(int j = 0; j < A[i]; j++){
                    if(y[i][j]^(1 & (flag >> x[i][j]))){checker = 0;}
                }
            }
        }

        //cout << "flag = " << flag << ", tmp = " << tmp << ", checker = " << checker << endl;

        if(checker && ans < tmp){ans = tmp;}
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
from collections import Counter
from itertools import starmap
from operator import mul

R = lambda: map(int, input().split())
n, m = R()
a = list(Counter(R()).items())
heapq.heapify(a)
for _ in range(m):
    b, c = R()
    i = b
    while i:
        x, y = a[0]
        if x >= c:
            break
        d = min(i, y)
        i -= d
        y -= d
        if y:
            heapq.heapreplace(a, (x, y))
        else:
            heapq.heappop(a)
    heapq.heappush(a, (c, b - i))
print(sum(starmap(mul, a)))


Measured memory_bytes: 24168
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int count = 0;
        for(int i = n[0]; i <= n[1]; i++){
            if(n[2] % i == 0){
                    count++;
            }
        }
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 18428
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int k, s, cnt, a;

int main()
{
    speed;
    /// Author: Dilshod--Imomov
    #ifdef DEBUGd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG
    cin >> k >> s;
    for ( int i = 0; i <= k; i++ ) {
        for ( int j = 0; j <= k; j++ ) {
            a = s - (i + j);
            if ( a < 0 || a > k ) continue;
            cnt++;
        }
    }
    cout << cnt;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){

  int a,b;cin>>a>>b;
  cout<<max(a+b,max(a-b,a*b))<<endl;

 

  return 0;
}

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

template <typename T>
class SparseTable {
	const int n, h;
	vector<vector<T>> t;
public:
	SparseTable(const vector<T>& b)
		: n(b.size()), h(31 - __builtin_clz(n)), t(h + 1, vector<T>(b.size())) {
		t[0] = b;
		for (int i = 0; i < h; i++)
			for (int k = 0; k + (1 << i) < n; k++)
				t[i + 1][k] = min(t[i][k], t[i][k + (1 << i)]);
	}
	T find(int l, int r) {
		int b = 31 - __builtin_clz(r - l);
		return min(t[b][l], t[b][r - (1 << b)]);
	}
	T operator[](int id) {
		return t[0][id];
	}
};

class LCA {
	using pii = pair<int, int>;
	vector<int> depth, id;
	SparseTable<pii> st;
	void dfs(int v, int prev, const graph& G, vector<pii>& res) {
		depth[v] = prev != -1 ? depth[prev] + 1 : 0;
		id[v] = res.size();
		res.emplace_back(depth[v], v);
		for (auto to : G[v]) if (to != prev) {
			dfs(to, v, G, res);
			res.emplace_back(depth[v], v);
		}
	}
	vector<pii> init(const graph& G, int rt) {
		vector<pii> res;
		res.reserve(G.size() * 2 - 1);
		dfs(rt, -1, G, res);
		return res;
	}
public:
	LCA(const graph& G, int rt = 0) : depth(G.size()), id(G.size()), st(init(G, rt)) {}
	int calc(int a, int b) {
		if (id[a] > id[b]) swap(a, b);
		return st.find(id[a], id[b] + 1).second;
	}
	int dist(int a, int b) {
		return depth[a] + depth[b] - depth[calc(a, b)] * 2;
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	graph G(n);
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int c;
			cin >> c;
			G[i].push_back(c);
			G[c].push_back(i);
		}
	}
	LCA lca(G);
	int q;
	cin >> q;
	while (q--) {
		int u, v;
		cin >> u >> v;
		printf("%d\n", lca.calc(u, v));
	}
	return 0;
}



Measured memory_bytes: 43292
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>  
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a,b;
	cin >> a >> b;
	if ((a * b) % 2 == 0) {
		cout << "Even" << endl;
	}
	else cout << "Odd" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0;i<N;i++) {
        cin >> A[i];
    }
    int64_t ans=0;
    
    for (int i=0;i<N-1;i++) {
        if(A[i]>A[i+1]) {
            ans+=A[i]-A[i+1];
            A[i+1]=A[i];
        }
    }
   cout << ans << endl;
} 


Measured memory_bytes: 4756
import sys
input = sys.stdin.readline

class FenwickTree:
    def __init__(self, size):
        self.bit = [0] * (size + 1)
        self.size = size

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.bit[i]
            s %= mod
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.bit[i] += x
            self.bit[i] %= mod
            i += i & -i

mod = 998244353
N, K = map(int, input().split())
L, R = zip(*[list(map(int, input().split())) for _ in range(K)])
dp = FenwickTree(N + 1)
dp.add(1, 1)
dp.add(2, -1)
for i in range(1, N):
    x = dp.sum(i)
    for j in range(K):
        dp.add(i + L[j], x)
        if i + R[j] + 1 <= N:
            dp.add(i + R[j] + 1, -x)
print(dp.sum(N))

Measured memory_bytes: 70096
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
main(){
    #define task "TASK"
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;

    string s; cin>>s;
    forv(i,s) cout<<"x";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readL(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readL(String str) {
		String[] strArr = str.split("\\s+");
		HashMap<Integer, Integer> hist = new HashMap<Integer, Integer>();
		for (int i = 0; i < N; i++) {
			int l = Integer.parseInt(strArr[i]);
			if (hist.containsKey(l))
				hist.put(l, hist.get(l) + 1);
			else
				hist.put(l, 1);
		}

		// for (int l : hist.keySet())
		// System.out.println(l + " " + hist.get(l));
		int[] side = new int[hist.size()];
		int idx = 0;
		for (int l : hist.keySet()) {
			side[idx] = l;
			idx++;
		}
		Arrays.sort(side);
		long ans = 0;
		// 三辺の長さが異なる三角形
		for (int a = 0; a < hist.size() - 2; a++) {
			for (int b = a + 1; b < hist.size() - 1; b++) {
				for (int c = b + 1; c < hist.size(); c++) {
					if (side[a] + side[b] <= side[c])
						break;
					ans += ((long) hist.get(side[a]) * (long) hist.get(side[b]) * (long) hist.get(side[c]));
				}
			}
		}

		// 正三角形を除く二等辺三角形
		for (int a = 0; a < hist.size() - 1; a++) {
			for (int b = a + 1; b < hist.size(); b++) {
				ans += (long) hist.get(side[a]) * (long) hist.get(side[b]) * ((long) hist.get(side[b]) - 1) / 2;
				if (side[a] + side[a] > side[b])
					ans += (long) hist.get(side[b]) * (long) hist.get(side[a]) * ((long) hist.get(side[a]) - 1) / 2;
			}
		}

		// 正三角形
		for (int a = 0; a < hist.size(); a++)
			ans += (long) hist.get(side[a]) * ((long) hist.get(side[a]) - 1) * ((long) hist.get(side[a]) - 2) / 6;

		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 342616
#include <iostream>
#include <vector>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	ull mod = 1000000007;
	
	uint N;
	cin >> N;
	
	vector<uint> A(N);
	for(uint i=0; i<N; i++) {
		cin >> A[i];
		if(i < A[i]) {
			cout << 0;
			return 0;
		}
	}
	
	vector<vector<uint>> dp(N+1, vector<uint>(3));
	ull ans = 1;
	
	for(uint i=1; i<=N; i++) {
		uint k = 0;
		bool found = false;
		
		for(uint c=0; c<3; c++) {
			if(dp[i-1][c] == A[i-1]) {
				dp[i][c] = (found) ? dp[i-1][c] : dp[i-1][c] + 1;
				found = true;
				k++;
			} else {
				dp[i][c] = dp[i-1][c];
			}
				
			//cout << dp[i][c] << " ";
		}
		//cout << endl;
		ans = (ans * k) % mod;
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 6144
h, w = map(lambda x: int(x)+2, input().split())
MOD = 10**9+7
MAZE = ['#'*w]
for _ in range(h-2):
    MAZE.append('#'+input()+'#')
else:
    MAZE.append('#'*w)

route = [[0]*w for _ in range(h)]
for j in range(1, w):
    if MAZE[1][j] == '.':
        route[1][j] = 1
        continue
    break
for i in range(1, h):
    if MAZE[i][1] == '.':
        route[i][1] = 1
        continue
    break

for i in range(1, h-1):
    for j in range(1, w-1):
        x = i+1
        y = j+1
        if MAZE[x][y] == '#':
            continue
        route[x][y] = route[x-1][y]+route[x][y-1]
        
print(route[-2][-2] % MOD)


Measured memory_bytes: 157556
import sys
input = sys.stdin.readline

N, P = map(int, input().split())
S = list(map(int, list(input().rstrip())))
ans = 0
if P == 2 or P == 5:
    for i in range(N):
        if S[i] % P == 0:
            ans += i + 1
else:
    U = [0] * (N+1)
    count = [0] * P
    count[0] = 1
    factor = 10
    for i in range(N)[::-1]:
        U[i] = (S[i] * factor + U[i+1]) % P
        factor = factor * 10 % P
        ans += count[U[i]]
        count[U[i]] += 1
print(ans)


Measured memory_bytes: 61680
s=input()
q=int(input())
quary=[]
for i in range(q):
    temp=list(input().split())
    quary.append(temp)
switch=False
first=''
last=''
for i in range(q):
    if quary[i][0]=='1':
        if switch:
            switch=False
        else:
            switch=True

    else:
        if quary[i][1]=='1':
            if switch:
                last+=quary[i][2]
            else:
                first+=quary[i][2]
        else:
            if switch:
                first+=quary[i][2]
            else:
                last+=quary[i][2]
s=first[::-1]+s+last
if switch:
    print(s[::-1])
else:
    print(s)

Measured memory_bytes: 30388
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(true){
        int H,W;
        cin>>H>>W;
        if(H==0 && W==0)return 0;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i%2==j%2)cout<<'#';
                else cout<<'.';
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;

const ll mod = 1000000007;
const int N = 2e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n, k;
int dp[N], en[N], be[N];
char s[N];
int ok(int x) {
	if(!x) return true;
	int ret;
	int pre = 1;
	dp[x] = 0;
	rep(i, 1, x + 1) if(be[i]) dp[x]++;
	if(!pre) dp[x]++;
	// if(x == 8) dd(x),de(dp[x]);
	ret = dp[x];
	rep(i, x + 1, n + 1) {
		dp[i] = dp[i-1];
		if(be[i]) dp[i]++;
		if(en[i-x]) dp[i]--;
		// if(x == 8) dd(i), de(dp[i]);
		ret = min(ret, dp[i]);
	}
	return ret;
}
void init() {
	mt(be, 0);
	mt(en, 0);
	rep(i, 1, n + 1) {
		if(s[i]=='0' && (i == n || s[i+1] == '1')) en[i] = 1;
		if(s[i]=='0') {
			if(i==1 || s[i-1] == '1') be[i] = 1;
		}
		// dd(i);dd(s[i]);dd(be[i]);de(en[i]);
	}
}
int main() {
	while(~scanf("%d%d%s", &n, &k, s + 1)) {
		// dd(n);dd(k);de(s+1);
		init();
		int l = 0, r = n;
		while(l + 1 < r) {
			int mid = l + r >> 1;
			// dd(l);de(r);de(mid);
			if(ok(mid) <= k) l = mid;
			else r = mid;
		}
		// dd(l);dd(ok(l));dd(r);de(ok(r));
		if(ok(r) <= k) printf("%d\n", r);
		else if(ok(l) <= k) printf("%d\n", l);
	}
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

int n;
vi in;

int main(){
  scanf("%d", &n);
  in.resize(n);
  for(int& e : in) scanf("%d", &e);

  sort(all(in));

  int a = in.back(), b = in[0];

  int m1 = (a + 1) / 2, m2 = m1;
  if(a % 2 == 0) ++m2;

  for(int i = 1;i + 1 < n;++i){
    int d1 = min(abs(m1 - b), abs(m2 - b));
    int d2 = min(abs(m1 - in[i]), abs(m2 - in[i]));
    if(d2 < d1) b = in[i];
  }

  printf("%d %d\n", a, b);

  return 0;
}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        long n = sc.nextLong();

        PriorityQueue<P> q = new PriorityQueue<>();
        ArrayList<Integer> primes = primes();
        for (int p : primes) {
            q.add(new P(p, p));
        }

        if (isPrime(n)) {
            out.println(1);
        } else {
            int cnt = 0;
            while (!q.isEmpty()) {
                P c = q.remove();
                if (n % c.c == 0) {
                    n /= c.c;
                    q.add(new P(c.p, c.c * c.p));
                    cnt++;
                }
            }
            for (int p : primes) {
                while (n % p == 0) n /= p;
            }
            if (isPrime(n)) cnt++;
            out.println(cnt);
        }

        out.flush();
    }

    boolean isPrime(long x) {
        if (x == 1) return false;
        for (long i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    int max = 3000000;
    ArrayList<Integer> primes() {
        boolean[] ps = new boolean[max + 1];
        ps[0] = ps[1] = true;

        for (int i = 2; i <= max; i++) {
            if (!ps[i]) {
                for (int j = 2 * i; j <= max; j += i) {
                    ps[j] = true;
                }
            }
        }

        ArrayList<Integer> ret = new ArrayList<>();
        for (int i = 0; i <= max; i++) {
            if (!ps[i]) {
                ret.add(i);
            }
        }
        return ret;
    }

    class P implements Comparable<P> {
        long p, c;
        P(long p, long c) {
            this.p = p;
            this.c = c;
        }

        @Override
        public int compareTo(P o) {
            return Long.compare(c, o.c);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

Measured memory_bytes: 63140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	sort(a.begin(), a.end());
	const int m = 1000000;
	vector<bool> sieve(m + 1);
	int answer = 0;
	for(int i = 0; i < n; ++i){
		const int x = a[i];
		if(!sieve[x]){
			if(i + 1 == n || a[i] != a[i + 1]){ ++answer; }
			for(int j = x; j <= m; j += x){ sieve[j] = true; }
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 4304
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b;
    cin >> a >> b;
    
    if (b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
    
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}

import Data.Array.Unboxed
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let [n,k] = map (read . BS.unpack) $ BS.words li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n k as
  print ans

type A = UArray Int Int

compute :: Int -> Int -> [Int] -> Int
compute n k as = (loop arid k ar0 :: A) ! 1
  where
    ar0 = listArray (1,n) as :: A
    addAr ar1 ar2 = listArray (1,n) [ (ar2 :: A) ! ((ar1 :: A) ! i) | i <- [1..n] ] :: A
    arid = listArray (1,n) $ replicate n 1 :: A
    loop ar 0 _ = ar :: A
    loop ar k arn
      | odd k = loop (addAr ar arn) (k `div` 2) (addAr arn arn)
      | True  = loop ar             (k `div` 2) (addAr arn arn)

Measured memory_bytes: 17948