akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(4);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<int> dy={-1,0,1,0},dx={0,-1,0,1};
struct data{
    int y,x,cnt;
    data(int y,int x,int cnt):y(y),x(x),cnt(cnt) {}
};
bool ok[805][805];
bool used[805][805];
int main(){
   int h,w,k;
   cin>>h>>w>>k;
   V<string> s(h);
   for(int i=0;i<h;i++)cin>>s[i];
   V<V<int>> d(h,V<int>(w,1e6));
   for(int i=0;i<h;i++){
       ok[i][0]=1;
       ok[i][w-1]=1;
   }
    for(int i=0;i<w;i++){
       ok[0][i]=1;
       ok[h-1][i]=1;
   }
   queue<data> q;
    queue<data> qq;
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           if(s[i][j]=='S'){
               d[i][j]=1;
               q.emplace(i,j,0);
               qq.emplace(i,j,0);
           }
       }
   }
   int ans=1e6;
   while(q.size()){
       int yy=q.front().y,xx=q.front().x,c=q.front().cnt;
       c++;
       q.pop();
       if(c>k)continue;
       for(int i=0;i<4;i++){
           int ny=dy[i]+yy,nx=dx[i]+xx;
           if(s[ny][nx]=='#')continue;
           if(ok[ny][nx]){
               cout<<1<<"\n";
               return 0;
           }
           if(d[ny][nx]>d[yy][xx]){
               d[ny][nx]=d[yy][xx];
               qq.emplace(ny,nx,0);
               q.emplace(ny,nx,c);
           }
       }
   }
       while(qq.size()){
       q.emplace(qq.front());
       qq.pop();
   }
        while(q.size()){
       int yy=q.front().y,xx=q.front().x,c=q.front().cnt;c++;
       q.pop();
       for(int i=0;i<4;i++){
           int ny=dy[i]+yy,nx=dx[i]+xx;
           if(ok[ny][nx]){
               chmin(ans,(c+k-1)/k+1);
               continue;
           }
           if(d[ny][nx]>(c+k-1)/k+1){
               d[ny][nx]=(c+k-1)/k+1;
              q.emplace(ny,nx,c);
           }
       }
   }
   cout<<ans<<"\n";
}


Measured memory_bytes: 4736
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();// 学生の数
		int M = scanner.nextInt();// チェックポイント数
		List<Pos> studentList = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			// i番目の学生の位置 (a, b)
			studentList.add(new Pos(scanner.nextInt(), scanner.nextInt()));
		}
		List<Pos> checkPointList = new ArrayList<>();
		for (int i = 0; i < M; i++) {
			// i番目のチェックポイントの位置 (c, d)
			checkPointList.add(new Pos(scanner.nextInt(), scanner.nextInt()));
		}
		for (Pos stupos : studentList) {
			int checknum = 0;
			int min = stupos.distance(checkPointList.get(0));
			for (int i = 1; i < checkPointList.size(); i++) {
				int dis = stupos.distance(checkPointList.get(i));
				if (dis < min) {
					min = dis;
					checknum = i;
				}
			}
			System.out.println(checknum + 1);
		}
	}
	public static class Pos {
		int x;
		int y;
		public Pos(int x, int y) {
			this.x = x;
			this.y = y;
		}
		public int distance(Pos o) {
			return Math.abs(this.x - o.x) + Math.abs(this.y - o.y);
		}
	}
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            String S = Console.ReadLine();

            if (N % 2 != 0 ) {
                Console.WriteLine("No");
                return;
            }

            String s1 = S.Substring(0, N / 2);
            String s2 = S.Substring(N / 2, N / 2);

            if (s1 == s2) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }

}


Measured memory_bytes: 11092
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


def main():
    N, K = MI()

    for i in range(K):
        if i < N - K + 1:
            a = cmb(N - K + 1, i+1) * cmb(K - 1, i)
            print(a % MOD)
        else:
            print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49880
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef   long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI 3.1415926535

ll dp[1<<23];

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[23][23];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>a[i][j];
    ve<ll> v[30];
    for(int i=0;i<(1<<23);i++)
    {
        ll x=i,co=0;
        while(x>0)
        {
            if(x%2!=0)
                co++;
            x=x/2;
        }
        v[co].pb(i);
    }
    for(int i=0;i<n;i++)
        if(a[0][i]==1)
            dp[(1<<i)]=1;
    for(int i=1;i<n;i++)
    {
        for(int j=0;j<v[i+1].size();j++)
        {
            ll x=v[i+1][j],y=0,t=0;
            while(x>0)
            {
                if(x%2!=0 && a[i][t]==1)
                    y=(y+dp[v[i+1][j]-(1<<t)])%A;
                t++;
                x=x/2;
            }
            dp[v[i+1][j]]=y;
        }
    }
    cout<<dp[(1<<n)-1];
    return 0;
}

Measured memory_bytes: 148468
#include<iostream>
using namespace std;
int main() {

	//
	long long int a, b, n;
	cin >> n >> a >> b;
	int i, j;
	long long int x[100000];
	for (i = 0; i < n; i++) {
		cin >> x[i];
	}
	long long int s = 0;
	for (i = 0; i < n - 1; i++) {
		if ((x[i + 1] - x[i]) * a < b) {
			s = s + (x[i + 1] - x[i]) * a;
		}else{
			s = s + b;
		}
	}
	cout << s << endl;
	return 0;
	

	//C
	/*long long int p[1000];
	int i, j;
	for (i = 2; i < 1000; i++) {
		p[i] = 0;
		for (j = 2; j < i; j++) {
			if (i % j == 0)p[i] = -1;
		}
	}
	int n;
	cin >> n;
	long long int x;
	for (i = 2; i <= n; i++) {
		x = i;
		j = 2;
		while (j <= x) {
			if ((x % j == 0) && (p[j] > -1)) {
				//cout << j << endl;
				x = x / j;
				p[j]++;
				j--;
			}
			j++;
		}
	}
	long long int mod = 1000000007;
	long long int sum = 1;
	for (i = 0; i < 1000; i++) {
		if (p[i] > -1) {
			//cout << i << ' ' << p[i] << endl;
			sum = (sum * (p[i] + 1)) % mod;
		}
	}
	cout << sum << endl;
	return 0;*/

}

Measured memory_bytes: 4416
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

bool eq(string lhs, string rhs) {
  if(lhs.size() != rhs.size()) return false;
  for(int i = 0; i < lhs.size(); i++) if(lhs[i] != '?' && rhs[i] != '?' && lhs[i] != rhs[i]) return false;
  return true;
}

int main() {
  string s, t;
  cin >> s >> t;
  string ans;
  bool b = true;
  for(int i = 0; i < s.size(); i++) ans.push_back('z');
  for(int i = 0; i < s.size(); i++) {
    if(eq(s.substr(i, t.size()), t)) {
      b = false;
      string a;
      for(int j = 0; j < i; j++) a.push_back((s[j] == '?' ? 'a' : s[j]));
      for(int j = 0; j < t.size(); j++) a.push_back(t[j]);
      for(int j = t.size() + i; j < s.size(); j++) a.push_back((s[j] == '?' ? 'a' : s[j]));
      if(a < ans) {
        ans = a;
      }
    }
  }
  if(b) cout << "UNRESTORABLE" << endl;
  else cout << ans << endl;
  return 0;
}


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

int main(void) {
	llong A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	llong res = 1LL << 30;
	for (int i = 0; i <= 100000; i++) {
		if (i > X && i > Y) break;
		llong price = i * 2 * C + max(0LL, X - i)*A + max(0LL, Y - i) * B;
		res = min(res, price);
	}

	cout << res << endl;
	return 0;
}

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

#define show(x) cout << #x << " = " << x << '\n';

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,x,mx,mn;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        if(i==1) mx=mn=x;
        else{
            mx=max(mx,x);
            mn=min(mn,x);
        }
    }
    cout<<mx-mn<<endl; 
	return 0;
}

Measured memory_bytes: 256
a, b, c = [int(i) for i in input().split()]

def ncr(n, r, p): 
    # initialize numerator 
    # and denominator 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den,  
            p - 2, p)) % p 

res = (pow(2, a, 10**9 + 7) - ncr(a, b, 10**9 + 7) - ncr(a, c, 10**9 + 7) - 1) %(10 **9 + 7) 
print(res)

Measured memory_bytes: 38784
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;

void die() {
  cout << "-1\n";
  exit(0);
}

vector<int> edges[100005];
int ans[100005];
set<pii> ret;

bool seen[100005];

void dfs(int curr, int par = -1) {
  for(int out: edges[curr]) {
    if(out == par) continue;
    if(seen[out]) continue;
    seen[out] = true;
    dfs(out, curr);
    if(ans[out]%2 && ret.count({curr, out})) {
      ans[out]++;
      ans[curr]--;
      ret.erase({curr, out});
      ret.insert({out, curr});
    }
    if(ans[out]%2 && ret.count({out, curr})) {
      ans[out]--;
      ans[curr]++;
      ret.erase({out, curr});
      ret.insert({curr, out});
    }
  }
}

void solve() {
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    ret.insert({a, b});
    edges[a].push_back(b);
    edges[b].push_back(a);
    ans[a]++;
  }
  seen[1] = true;
  dfs(1);
  for(int i = 1; i <= n; i++) {
    if(ans[i]%2) die();
  }
  for(pii out: ret) {
    cout << out.first << " " << out.second << "\n";
  }
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 21376
#include <cstdio>
#include <climits>
#include <algorithm>
#define inf INT_MAX/2;
using namespace std;
int main() {
    int n;
    while (scanf("%d",&n)) {
        if (!n) break;
        int M=0, m=inf;
        for (int i=0; i<n; i++) {
            int sum=0;
            for (int j=0; j<5; j++) {
                int s; scanf("%d",&s);
                sum+=s;
            }
            M=max(M,sum);
            m=min(m,sum);
        }
        printf("%d %d\n",M,m);
    }
}

Measured memory_bytes: 0
//include "stdafx.h"
#include<iostream>
#include<algorithm>
using namespace std;
void maximumProfit();


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

void maximumProfit()
{
	const int MAX = 200000;
	int R[MAX];
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> R[i];
	}
	int mi = R[0];
	int ma = -2000000000;
	for (int i = 1; i < N; i++)
	{
		ma = max(ma,  R[i]-mi);
		mi = min(mi, R[i]);
	}

	cout << ma << endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C;
    cin >> A >> B >> C;

    ll k = gcd(A, B);
    
    if(C%k == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3620
// ABC141_A
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str,str1,str2;
    cin >> str;
    str1 ="Sunny";
    str2 = "Cloudy";
    if(str == str1){
        cout << "Cloudy" << endl;
        
    } else if(str == str2 ){
        cout << "Rainy" << endl;
    } else{
        cout << "Sunny" << endl;
    }

}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())printf("%d ",v[_]);cout<<"\n";}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

int n,m;
vs in;
vvi used;
int c1,c2;
void dfs(int x,int y){
	used[x][y]=1;
	if(in[x][y]=='.')c1++;
	else c2++;
	rep(i,4){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx<0||ny<0||nx>=n||ny>=m)continue;
		if(used[nx][ny])continue;
		if(in[nx][ny]==in[x][y])continue;
		dfs(nx,ny);
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n>>m;
	used=vvi(n,vi(m));
	in=vs(n);
	rep(i,n)cin>>in[i];
	int out=0;
	rep(i,n)rep(j,m)if(!used[i][j]){
		c1=c2=0;
		dfs(i,j);
		out+=c1*c2;
	}
	cout<<out<<endl;
}









Measured memory_bytes: 14208
n, m = map(int, input().split())

A = []
for i in range(1, int(m**0.5) + 1):
    if m % i == 0:
        A.append(i)
        A.append(m//i)
A = sorted(A)

for i in A:
    if i >= n:
        print(m//i)
        break

Measured memory_bytes: 38640
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include<queue>
#include<map>
using namespace std;
int A[200005];
int main() {
	int N,M;
	int a,b;
	cin >> N >> M;
	
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		if (a == 1||a==N)A[b]++;
		if (b == 1 || b == N)A[a]++;

	}
	int Y = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] >= 2)Y++;
	}

	if (Y > 0)cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;


	return 0;
}


Measured memory_bytes: 1024
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

const int mod = 1000003;
const int MAX = 1001;

int dp1A[MAX][MAX];
int dp1B[MAX][MAX];
int dp2[MAX];
int dp3[MAX];

int main(){
  int n, k;

  while(scanf("%d%d", &n, &k), n + k){
    int asum = 1;
    int bsum = 0;
    int ans = 0;

    if(k >= n){
      k = n - 1;
      ans = 2;
    }

    memset(dp1A, 0, sizeof(dp1A));
    memset(dp1B, 0, sizeof(dp1B));
    memset(dp2, 0, sizeof(dp2));
    memset(dp3, 0, sizeof(dp3));

    dp1A[1][1] = 1;
    dp1B[1][1] = 0;
    
    for(int i = 2; i <= n; i++){
      dp1A[i][1] = bsum;
      dp1B[i][1] = asum;

      asum = dp1A[i][1];
      bsum = dp1B[i][1];

      for(int j = 2; j <= min(k, i); j++){
	asum += (dp1A[i][j] = dp1A[i-1][j-1]); asum %= mod;
	bsum += (dp1B[i][j] = dp1B[i-1][j-1]); bsum %= mod;
      }
    }

    // puts("dp1A:"); for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++) printf("%d ", dp1A[i][j]); puts(""); }
    // puts("dp1B:"); for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++) printf("%d ", dp1B[i][j]); puts(""); }

    for(int i = 1; i <= n; i++)
      for(int j = 1; j <= k; j++){
	dp2[i] += dp1B[i][j];
	dp2[i] %= mod;
      }

    for(int i = 1; i <= n; i++)
      for(int j = 1; j < k; j++){
	dp1B[i][j + 1] += dp1B[i][j];
	dp1B[i][j + 1] %= mod;
      }

    for(int i = 1; i <= n; i++)
      for(int p = 1; p <= min(i, k); p++){
	dp2[i] += dp1B[i - p][k - p];
	dp2[i] %= mod;
      }

    /*
    puts("dp2:");
    for(int i = 1; i <= n; i++)
      printf("%d ", dp2[i]);
    puts("");
    */

    for(int i = 1; i <= n; i++){
      dp3[i] = (2 * dp2[i]) % mod;
      for(int j = 2; j < i; j++) if(i % j == 0){
	dp3[i] -= dp3[j];
	dp3[i] = (dp3[i] + mod) % mod;
      }
    }

    /* 
    puts("dp3:");
    for(int i = 1; i <= n; i++)
      printf("%d ", dp3[i]);
    puts("");
    */

    for(int i = 2; i <= n; i++){
      if(n % i == 0){
	int tmp = 0;
	for(int j = 0; j < mod; j++){
	  if(tmp == 1){
	    tmp = j; break;
	  }
	  tmp += i; tmp %= mod;
	}

	ans = (ans + ((long long)dp3[i] * tmp) % mod) % mod;
      }
    }

    printf("%d\n", ans, n, k);
  }
}

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

int main() {
  int R;
  cin >> R;
  if (R < 1200)
  {
    cout << "ABC" << endl;
  }
  else if (R < 2800)
  {
    cout << "ARC" << endl;
  }
  else
  {
    cout << "AGC" << endl;
  }
}

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

int main(){
int a,b,max=0;
cin >>a >>b;
for(int i=0; i<2;i++){
    if(a>=b){
        max+=a;
        a--;
    }
    else{
        max+=b;
        b--;
    }
}
cout <<max <<endl;
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char m[1002][1002];
int dp[1002][1002];
int n,mi;
void ini(){
    for(int i=1;i<=1001;i++)
        for(int j=1;j<=1001;j++)
            dp[i][j]=-1;
}
int f(int x,int y){
    if(x==n and y==mi)return 1;
    if(m[x][y]=='#' or x>n or y>mi)return 0;
    if(dp[x][y]!=-1)return dp[x][y];
    return dp[x][y]=f(x+1,y)%(1000000007)+f(x,y+1)%(1000000007);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>mi;
    ini();
    for(int i=1;i<=n;i++){
       for(int j=1;j<=mi;j++){
            cin>>m[i][j];
        }
    }
    cout<<f(1,1)%(1000000007);
}


Measured memory_bytes: 5248
#include <cstdio>
#include <cstdlib>

int stack[101];
int cur = 0;

void push(int i){
	stack[cur] = i;
	cur++;
}

int pop(){
	cur--;
	return stack[cur];
}
int main(){
	char op[100];
	int a, b;
	
	while(scanf("%s", op) != EOF){
		switch(op[0]){
		case '+':
			b = pop();
			a = pop();
			push(a + b);
			break;
		case '-':
			b = pop();
			a = pop();
			push(a - b);
			break;
		case '*':
			b = pop();
			a = pop();
			push(a * b);
			break;
		case '/':
			b = pop();
			a = pop();
			push(a / b);
			break;
		default:
			push(atoi(op));
			break;
		}
	}
	
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 976
/*input
0
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <tgmath.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<long long, long long> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 
vector<int> adj_list[100010];
bool visited[10010];

void dfs(int node){
	visited[node] = true;
	for(int n: adj_list[node]){
		if(!visited[n]){
			dfs(n);
		}
	}
}



int main() {
 	string s;
 	cin>>s;
 	int count = 0;
 	rep(i,s.size()){
 		char a = s[i];
 		int g = a - '0';
 		count+=g;
 	}
 	if(count%9==0){
 		cout<<"Yes"<<endl;
 	}
 	else{
 		cout<<"No"<<endl;
 	}
}



 


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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;

struct gT
{
	gT ()
	{
		INIT ( la, -1 );
	}
	
	void addedge ( int u, int v )
	{
		edge[ke].setd ( u, v, la[u] );
		la[u] = ke++;
		edge[ke].setd ( v, u, la[v] );
		la[v] = ke++;
	}
	
	int input ( int n )
	{
		int nf, nr;
		lpi ( i, 1, n ){
			scanf ( "%d", &nf );
			if ( ~nf ) addedge ( i, nf );
			else nr = i;
		}
		return nr;
	}

	int last ( int i )
	{
		return edge[i].last;
	}

	int v ( int i )
	{
		return edge[i].v;
	}

	int ke, la[MAXN];

	struct eT
	{
		void setd ( int _u, int _v, int _l )
		{
			u = _u, v = _v, last = _l;
		}

		int u, v, last;
	}edge[MAXN * 4];
}ga, gb, g;

int n, ra, rb;
int od[MAXN];
int ans[MAXN];

void init ();
void input ();
void work ();

int dfs ( int now, int fa, gT &ng, int f );
void paint ( int now, int c );



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method
	
	scanf ( "%d", &n );
	ra = ga.input ( n ), rb = gb.input ( n );
}

void work ()
{
	// main work
	
	dfs ( ra, -1, ga, 1 );
	dfs ( rb, -1, gb, 2 );
	
	lpi ( i, 1, n ){
		if ( od[i] == 1 || od[i] == 2 ){
			printf ( "IMPOSSIBLE\n" );
			return;
		}
	}
	
	lpi ( i, 1, n ){
		if ( od[i] && !ans[i] ){
			paint ( i, 1 );
		}
	}
	
	printf ( "POSSIBLE\n" );
	lpi ( i, 1, n ) printf ( "%d ", ans[i] );
	putchar ( '\n' );
}



int dfs ( int now, int fa, gT &ng, int f )
{
	int v, last = -1, ret;
	for ( int i = ng.la[now]; ~i; i = ng.last ( i ) ){
		if ( ( v = ng.v ( i ) ) ^ fa ){
			if ( ret = dfs ( v, now, ng, f ) ){
				if ( ~last ) g.addedge ( last, ret ), last = -1;
				else last = ret;
			}
		}
	}
	
	if ( last == -1 ){
		od[now] |= f;
		return now;
	}else return last;
}

void paint ( int now, int c )
{
	if ( ans[now] ) return;
	ans[now] = c;
	for ( int i = g.la[now]; ~i; i = g.last ( i ) ) paint ( g.v ( i ), -c );
}

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

namespace ABC121_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs0 = Console.ReadLine().Split(' ');
            int n = int.Parse(strs0[0]);
            int m = int.Parse(strs0[1]);
            int c = int.Parse(strs0[2]);

            string[] strs1 = Console.ReadLine().Split(' ');
            int[] b = new int[m];
            for (int i = 0; i < m; ++i)
            {
                b[i] = int.Parse(strs1[i]);
            }

            int count = 0;

            for (int i = 0; i < n; ++i)
            {
                int ans = 0;
                string[] strs2 = Console.ReadLine().Split(' ');
                for (int j = 0; j < m; ++j)
                {
                    ans += b[j] * int.Parse(strs2[j]);
                }

                if (ans + c > 0)
                {
                    ++count;
                }
            }

            Console.WriteLine("{0}", count);
        }
    }
}


Measured memory_bytes: 13140
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = list(input())
result = 0
for i in range(n):
    if t[i] == "r":
        result += p
    elif t[i] == "p":
        result += s
    else:
        result += r
for i in range(n-k):
    if t[i] == t[i+k]:
        if t[i] == "r":
            result -= p
        elif t[i] == "p":
            result -= s
        else:
            result -= r  
        t[i+k] = "1"      

print(result)

Measured memory_bytes: 4212
// package coffee.acupof.atcoder.solution.abc162.c

fun gcd(a: Int, b: Int): Int {
    return when {
        a == b -> a
        a > b -> gcd(b, a)
        else -> gcd(a,b - a)
    }
}

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()

    val memo = (1..k).map { ab ->
        (1..k).map { c ->
            gcd(ab, c)
        }.sum()
    }.toIntArray()

    var sum = 0

    for (a in 1..k) {
        for (b in 1..k){
            sum += memo[gcd(a, b) - 1]
        }
    }
    println(sum)
}

Measured memory_bytes: 36560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt = 0;
    int pre = 0;
    rep(i, 0, n) {
        if (s[i] == '(') cnt++;
        else {
            cnt--;
            pre = max(pre, -cnt);
        }
    }

    rep(i, 0, pre) s = '(' + s;

    n += pre;
    cnt = 0;
    rep(i, 0, n) {
        if (s[i] == '(') cnt++;
        else cnt--;
    }

    rep(i, 0, cnt) s += ')';

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (){
    int S;
    int h = 0, m = 0, s = 0;
    
    scanf("%d", &S);
    
    while (S >= 3600){
        S -= 3600;
        h++;
    }
    
    while (S >= 60){
        S -=60;
        m++;
    }
    
    s = S;
    
    printf("%d:%d:%d\n", h, m, s);
    
    return 0;
}


Measured memory_bytes: 2108
import java.util.Scanner;


public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			String s=scanner.next();
			int joi=0,ioi=0;
			for(int i=0;i<s.length()-2;i++){
				if(s.charAt(i+1)=='O'&&s.charAt(i+2)=='I'){
					switch(s.charAt(i)){
					case 'J':
						joi++;
						break;
					case 'I':
						ioi++;
						break;
					}
				}
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}
}

Measured memory_bytes: 20168
#include <stdio.h>
#include<iostream>
using namespace std;

int a[100003];

int main()
{
    int N;
    cin >> N;
    while (N--)
    {
        int t;
        cin >> t;
        a[t]++;
        a[t + 1]++;
        a[t + 2]++;
    }
    cout << *max_element(a + 2, a + 100000) << endl;
    return 0;
}

Measured memory_bytes: 3476
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	int a, b;
	cin >> a >> b;
	if (a + b >= 10) {
		cout << "error" << endl;
	}
	else {
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    long k=sc.nextLong();
    int[] a=new int[n+1];
    for(int i=1;i<=n;i++){
      a[i]=sc.nextInt();
    }
    List<Integer> ls=new ArrayList<>();
    Set<Integer> st=new HashSet<>();
    int p=1;
    ls.add(p);
    st.add(p);
    while(!st.contains(a[p])){
      p=a[p];
      st.add(p);
      ls.add(p);
    }
    int idx=ls.indexOf(a[p]);
    if(k<ls.size()){
      System.out.println(ls.get((int)k));
    }else{
      System.out.println(ls.get((int)((k-idx)%(ls.size()-idx)+idx)));
    }
  }
}

Measured memory_bytes: 66396
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String X = sc.next();
        String Y = sc.next();

        String alphaHex = "ABCDEF";

        if (alphaHex.indexOf(X) < alphaHex.indexOf(Y)) {
            System.out.println("<");
        }else if (alphaHex.indexOf(X) == alphaHex.indexOf(Y)){
            System.out.println("=");
        }else{
            System.out.println(">");
        }
    }

}


Measured memory_bytes: 21716
local mmi, mma = math.min, math.max
local mfl, mce = math.floor, math.ceil
local n, m, r = io.read("*n", "*n", "*n")
local t = {}
for i = 1, r do
  t[i] = io.read("*n")
end
local inf = 1000000007 * 1000
local len = {}
for i = 1, n do
  len[i] = {}
  for j = 1, n do
    len[i][j] = i == j and 0 or inf
  end
end
for i = 1, m do
  local a, b, c = io.read("*n", "*n", "*n")
  len[a][b], len[b][a] = c, c
end
for k = 1, n do
  for i = 1, n do
    for j = 1, n do
      len[i][j] = mmi(len[i][j], len[i][k] + len[k][j])
    end
  end
end

local function getpattern(n, patall, idx)
  local used = {}
  local retary = {}
  local div = patall
  for i = 1, n do used[i] = false end
  for i = n, 1, -1 do
    div = mfl(div / i)
    local v_idx = mfl(idx / div)
    idx = idx % div
    local tmp_idx = 0
    for j = 1, n do
      if not used[j] then
        if tmp_idx == v_idx then
          table.insert(retary, j)
          used[j] = true
          break
        else
          tmp_idx = tmp_idx + 1
        end
      end
    end
  end
  return retary
end

local function heldkarp_prepare(n)
  local tot = 1
  local alltask = {}
  local stagetask = {}
  for i = 1, n do
    tot = tot * 2
    alltask[i] = {}
    stagetask[i] = {}
  end
  for i = 1, n do
    for j = 1, tot - 1 do
      -- set inf value
      alltask[i][j] = 100000 * 200 * 8
    end
  end
  for i = 1, tot - 1 do
    local ti = i
    local cnt = 0
    for j = 1, n do
      if ti % 2 == 1 then
        cnt = cnt + 1
        ti = ti - 1
      end
      ti = ti / 2
    end
    table.insert(stagetask[cnt], i)
  end
  -- set first state
  local tmp = 1
  for i = 1, n do
    alltask[i][tmp] = 0
    tmp = tmp * 2
  end
  return tot, alltask, stagetask
end

local function heldkarp_doall(n, alltask, stagetask)
  for stage = 1, n - 1 do
    local stlen = #stagetask[stage]
    for i_stagetask = 1, stlen do
      local used = stagetask[stage][i_stagetask]
      local t_used = used
      for i = 1, n do
        if t_used % 2 == 1 then
          local val = alltask[i][used]
          local mul = 1
          local tmp = used
          for j = 1, n do
            if tmp % 2 == 0 then
              alltask[j][used + mul] = mmi(alltask[j][used + mul], val + len[t[i]][t[j]])
            else
              tmp = tmp - 1
            end
            tmp = tmp / 2
            mul = mul * 2
          end
          t_used = t_used - 1
        end
        t_used = t_used / 2
      end
    end
  end
end

local function heldkarp_getresult(n, tot, alltask)
  local ret = 100000 * 200 * 8
  for i = 1, n do
    ret = mmi(ret, alltask[i][tot - 1])
  end
  return ret
end
local tot, alltask, stagetask = heldkarp_prepare(r)
heldkarp_doall(r, alltask, stagetask)
print(heldkarp_getresult(r, tot, alltask))


Measured memory_bytes: 2912
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=1010,inf=1e9;
inline int Abs(int x) { return x>0?x:-x; }
int S,T;
namespace Flow {
	const int N=5010;
	int head[N],cur[N],vis[N];
	ll dis[N];
	struct ed { int to,next,f; ll w; };
	vector<ed> e;
	void init() { e.clear(); memset(head,-1,sizeof(head)); }
	void ad(int x,int y,int f,ll w) {
		e.PB((ed){y,head[x],f,w}); head[x]=e.size()-1;
		e.PB((ed){x,head[y],0,-w}); head[y]=e.size()-1;
	}
	queue<int> q;
	bool bfs() {
		memset(dis,-0x3f,sizeof(dis));
		memcpy(cur,head,sizeof(cur));
		dis[S]=0,q.push(S),vis[S]=1;
		while(!q.empty()) {
			int u=q.front(); q.pop(),vis[u]=0;
			for(int k=head[u];~k;k=e[k].next) if(e[k].f) {
				int v=e[k].to;
				if(dis[v]<dis[u]+e[k].w) {
					dis[v]=dis[u]+e[k].w;
					if(!vis[v]) q.push(v),vis[v]=1;
				}
			}
		}
		return dis[T]>-1e16;
	}
	int dfs(int u,int f) {
		if(u==T||!f) return f; int ret=0,tmp;
		vis[u]=1;
		for(int &k=cur[u];~k;k=e[k].next) if(e[k].f) {
			int v=e[k].to;
			if(dis[v]==dis[u]+e[k].w&&!vis[v]&&(tmp=dfs(v,min(f,e[k].f)))) {
				f-=tmp,ret+=tmp;
				e[k].f-=tmp,e[k^1].f+=tmp;
				if(!f) break;
			}
		}
		vis[u]=0;
		return ret;
	}
	ll work() { ll ans=0; while(bfs()) ans+=dis[T]*dfs(S,1e9); return ans; }
}
int rx[N],ry[N],rc[N];
int bx[N],by[N],bc[N];
int n;
int main() {
	rd(n);
	for(int i=1;i<=n;++i) rd(rx[i]),rd(ry[i]),rd(rc[i]);
	for(int i=1;i<=n;++i) rd(bx[i]),rd(by[i]),rd(bc[i]);
	S=2*n+1,T=2*n+2;
	int p[4];
	for(int i=0;i<4;++i) p[i]=2*n+3+i;
	Flow::init();
	for(int i=1;i<=n;++i) {
		Flow::ad(S,i,rc[i],0);
		Flow::ad(i+n,T,bc[i],0);
	}
	for(int i=1;i<=n;++i) {
		Flow::ad(i,p[0],inf,rx[i]+ry[i]);
		Flow::ad(i,p[1],inf,rx[i]-ry[i]);
		Flow::ad(i,p[2],inf,-rx[i]+ry[i]);
		Flow::ad(i,p[3],inf,-rx[i]-ry[i]);
		
		Flow::ad(p[0],i+n,inf,-bx[i]-by[i]);
		Flow::ad(p[1],i+n,inf,-bx[i]+by[i]);
		Flow::ad(p[2],i+n,inf,bx[i]-by[i]);
		Flow::ad(p[3],i+n,inf,bx[i]+by[i]);
	}
	printf("%lld",Flow::work());
	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> a(n), b(n), c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    int ans = 0;
    rep(i,n) {
        ans += b[a[i]-1];
        if (i >= 1 && a[i]-a[i-1] == 1) ans += c[a[i-1]-1];
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x) for (int i = 0; i < x; ++i)
#define rep2(i, a, b) for (int i = a; i < b; ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<P> p(m);
    rep (i, m) cin >> p[i].first >> p[i].second;
    rep (x, 1000) {
        int nx = x / 10;
        vector<int> d(1, x % 10);
        while (nx) {
            d.push_back(nx % 10);
            nx /= 10;
        }
        if (d.size() != n) continue;
        reverse(d.begin(), d.end());
        bool ok = true;
        rep (i, m) {
            if (d[p[i].first-1] != p[i].second) ok = false;
        }
        if (ok) {
            cout << x << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define p pair<ll, ll>
#define SIZE 100010
using namespace std;

ll x[SIZE], v[SIZE], y[SIZE];
ll A[SIZE], B[SIZE];
ll f[SIZE], g[SIZE];

int main() {
    int n;
    ll c;
    cin >> n >> c;
    vector<ll> s;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> v[i];
        y[n - i + 1] = c - x[i];
    }
    for (int i = 1; i <= n; i++) {
        A[i] = A[i - 1] + v[i];
        B[i] = B[i - 1] + v[n - i + 1];
    }
    ll m1 = 0, m2 = 0;
    for (int i = 1; i <= n; i++) {
        m1 = max(m1, A[i] - x[i]);
        m2 = max(m2, B[i] - y[i]);
        f[i] = m1, g[i] = m2;
    }
    ll ans = 0LL;
    for (int i = 1; i <= n; i++) {
        ans = max({ans, f[i], g[i]});
        ans = max(f[i] - x[i] + g[n - i], ans);
        ans = max(g[i] - y[i] + f[n - i], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> s(m);
    rep(i,m){
        ll k;
        cin >> k;
        rep(j,k){
            ll x;
            cin >> x;
            x--;
            s[i].push_back(x);
        }
    }
    vector<ll> p(m);
    rep(i,m){
        cin >> p[i];
    }
    ll ans=0;
    for(ll i=0;i<(1<<n);i++){
        bool ok=true;
        rep(j,m){
            ll cnt=0;
            for(auto x:s[j]){
                if((i>>x)%2==1){
                    cnt++;
                }
            }
            if(cnt%2!=p[j]){
                ok=false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
void trace(int A[], int N) {
	for (int i = 0;i < N;i++) {
		if (i > 0) {
			printf(" ");
		}
		printf("%d", A[i]);
	}
	cout << endl;
}
void insertSort(int A[], int N) {
	int v;
	for (int i = 1;i < N;i++) {
		v = A[i];
		int j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = v;
		trace(A, N);
	}
}

int main() {
	int N;
	int A[100];
	cin >> N;
	for (int i = 0;i < N;i++)cin >> A[i];
	trace(A, N);
	insertSort(A, N);
	return 0;
}


Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  bool flag=true;
  char f=s[0];
  char r=s[3];
  rep(i,3){
    if(f!=s[i]){
      flag=false;
    }
  }
  if(!flag){
    flag=true;
    rep(i,3){
      if(r!=s[i+1]){
        flag=false;
      }
    }
  }
	if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bitset>
#include <utility>
#define Max 20
using namespace std;

int main(){
    int n;
    vector<pair<int,int> > adj[Max];
    cin >> n;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        for(int j=0;j<a;j++){
            int x,y;
            cin >> x >> y;
            x--;
            adj[i].push_back(make_pair(x,y));
        }
    }

    int ans =0;
    for(int bit=0;bit<(1<<n);bit++){
        bool flag = 1;
        bitset<15> B(bit);
        for(int i=0;i<n;i++){
            //i人目が不親切なら飛ばす
            if(!(B[i])){
                continue;
            }
            for(int j=0;j<adj[i].size();j++){
              if(adj[i][j].second != B[adj[i][j].first]){
                  flag = 0;
                  break;
                  }
            }
        }
        if(flag){
            if(ans<B.count()){
                ans = B.count();
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())

void Add(ll &a, ll b){a=(a+b)%mod;}
void Pro(ll &a, ll b){a=(a*b)%mod;}


int main(){
    ll N; cin>>N;
    vec A(N), B(N);
    rep(i,N) cin>>A[i]>>B[i];
    ll ans=0;
    for(int i=N-1;i>=0;i--){
        ll K=(ans+A[i])%B[i];
        if(K) ans+=(B[i]-K);
    }
    cout<<ans<<endl;
}

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

int h[100006];

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;++i) scanf("%d",&h[i]);
	for(int i=n;i>=2;--i) {
		if(h[i]+1==h[i-1]) h[i-1]--;
		else if(h[i]+1<h[i-1]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll all=0;
    vector<ll> tot(n);
    for(int i=0; i<n; i++){
        cin >> tot.at(i);
        all += tot.at(i);
        if(i>=1) tot.at(i)+=tot.at(i-1);
    }
    ll ans=pow(10,18);
    for(int i=0; i<n-1; i++){
        ll dif = abs(tot.at(i)-(all-tot.at(i)));
        ans = min(ans, dif);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4812
# 02
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
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 S(): return input()
def LS(): return input().split()


INF = float('inf')


h, w = LI()
a = []
for _ in range(h):
    a.append(list(S()))

cnt = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            cnt += 1

if cnt == h+w-1:
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <typeinfo>
#include <list>
#include <queue>
#include <stack>
#include <limits.h>
#include <set>
#include <map>
using namespace std;


int main() {
    int N;
    string S;
    cin>>N>>S;
    map<char, long long> m;
    for (char s:S) {
        m[s]++;
    }
    long long ans = 1, mod = 1e9+7;
    for (auto e:m) {
        if (e.second > 1) {
            ans = (e.second + 1) * ans % mod;
        }
        else {
            ans = ans * 2 % mod;
        }
    }
    cout<<(ans-1) % mod<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];
char field[200][200];

int main(){
  cin >> n >> m >> l;
  int i = 0;
  if(n < m)swap(n,m);
  if(n < l)swap(n,l);
  if(m < l)swap(m,l);
  // cout << n << " " << m << " " << l << endl;
  int p = n - m;
  m += p;
  l += p;
  i += p;
  if(n - l != 0){
    if((n - l) % 2){
      i += 2;
      l++;
      n++;
    }
    i += (n - l) / 2;
  }
  // cout << n << " " << m << " " << l << endl;
  print(i);
  return 0;
}

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

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

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  if(a<b){
    for(int i=0;i<b;i++){
      ans+=a;
      a*=10;
    }
  }
  else{
    for(int i=0;i<a;i++){
      ans+=b;
      b*=10;
    }
  }
  cout << ans << endl;
}
      
  
  
  

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
S=input()
sign="+-"
for i in range(2):
  for j in range(2):
    for n in range(2):
      if eval(S[0]+sign[i]+S[1]+sign[j]+S[2]+sign[n]+S[3])==7:
        print(str(S[0]+sign[i]+S[1]+sign[j]+S[2]+sign[n]+S[3])+'=7')
        exit()

Measured memory_bytes: 3064