akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
static vector<string> lamp;

int main()
{
  // 入力受け取り
  int H,W;
  cin >> H >> W;
  lamp.resize(H);
  for (int i = 0; i < H; i++) {
    cin >> lamp.at(i);
  }
  int light[H][W];
  memset(&light, 0, sizeof(light));
  
  // 左から確認
  int cur=0;
  for (int i = 0; i < H; i++) {
    cur=0;
    for (int j = 0; j< W; j++) {
      if (lamp[i][j] == '#') cur = 0;
      else cur++;
      light[i][j]+=cur;
    }
  }
  
  // 右から確認
  cur=0;
  for (int i = 0; i < H; i++) {
    cur=0;
    for (int j = W-1; j>=0; j--) {
      if (lamp[i][j] == '#') cur = 0;
      else cur++;
      light[i][j]+=cur;
    }
  }

  // 上から確認
  cur=0;
  for (int i = 0; i < W; i++) {
    cur=0;
    for (int j = 0; j< H; j++) {
      if (lamp[j][i] == '#') cur = 0;
      else cur++;
      light[j][i]+=cur;
    }
  } 
  
  // 下から確認
  cur=0;
  for (int i = 0; i < W; i++) {
    cur=0;
    for (int j = H-1; j>= 0; j--) {
      if (lamp[j][i] == '#') cur = 0;
      else cur++;
      light[j][i]+=cur;
    }
  } 
  
  // 取り出し
  int ans=0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j< W; j++) {
      ans=max(ans,light[i][j]);
    }
  } 
  
  // ans
  cout << ans-3 << endl;
  
  return 0;
}


Measured memory_bytes: 19968
function main(input) {
  const last = input.slice(-1);
  if(last === '3'){
    console.log('bon');
  }else if(['0', '1', '6', '8'].includes(last)){
    console.log('pon');
  }else{
    console.log('hon');
  }
}

main(require('fs').readFileSync('/dev/stdin','utf8').trim());

Measured memory_bytes: 30328
#include<bits/stdc++.h>
#define M 100005
using namespace std; 
int fa[M][20],dep[M],dis[M];
struct node{
	int to,c,v;
};
vector<node>edge[M];
struct Query{
	int id,c,d,flag;
};
int cc[M],cs[M];
vector<Query>query[M];
int ans[M];
void dfs(int x,int f,int d,int ds){
	fa[x][0]=f;dep[x]=d;dis[x]=ds;
	for(int i=0;i<edge[x].size();i++){
		int y=edge[x][i].to;
		if(y==f)continue;
		dfs(y,x,d+1,ds+edge[x][i].v);
	}
}
int Up(int x,int step){
	for(int i=0;i<20;i++)
		if(step&(1<<i))x=fa[x][i];
	return x;
}
int LCA(int a,int b){
	if(dep[a]>dep[b])swap(a,b);
	b=Up(b,dep[b]-dep[a]);
	if(a==b)return a;
	for(int i=19;i>=0;i--)
		if(fa[a][i]!=fa[b][i])
			a=fa[a][i],b=fa[b][i];
	return fa[a][0];
}
void DFS(int x,int f){
	for(int i=0;i<query[x].size();i++){
		int c=query[x][i].c;
		int d=query[x][i].d;
		ans[query[x][i].id]+=query[x][i].flag*(dis[x]-cs[c]+cc[c]*d);
	}
	for(int i=0;i<edge[x].size();i++){
		int y=edge[x][i].to;
		if(y==f)continue;
		cc[edge[x][i].c]++;
		cs[edge[x][i].c]+=edge[x][i].v;
		DFS(y,x);
		cc[edge[x][i].c]--;
		cs[edge[x][i].c]-=edge[x][i].v; 
	}
}
int main(){
	int n,Q,a,b,c,d;
	cin>>n>>Q;
	for(int i=1;i<n;i++){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		edge[a].push_back((node){b,c,d});
		edge[b].push_back((node){a,c,d}); 
	}
	dfs(1,0,0,0);
	for(int j=1;j<20;j++)
		for(int i=1;i<=n;i++)fa[i][j]=fa[fa[i][j-1]][j-1];
	for(int i=1;i<=Q;i++){
		scanf("%d %d %d %d",&c,&d,&a,&b);
		query[a].push_back((Query){i,c,d,1});
		query[b].push_back((Query){i,c,d,1});
		query[LCA(a,b)].push_back((Query){i,c,d,-2}); 
//		printf("a=%d b=%d c=%d\n",a,b,LCA(a,b));
	}
	DFS(1,0); 
	for(int i=1;i<=Q;i++)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 31348
N = int(input())
v = list(map(int, input().split()))

v.sort()

molec = 0
power = 0
for i in range(N):
    if i >= 2:
        power += 1
    molec += (v[i] << power)

denom = 1 << (1 + power)

print(molec / denom)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
	long long int N, Total = 0;
	scanf ("%lld", &N);
	for (int i = 1; i <= N; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			continue;
		} else {
			Total += i;
		}
	}
	printf("%lld\n", Total);
	return 0;
}

Measured memory_bytes: 1708
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])

"""
DPを考える
"""

result = [0] * (N+1)
result[0] = 1
if 1 not in A:
    result[1] = 1
mod = 10**9 + 7
for i in range(2,N+1):
    if i not in A:
        result[i] = (result[i-1] + result[i-2])

print(result[N]%mod)

Measured memory_bytes: 460020
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    int a,b,c,ans;
    cin >> a >> b >> c;
    ans = c-a+b;
    if(ans>0) cout << ans << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
b = input().split()

if int(b[0]) % 3 == 0:
  print("Possible")
elif int(b[1]) % 3 == 0:
  print("Possible")
elif (int(b[0]) + int(b[1])) % 3 == 0:
  print("Possible")
else:
  print("Impossible")


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	int n;
	cin >> n;
	vi d(n);
	rept(i, n)cin >> d[i];

	ll sum = 0;
	rept(i, n-1) {
		rep(j, i + 1, n) {
			sum += d[i] * d[j];
		}
	}
	
	cout << sum << endl;

	system("pause");
	return 0;
}


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

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

	int d, n;
	cin >> d >> n;

	if (d==2&&n==100) cout << "1010000" << "\n";
	else if (n==100) cout << pow(100,d)*101 << "\n";
	else cout << pow(100,d)*n << "\n";

	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] a = ReadLine().Split(' ');
        string[] b = ReadLine().Split(' ');
        if(b[1] == "1"){
            WriteLine(1);
        }else{
            WriteLine(0);
        }
    }
}


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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

long double EPS = 1e-9;

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

	ll x, k, d; cin >> x >> k >> d;

	if(x < 0) x *= -1LL;

	ll mini = x%d;
	ll moves = (x-mini)/d;

	if(k <= moves) cout << x - k * d << '\n';
	else if((k-moves)%2 == 0){
		cout << mini << '\n';
	}else{
		cout << min(abs(mini-d), mini+d) << '\n';
	}

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main(){
	int h,m,s,S,a;
	cin>>S;
	h=S/3600;
	a=S%3600;
	m=a/60;
	s=a%60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,f,g;cin>>n>>f>>g;
    vector<int> v[n+1];
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int df[n+1],dg[n+1];
    fill(df,df+n+1,1000000000);
    fill(dg,dg+n+1,1000000000);
    df[f]=0,dg[g]=0;
    queue<int> q;
    q.push(f);
    while(q.size()>0){
        int now=q.front();q.pop();
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(df[ne]<1000000000)continue;
            df[ne]=df[now]+1;
            q.push(ne);
        }
    }
    q.push(g);
    while(q.size()>0){
        int now=q.front();q.pop();
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(dg[ne]<1000000000)continue;
            dg[ne]=dg[now]+1;
            q.push(ne);
        }
    }
    int ans=0;
    rep(i,1,n+1){
        if(v[i].size()==1){
            if(df[i]<dg[i]){
                ans=max(ans,dg[i]-1);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6656
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int x, a, b;
	cin>>x>>a>>b;
	cout<<(x-a)%b<<endl;
	return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
s=[]
g=[['#']*100 for i in range(100)]
for i in range(1,100,4):
  for j in range(1,100,4):
    s.append((i,j))
if a>=b:
  for i in range(a):
    y,x=s[i]
    for dy in [-1,0,1]:
      for dx in [-1,0,1]:
        if dy==dx==0:
          continue
        g[y+dy][x+dx]='.'
  for i in range(a-b+1):
    y,x=s[i]
    g[y][x]='.'
else:
  for i in range(100):
    for j in range(100):
      g[i][j]='.'
  for i in range(b):
    y,x=s[i]
    for dy in [-1,0,1]:
      for dx in [-1,0,1]:
        if dy==dx==0:
          continue
        g[y+dy][x+dx]='#'
  for i in range(b-a+1):
    y,x=s[i]
    g[y][x]='#'
print(100,100)
for i in range(100):
  print(''.join(g[i]))

Measured memory_bytes: 3188
n, p = map(int, input().split())
s = input()[::-1]
if p == 2:
  ans = 0
  for num, i in enumerate(s):
    if int(i)%2 == 0:
      ans += n-num
elif p == 5:
  ans = 0
  for num, i in enumerate(s):
    if int(i)%5 == 0:
      ans += n-num
else:
  C = [0]*p
  now = 0
  for num, i in enumerate(s):
    a = int(i)
    now = (now+pow(10, num, p)*a)%p
    C[now] += 1
  ans = C[0]
  for c in C:
    ans += c*(c-1)//2
print(ans)

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

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;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
/*vector<int> d(N+1,-1);

//頂点xとの各点との最短距離を求める
void bfs(int x,Graph &G){
  d[x] = 0;
  queue<<int> que;
  que.push(x);

  // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }
}*/

int main(){
  int X,Y,Z;
  cin >> X >> Y >> Z;
  cout << Z << " " << X << " " << Y << endl;
 }


Measured memory_bytes: 256
s = input()
n = len(s)
s2 = s[:int((n-1)/2)]
n2 = len(s2)
#print(s2)

a = ""
b = ""

if len(s2) %2 == 1:
  a = s2[:int((n2-1)/2)]
  b = s2[int(int((n2-1)/2) + 1):]
else:
  a = s2[:int((n2)/2)]
  b = s2[int(int((n2)/2)):]
#print(a)
#print(b)


# 回文の判定
if s[:int((n-1)/2)] == s[int(int((n-1)/2) + 1):] and s[:int((n-1)/2)] == s[int(int((n-1)/2) + 1):][::-1] and a[::-1] == b and s == s[::-1]:
  print ("Yes")
else:
  print("No")

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

int main() {
  string a;
  cin >> a;
  int b = a.size();
  int count = 0;
  for(int i = 0;i<b/2;i++){
    if(a.at(i)!=a.at(a.size()-i-1))count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3600
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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 main(){
  string S,T;
  cin >> S >> T;
  if(S.size() < T.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  reverse(S.begin(),S.end());
  reverse(T.begin(),T.end());
  bool c = false;
  for(int i=0; i<=S.size()-T.size(); i++){
    bool can = true;
    for(int j=i; j<i+T.size(); j++){
      if(S[j]==T[j-i] || S[j]=='?') continue;
      can = false;
    }
    if(can){
      c = true;
      for(int j=i; j<i+T.size(); j++){
        S[j] = T[j-i];
      }
      break;
    }
  }
  for(int i=0; i<S.size(); i++){
    if(S[i] == '?'){
      S[i] = 'a';
    }
  }
  if(c){
    reverse(S.begin(),S.end());
    cout << S << endl;
  }else{
    cout << "UNRESTORABLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
l = [len(c) for c in input().split("T")]
x, y = map(int, input().split())
bx = 1 << l.pop(0) + 8000
by = 1 << 8000
for i, d in enumerate(l):
	if i % 2:
		bx = (bx << d) | (bx >> d)
	else:
		by = (by << d) | (by >> d)
print("Yes" if bx & (1 << x + 8000) and by & (1 << y + 8000) else "No")

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    std::ios::sync_with_stdio(false);
    
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    long long dif = abs(a-b);
    bool ok = true;
    n--;
    if(n*d<dif){
        ok = false;
    }
    if(ok){
        ok = false;
        
        for(long i = 0; i<=n; i++){
            long up = (long long)i;
            long down = n-up;
            long long mini = 0LL;
            long long maxi = 0LL;
            maxi += d*up;
            maxi -= c*down;
            mini += c*up;
            mini -= d*down;
            if(dif>=mini && dif<=maxi){
                ok = true;
                break;
            }
        }
    }
    if(ok){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions

n, x = map(int, input().split())

l = list(map(int, input().split()))
l.append(x)
l = sorted(l)
ld = list()
for i in range(n):
    ld.append(l[i+1]-l[i])

a = ld[0]
for i in range(1, n):
    a = fractions.gcd(a, ld[i])

print(a)

Measured memory_bytes: 16300
/*
*/

//#pragma comment(linker, "/STACK:16777216")
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd

#define eps 1e-9
#define M_PI 3.141592653589793
#define bs 1234567891
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 200000;

const int TTL = 1;

int n;
long long L, ar[N];
int found;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

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

	for (int i = 1; i < n; i++)
	{
		if (ar[i] + ar[i + 1] >= L)
		{
			found = i;
		}
	}

	if (!found)
	{
		cout << "Impossible" << endl;
	}
	else
	{
		cout << "Possible" << endl;
		for (int i = 1; i < found; i++)
		{
			cout << i << endl;
		}
		for (int i = n-1; i>=found +1; i--)
		{
			cout << i << endl;
		}
		cout << found << endl;
	}
	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

bool solve(){
  int n,m,k;
  cin>>n>>m>>k;

  rep(i,n+1)rep(j,m+1){
    if((n-i)*(m-j)+i*j == k) return true;
  }
  return false;

}

int main(){
  if(solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(vector<vector<T>> x){cerr<<"\n{"; int f=x.size();for(int i=0;i<f;i++){cerr<<"("; int g=x[i].size(); for(auto j:x[i]){cerr<<j; (--g!=0)?cerr<<",":cerr<<"";}cerr<<")\n";}cerr<<"}";}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void __print(vector<bool> x){cerr<<"{";int f=x.size();for(auto i:x){cerr<<i;(--f !=0)?cerr<<",":cerr<<"";}cerr<<"}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define trace(x...)
#endif
 
template<typename... T>
void read(T&... args) {
    ((cin >> args), ...);
}
 
template<typename... T>
void writ(T&&... args) {
    ((cout << args << " "), ...);
}
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define INF (ll)1e18
#define IINF (int)1e9
#define EPS 1e-9

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin>>n;
    vector<ull> arr(n),suf(n);
    for(auto &i: arr) cin>>i;
    //First calc the suffix sum
    suf=arr;
    for(int i=n-2;i>=0;i--){
        suf[i]=(suf[i]+suf[i+1])%MOD;
    }
    //trace(suf);
    ull x=0;
    for(int i=n-2;i>=0;i--){
        ll temp = (arr[i]*suf[i+1])%MOD;
        x = (x + temp)% MOD;
    }
    cout<<x%MOD;
    return 0;
}



Measured memory_bytes: 6360
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private int A, B;


    private void Scan()
    {
        var line = Console.ReadLine().Split(' ');
        A = int.Parse(line[0]);
        B = int.Parse(line[1]);
    }



    public void Solve()
    {
        Scan();
        var a = A % 3 == 0;
        var b = B % 3 == 0;
        var c = (A + B) % 3 == 0;
        if (a || b || c)
        {
            Console.WriteLine("Possible");
        }
        else
        {
            Console.WriteLine("Impossible");
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ld, ll, ll>> vtll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  map<ll ,ll> ans;
  vll a(n); rep(i , n) {cin >> a[i]; if(a[i] % 4 == 0) ans[4]++; else if(a[i] % 2 == 0) ans[2]++; else ans[0]++;}
  if(ans[0] <= ans[4] || ans[0] - 1 <= ans[4] &&ans[2] == 0) fin("Yes");
  fin("No"); 
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <set>
    #define N 100010
    #define INF (1LL << 60)
    #define LL long long
    using namespace std;
    int n, e, t, x[N];
    LL dp[N], preMin[N];
    multiset<LL> st;
     
    int main() {
    	scanf("%d%d%d", &n, &e, &t);
    	for (int i = 1; i <= n; ++i) {
    		scanf("%d", &x[i]);
    	}
    	
    	dp[0] = 0;
    	x[0] = 0;
    	int last = 0;
    	preMin[0] = - 2 * x[1];
    	st.insert(t);
    	for (int i = 1; i <= n; ++i) {
    		while (last + 1 <= i && 2LL * (x[i] - x[last + 1]) >= t) {
    			st.erase(st.find(dp[last] - x[last] + t));
    			++last;
    		}
			dp[i] = (((LL)1)<<50);
			if(last - 1 >= 0) dp[i] = min(dp[i], preMin[last - 1] + 3LL * x[i]);
			if(!st.empty()) dp[i] = min(dp[i], *st.begin() + x[i]);
    		//if (last - 1 >= 0) dp[i] = min(preMin[last - 1] + 3LL * x[i], *st.begin() + x[i]);
    		//else dp[i] = *st.begin() + x[i];
    //cout << last << ' ' << preMin[last - 1] << ' ' << *st.begin() << ' ' << dp[i] << endl;
    		if (i < n) st.insert(dp[i] - x[i] + t);
    		preMin[i] = min(dp[i] - x[i] - 2LL * x[i + 1], preMin[i - 1]);
    //cout << dp[i] << ' ';
    	}
    //cout << endl;
    	
    	printf("%lld\n", dp[n] + e - x[n]);
    	return 0;
    }

Measured memory_bytes: 4224
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a = int(input())
    b = int(input())

    if a > b :
        print("GREATER")
    elif a  < b :
        print("LESS")
    elif a  == b :
        print("EQUAL")

if __name__=="__main__":
    main()

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


void dfs(unordered_map<int,int>* edges , unordered_map<int,int>& visited , int start , int* vertex , int color){
	if(visited.count(start)) return ;
	visited[start] = 1 ;
	vertex[start] = color ;
	for(auto i : edges[start]){
		if(i.second&1){
			dfs(edges,visited,i.first,vertex,!color) ; //odd
		}else{
			dfs(edges,visited,i.first,vertex,color) ; //even
		}
	}
}

int main() {
	int n ;
	cin >> n ;
	unordered_map<int,int> edges[n] ;
	int vertex[n] = {0} ;
	for(int i = 0 ; i < n-1 ; i++){
		int f ,s , w ;
		cin >> f >> s >> w ;
		f--,s-- ;
		edges[f][s] = w ;
		edges[s][f] = w ;
	}
	unordered_map<int,int> visited ;
	dfs(edges , visited, 0 , vertex , 0) ;
	
	for(int i = 0 ; i < n ; i++){
		cout << vertex[i] << '\n' ;
	}
	return 0;
}

Measured memory_bytes: 23076
v[5];a[]={0,10,50,100,500,v};c,b;main(z){for(;c>4?b>3?c=0,b=-1:++b?z=v[b]+*v%a[b+1]/a[b],z<1||printf("%d %d\n",a[b],z):puts(""):~scanf("%d",v+c)?*v-=v[c]*a[c],++c:0;);}

Measured memory_bytes: 0
n=int(input())
a=list(map(int,input().split()))
ood_cnt=0
even_cnt=0
for i in range(n):
    if a[i]%2==0:
        even_cnt+=1
    else:
        ood_cnt+=1
if ood_cnt%2==0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 14108
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,k = li()

# すべてmod k == 0
mod0 = 0
modk2 = 0
for i in range(1,n+1):
    if i%k == 0:
        mod0 += 1
        
    if i%k == (k/2):
        modk2 += 1
        
ans = (modk2**3 + mod0**3)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#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 ll long long
#define pb(a) push_back(a)

int main(){
  int a[3];
  REP(i, 3) cin >> a[i];
  SORT(a, 3);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
const int MOD = 1e9+7;
int n,k;
int f[MAXN],arr[MAXN];
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++){
		scanf("%d",&arr[i]);
	}
	int loc = 1;
	f[0]=1;
	for(int i=1;i<=n;i++){
		while(arr[loc]<i && loc+1<=n)loc++;
		if(arr[loc]==i)continue;
		if(i==1){
			f[i]=f[i-1];
		}else
			f[i]=(f[i-1]+f[i-2])%MOD;
	}
	cout<<f[n];
	return 0;
}



Measured memory_bytes: 896
//05, 03, 2019, 11:12:14 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const double EPS = 1E-9;
const ll mod = 998244353LL;
const int N = 500;
int gauss (vector < bitset<N> > a, int n, int m) {
    vector<int> where (m, -1);
    for (int col=0, row=0; col<m && row<n; ++col) {
        for (int i=row; i<n; ++i)
            if (a[i][col]) {
                swap (a[i], a[row]);
                break;
            }
        if (! a[row][col])
            continue;
        where[col] = row;

        for (int i=0; i<n; ++i)
            if (i != row && a[i][col])
                a[i] ^= a[row];
        ++row;
    }

    int rank = n;

    for(int i = 0 ; i < n ; i++){
        bool has_one = false;

        for(int j = 0 ; j < m ; j++){
            if(a[i][j]){
                has_one = true;
                break;
            }
        }

        if(!has_one){
            rank--;
        }
    }

    return rank;    
}

vector< bitset< N > > a;

ll fast_pow(ll base, int n){
    ll carry = base;
    ll res = 1LL;

    while(n){
        if(n & 1){
            res = (res * carry) % mod;
        }

        n /= 2;
        carry = (carry * carry) % mod;
    }
    
    return res;
}

ll MOD(ll x){
    return ((x % mod) + mod) % mod;
}

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

    int n, m;

    // cout << mod * mod << endl;
    cin >> n >> m;

    a.resize(n);

    for(int i = 0 ; i < n ; i++){
        for(int j = 0 ; j < m ; j++){
            int x;
            cin >> x;
            a[i][j] = x; 
        }
    }

    int rank = gauss(a, n, m);
    // cout << "rank = " << rank << endl;
    // cout << "voltei!" << endl;
    ll nn = fast_pow(2LL, n + m - 1);
    ll nr = fast_pow(2LL, n + m - rank - 1);   
    ll mm = fast_pow(2LL, m - 1);

    cout << MOD(nn - nr) << endl; 

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    A.push_back(A[N - 1]);
    vector<ll> sum(N);
    sum[0] = A[0];
    for (int i = 1; i < N; i++) sum[i] = sum[i - 1] + A[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        //cout << sum[i] * 2 << " " << A[i + 1] << endl;
        if (sum[i] * 2 < A[i + 1]) ans = 0;
        else ans++;
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void) {

  long n,k;
  scanf("%ld %ld", &n, &k);
  long number[n];
  int head[n];
  for (long i = 0; i < n; i++) {
    number[i] = i+1;
    head[i] = 0;
    while (number[i] < k) {
      number[i] *= 2;
      head[i]++;
    }
  }
  double answer = 0;
  for (long i = 0; i < n; i++) {
    answer += pow(0.5,head[i]);
  }
  answer /= n;
  printf("%.12f\n", answer);

  return 0;
}

Measured memory_bytes: 1280
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
int main() {
	string s;
	cin >> s;
	vector<ll> a(26);
	for (auto p : s) a[p - 'a']++;
	ll ans = s.size() * (s.size() + 1) / 2;
	rep(i, 26) ans -= a[i] * (a[i] + 1) / 2;
	printf("%lld\n", ans + 1);
	return 0;
}

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

using namespace std;

int main() {
  int N, H;
  cin >> N >> H;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    cin >> B[i];
  }

  int maxA = *max_element(A.begin(), A.end());
  vector<int> largerB;
  for (int i = 0; i < N; i++) {
    if (B[i] > maxA) {
      largerB.push_back(B[i]);
    }
  }
  sort(largerB.rbegin(), largerB.rend());

  int totalDamage = 0;
  int countAttack = 0;
  for (int i = 0; i < largerB.size(); i++) {
    totalDamage += largerB[i];
    countAttack++;
    if (totalDamage >= H) {
      break;
    }
  }

  if (totalDamage < H) {
    int restDamage = H - totalDamage;
    countAttack += (restDamage + maxA - 1) / maxA;
  }

  printf("%d\n", countAttack);

  return 0;
}


Measured memory_bytes: 1660
import java.util.Arrays;
import java.util.Scanner;


	public class Main {
		

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
	        
			int n = sc.nextInt();
			int c = sc.nextInt();
			int k = sc.nextInt();
	        int[] t = new int[n];
			
	        for(int i=0;i<n;i++) {
	        	t[i] = sc.nextInt();
	        }
	        
	        Arrays.sort(t);
	        int ret = 0;
	        
	        
	        for(int i=0;i<n;) {
	        	int i2 = i;
	        	for(int j=1;j<c;j++) {
	        		if(i+j>n-1) {
	        			break;
	        		}
	        		if(t[i]+k<t[i+j]) {
	        			break;
	        		}
	        		i2++;
	        	}
	        	if(i==i2) {
	        		i++;
	        	}else {
	        		i=i2+1;
	        	}
	        	
	        	ret++;
	        }
	        
	        System.out.println(ret);
		}
		
	}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll N, A, B, K;
ll mod = 998244353;

const int FACT_MAX = 1001010;
long long fact[FACT_MAX];  // 階乗
long long revFact[FACT_MAX];  // 階乗の逆元

long long powMod(long long x, long long y) {
  long long r = 1, a = x % mod;
  while (y) {
    if (y & 1) r = (r * a) % mod;
    a = (a * a) % mod;
    y /= 2;
  }
  return r;
}

void setFact() {
  const int N = FACT_MAX;
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = fact[i - 1] * i;
    fact[i] %= mod;
  }
  revFact[N - 1] = powMod(fact[N - 1], mod - 2);
  for (int i = N - 2; i >= 0; i--) {
    revFact[i] = revFact[i + 1] * (i + 1);
    revFact[i] %= mod;
  }
}

long long getC(int a, int b) {
  if (a < b) return 0;
  return (((fact[a] * revFact[b]) % mod) * revFact[a - b]) % mod;
}

int main() {
    cin >> N >> A >> B >> K;
    ll ans = 0;
    setFact();
    for (ll i=0; i<=N; ++i) {
        ll b = (K - A*i);
        if (b < 0 or b%B != 0) continue;
        b /= B;
        if (b > N) continue;
        ll tmp = 1;
        tmp *= getC(N, i)%mod;
        tmp *= getC(N, b)%mod;
        ans += tmp;
        ans %= mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 15872
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int maxn = 1000* 100 + 5;
int a[maxn];
map <int, int> cn;

int32_t main(){
    int n;
    cin >>n;
    for(int i = 0; i < n; i ++){
        cin >>a[i];
    }
    sort(a, a + n);
    int aa = -1;
    for(int i = n - 1; i >= 0; i --){
        cn[a[i]] ++;
        if(cn[a[i]] == 2){
            if(aa == -1){
                cn[a[i]] = 0;
                aa = a[i];
            }
            else{
                cout <<aa* a[i] <<endl;
                return false;
            }
        }
    }
    cout <<0 <<endl;
    return false;
}


Measured memory_bytes: 6272
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, cos, radians, pi, sin
from operator import mul
from functools import reduce
from operator import mul
from decimal import Decimal

mod = 10 ** 9 + 7
INF = 10 ** 13
sys.setrecursionlimit(2147483647)
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


n = I()
A = []
B = []
for _ in range(n):
    a, b = LI()
    A += [a]
    B += [b]

A.sort()
B.sort()
if n % 2:
    print(B[n // 2] - A[n // 2] + 1)
else:
    print((B[n // 2] + B[n // 2 - 1]) - (A[n // 2] + A[n // 2 - 1]) + 1)

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

int main(void){
    int n, x;
    cin >> n >> x;
    int tmp;
    int d = 0;
    int cnt = 1;
    while(cin >> tmp)
    {
        d += tmp;
        if (d > x) break;
        cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}


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

using namespace std;

int main() {
    int A, B, K; cin >> A >> B >> K;
    for (int i = min(A, B), cnt = 0; 1 <= i; --i) {
        if (A % i == 0 && B % i == 0) {
            ++cnt;
            if (cnt == K) {
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100001][2], ans, M = 1e9+7;
vector<vector<int>> adj(1e5+1);
int dfs(int src, int par, int col){
    if (dp[src][col]!=-1)
        return dp[src][col];
    if (adj[src].size()==1 && par!=-1)
        return col+1;
    int cur = 1, ano = col;
    for (auto &i: adj[src])
        if (i!=par){
            cur =(1ll*cur*dfs(i, src, 1-col))%M;
            if(col)
                ano = (1ll*ano*dfs(i, src, col))%M;
        }
    return dp[src][col] = (cur+ano)%M;
}
int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    memset(dp, -1, sizeof(dp));
    int n, src, dest;
    cin >> n ;
    if(n==1){
        cout << "2\n";
        exit(0) ;
    }
    while (--n){
        cin >> src >> dest;
        adj[src].emplace_back(dest), adj[dest].emplace_back(src);
    }
    cout << dfs(1, -1, 1) << "\n";
}

Measured memory_bytes: 16268
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for h in range(H):
        for w in range(W):
            if (h+w)%2 == 0:
                print('#', end='')
            else:
                print('.', end='')
        print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n,m;
  cin>>n>>m;
 vector<int>h(n,0);
 vector<bool>ok(n,true);
   rep(i,n) cin>>h.at(i);
   rep(i,m){
  	int a,b;
    cin>>a>>b;
  	a--; b--;
     if (h.at(a) <= h.at(b)) ok.at(a) = false;
    if (h.at(b) <= h.at(a)) ok.at(b) = false;
  }
  int ans=0;
  rep(i,n){
  	if(ok.at(i)) ans++;
  }
  cout<<ans<<endl;
}
// 片方を比べてどちらかがアウトになるので、そうなったやつは消す

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

//#define int long long

using namespace std;

int d[101][101];
char a[101][101];

void print (int x) {
	cout << x;
	exit (0);
}

int main () {
	int l, r;
	cin >> l >> r;
	int L = abs (l);
	int R = abs (r);
	if (abs (l) <= abs (r)) {
		if (l >= 0 && r >= 0) print (R - L);  
		if (l < 0 && r >= 0) print (R - L + 1);
		if (l < 0 && r < 0) print (R - L + 2);
		if (l >= 0 && r < 0) print (R - L + 1); 
	}
	if (abs (l) > abs (r)) {
		if (l > 0 && r > 0) print (L - R + 2);  
		if (l <= 0 && r > 0) print (L - R + 1);
		if (l <= 0 && r <= 0) print (L - R);
		if (l > 0 && r <= 0) print (L - R + 1); 
	}
    return 0;           		
}

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

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] inputNum = br.readLine().split(" ");
		int minNum = Integer.parseInt(inputNum[0]);
		int maxNum = Integer.parseInt(inputNum[0]);
		long total = 0;

		for (int i = 0; i < n; i++) {
			int num =  Integer.parseInt(inputNum[i]);
			if (num < minNum) {
				 minNum = num;
			}else if (maxNum < num) {
				maxNum = num;
			}
			total += num;
		}

		System.out.println(minNum + " " + maxNum + " " + total);
	}

}

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll a,b;
  	ci(a>>b);
  vpll A(b);
  FOR(i,0,b){
    ci(A[i].fi)
    ci(A[i].se)
  }
  
  SORT(A);
  
  ll nowl=0;
  ll nowr=a;
  
  FOR(i,0,b){
    nowl=M(nowl,A[i].fi);
    nowr=min(nowr,A[i].se);
  }
  if(nowl<=nowr){
    co(nowr-nowl+1)
  }
  else{
    co(0)
  }

}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int GCD(int a, int b) {
	if (!b) return a;
	else {
		return GCD(b, a % b);
	}
}

int main() {
	int N;
	cin >> N;

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		ans = GCD(ans, A);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3512
#include <iostream>
     
using namespace std;
     
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
  	bool triggered = false;
    for (int i = 1; i <= 9; i++) {
      if (n % i == 0 && n / i <= 9) {
        cout << "Yes";
        triggered = true;
        break;
      }
    }
  	if (!triggered) {
      cout << "No";
  	}
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
CS = [list(map(int,input().split())) for _ in range(M)]
ANS = ['N']*N
if N == 1 and M == 0:
    print(0)
    exit()  
for cs in CS:
    if ANS[cs[0]-1] == 'N':
        ANS[cs[0]-1] = str(cs[1])
        continue
    if ANS[cs[0]-1] != str(cs[1]):
        print(-1)
        exit()
for i in range(N):
    if i == 0 and ANS[i] == 'N':
        ANS[0] = '1'
        continue
    if ANS[i] == 'N':
        ANS[i] = '0'
if N == 1:
    print(ANS[0])
    exit()
if ANS[0] == '0':
    print(-1)
    exit()  
print(''.join(ANS))

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;
int a[200000];
int s[200000];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> a[i];

  s[0] = 0;
  for (int i = 1; i < N; i++)
    s[0] ^= a[i];

  cout << s[0];
  for (int i = 1; i < N; i++) {
    s[i] = s[i - 1] ^ a[i - 1] ^ a[i];
    cout << " " << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 5148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(void){
    int n;cin>>n;
    mint dp[108][4][4][4];
    rep(i,4)rep(j,4)rep(k,4)rep(l,102) dp[i][j][k][l]=0;
    dp[0][3][3][3]=1;
    rep(i,100)rep(j,4)rep(k,4)rep(l,4){
        rep(a,4){
            if(k==0&&l==1&&a==2)continue;//AGC
            if(j==0&&l==1&&a==2)continue;//AXGC
            if(j==0&&k==1&&a==2)continue;//AGXC
            if(k==1&&l==0&&a==2)continue;//GAC
            if(k==0&&l==2&&a==1)continue;//ACG
            dp[i+1][k][l][a]+=dp[i][j][k][l];
        }
    }
    mint res=0;
    rep(j,4)rep(k,4)rep(l,4){
        res+=dp[n][j][k][l];
    }
    cout<<res.x<<endl;
}

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

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long x = N / (A + B);
  long long y = min(A, (N % (A + B)));
  cout << A * x + y << endl;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const ll INF = 1e18;
const double PI = acos(-1.0);
const int T = 3e5 + 3;
int v[T];
ll b[T],s[T];

multiset<int> bag;

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll tmp = 0;
    for(int i = 0; i < 3*n; i++) {
        cin >> v[i];
        tmp += v[i];
        bag.insert(v[i]);
        if(bag.size() > n) {
            ll at = *bag.begin();
            tmp -= at;
            bag.erase(bag.find(at));
        }
        b[i] = tmp;
    }

    tmp = 0;
    bag.clear();

    for(int i = 3*n-1; i >= 0; i--) {
        tmp += v[i];
        bag.insert(v[i]);
        if(bag.size() > n) {
            ll at = *bag.rbegin();
            tmp -= at;
            bag.erase(bag.find(at));
        }
        s[i] = tmp;
    }

    ll ans = -1e18;

    for(int i = n-1; i < 2*n; i++)
        ans = max(ans, b[i] - s[i+1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10752