akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void dk()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int knapsack(int a[], int val[], int n, int k)
{
    int dp[k + 1][n + 1];
    for (int i = 0; i <= n; i++)
    {
        dp[0][i] = 0;
    }
    for (int i = 0; i <= k; i++)
    {
        dp[i][0] = 0;
    }
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            if (a[j - 1] <= i)
            {
                dp[i][j] = max(dp[i][j - 1], dp[i - a[j - 1]][j - 1] + val[j - 1]);
            }
            else
            {
                dp[i][j] = dp[i][j - 1];
            }
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    return dp[k][n];
}
int32_t main()
{
    //dk();
    int n, k;
    cin >> n >> k;
    int val[n], a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> val[i];
    }
    int m = knapsack(a, val, n, k);
    cout << m;
    return 0;
}

Measured memory_bytes: 79104
#include<iostream>
using namespace std;
int main() {
  int NoS,num;
  char Mark;
  bool Cards[4][13]={{}};
  cin >> NoS;
  for(int i=0; i<NoS; i++) {
    cin >> Mark >> num;
    if(Mark == 'S') Cards[0][num-1] = true;
    else if(Mark == 'H') Cards[1][num-1] = true;
    else if(Mark == 'C') Cards[2][num-1] = true;
    else if(Mark == 'D') Cards[3][num-1] = true;
  }
  for(int i=0; i<4; i++) {
    for(int j=0; j<13; j++){
    if(Cards[i][j] != true) {
      if(i == 0) cout << "S " << j+1 << endl;
      if(i == 1) cout << "H " << j+1 << endl;
      if(i == 2) cout << "C " << j+1 << endl;
      if(i == 3) cout << "D " << j+1 << endl;
    }
  }
}
  return 0;

}



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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    int[] d = new int[k];
    int[] count = new int[n];
    for(int i=0; i<k; i++) {
      d[i] = Integer.parseInt(in.readLine());
      int[][] a = new int[k][d[i]];
      str = in.readLine().split(" ");
      for(int j=0; j<d[i]; j++) {
        a[i][j] = Integer.parseInt(str[j]);
        count[a[i][j]-1]++;
      }
    }
    
    int ans = 0;
    for(int i=0; i<n; i++) {
      if(count[i]==0)
        ans++;
    }
    
    System.out.println(ans);
  }
}

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

int bingo(vector<vector<int>> V) {
  int v = V.size();
  int cnt = 0;
  for (auto a : V) if (accumulate(a.begin(), a.end(), 0) == -v) cnt++;
  for (int i = 0; i < v; i++) {
    int tmp = 0;
    for (int j = 0; j < v; j++) tmp += V.at(j).at(i);
    if (tmp == -v) cnt++;
  }
  int tmp1 = 0;
  int tmp2 = 0;
  for (int i = 0; i < v; i++) {
    tmp1 += V.at(i).at(i);
    tmp2 += V.at(i).at(v - 1 - i);
  }
  if (tmp1 == -v) cnt++;
  if (tmp2 == -v) cnt++;
  return cnt;
}

int main() {
  vector<vector<int>> V(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> V.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  while (cin >> N) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (V.at(i).at(j) == N) V.at(i).at(j) = -1;
      }
    }
  }
  cout << ((bingo(V)) ? "Yes" : "No") << "\n";
}

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

int main() {
	int n;
	cin >> n;
	bool a=false;
	for(int i=0;i<26;i++){
		for (int j=0;j<15;j++){
			if ((4*i+7*j)==n){
					cout << "Yes" << endl;
					a=true;
					break;
			}
		}
		
		if(a==true) break;
		
	}
	if(a==false) cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# ABC137 B

import numpy as np

def resolve():
    k, x = map(int, input().split())
    for i in range(x-k+1, x+k):
        if -1000000 <= i and i <= 1000000:
            print("{} ".format(i), end="")
    print("")


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 12508
#include<bits/stdc++.h>
#define ll long long 
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll n,m,i,a,b,k,t;
    cin>>n;
    ll arr[n];
    ll all=0;
    for(i=0;i<n;i++) cin>>arr[i];
    for(i=0;i<n;i++) all^=arr[i];
    ll dup=all;
    for(i=0;i<n;i++) 
    {
        all=dup;
        all^=arr[i];
        cout<<all<<" ";
    }
}

Measured memory_bytes: 5060
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()

ks = [LIST() for _ in range(M)]

p = LIST()

ans = 0
for i in range(1<<N):  # スイッチの状態を全探索
	i = list("{:b}".format(i).zfill(N))
	flag = True
	for j, lis in enumerate(ks):
		lis = lis[1:]
		tmp = 0
		for l in lis:
			if i[l-1] == '1':
				tmp += 1
		if tmp % 2 != p[j]:
			flag = False
			break
	if flag:
		ans += 1
print(ans)

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

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


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

using namespace std;


int gcd(int a, int b) 
{ 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 

int main() {

int k;

cin>>k;

int64_t sum=0;

for(int i=1;i<=k;i++) {
	for(int j=1;j<=k;j++) {
		for(int l=1;l<=k;l++) {
			sum=sum+__gcd(__gcd(i,j),l);
			//sum=sum+gcd(i,gcd(l,j));
		}
	}
}

cout<<sum;

	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    long long int product = 1;
    
    for(int i = 1; i <= n; i++)
    {
        product *= i;
        product %= 1000000007;
    }
    
    cout << product << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int h,w,c,ans;
int t[10][10];
 
void check(){
  int cnt=0,flg[10][10];
  for(int i=0;i<10;i++)for(int j=0;j<10;j++)flg[i][j]=false;
  queue<int> qy,qx;
  qy.push(0);qx.push(0);
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    if(y<0||x<0)continue;
    if(y>=h||x>=w)continue;
    if(flg[y][x])continue;
    if(t[y][x]!=c)continue;
    cnt++;
    flg[y][x]=true;
    for(int i=0;i<4;i++)qy.push(y+dy[i]),qx.push(x+dx[i]);
  }
  ans=max(ans,cnt);
}
 
void solve(int depth){
  if(depth==5)check();
  else{
 
    int flg[10][10];
    for(int i=0;i<10;i++)for(int j=0;j<10;j++)flg[i][j]=0;
    queue<int> qy,qx;
    qy.push(0);qx.push(0);
    while(!qy.empty()){
      int y=qy.front();qy.pop();
      int x=qx.front();qx.pop();
      if(y<0||x<0)continue;
      if(y>=h||x>=w)continue;
      if(flg[y][x]!=0)continue;
      if(t[y][x]!=t[0][0])continue;
      flg[y][x]=t[y][x];
      for(int i=0;i<4;i++)qy.push(y+dy[i]),qx.push(x+dx[i]);
    }
    for(int I=1;I<=6;I++){
      if(I==flg[0][0])continue;
      for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(flg[i][j]!=0)t[i][j]=I;
      solve(depth+1);
    }
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
    if(flg[i][j]!=0)t[i][j]=flg[i][j];
  }
}
int main(){
  while(1){
    cin>>h>>w>>c;
    if(h==0&&w==0&&c==0)break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
    cin>>t[i][j];
    ans=0;
    solve(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define pb push_back
#define vec vector<int>
using namespace std;
int main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
    int n,i;
    cin>>n;
    /*vector<int> a(n);
    for(i=0;i<n;i++)
        cin>>a[i];
    */
    string s;
    int ac=0,wa=0,tle=0,re=0;
    for(i=0;i<n;i++)
    {
      cin>>s;
      if(s=="AC")
            ac++;
      else if(s=="TLE")
        tle++;
      else if(s=="RE")
        re++;
      else
        wa++;
    }
    cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re;
  }
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#define ll long long int
using namespace std;

int main() {
	ll n;
	cin>>n;
	ll a[n][2];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i][0]>>a[i][1];
	}
	ll flag=0;
	for(ll i=2;i<n;i++)
	{
		if(a[i][0] == a[i][1] && a[i-1][0] == a[i-1][1] && a[i-2][0] == a[i-2][1])
		{
			flag++;
			break;
		}
	}
	
	if(flag)
		cout<<"Yes\n";
	else cout<<"No\n";
	
	
	
	return 0;
}

Measured memory_bytes: 3668
// Working program with FastReader
import java.io.*;
import java.util.*;

public class Main
{
	static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;

		public FastReader()
		{
			br = new BufferedReader(new
					InputStreamReader(System.in));
		}

		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt()
		{
			return Integer.parseInt(next());
		}

		long nextLong()
		{
			return Long.parseLong(next());
		}

		double nextDouble()
		{
			return Double.parseDouble(next());
		}

		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args)
	{
		FastReader ob=new FastReader();
		int k=ob.nextInt();
		String s=ob.next();
		if(s.length()>k){
            System.out.println(s.substring(0,k)+"...");
            return;
        }
        System.out.println(s);

	}
}



Measured memory_bytes: 36480
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll n;
    cin >> n;

    vector <int> color(n);
    for (int i = 0; i < n; i++) {
        cin >> color[i];
        color[i]--;
    }

    vector<vector<int>> edge(n);
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }

    vector <int> cnt(n);
    vector < map<int, int> > dp(n);
    vector < vector<int> > res(n);

    auto dfs = [&](auto &&dfs, int cur, int par) -> void {
        for (int ch : edge[cur]) {
            if (ch == par) continue;
            dfs(dfs, ch, cur);

            int sz = cnt[ch];
            cnt[cur] += sz;
            if (dp[ch][color[cur]]) sz -= dp[ch][color[cur]];
            res[color[cur]].push_back(sz);

            if (dp[cur].size() < dp[ch].size()) swap(dp[cur], dp[ch]);
            for (auto &p : dp[ch]) dp[cur][p.first] += p.second;
        }

        cnt[cur]++;
        dp[cur][color[cur]] = cnt[cur];
    };

    dfs(dfs, 0, -1);
    for (int i = 0; i < n; i++) res[i].push_back(n - dp[0][i]);

    ll total = n * (n + 1) / 2;
    vector <ll> ans(n, total);
    for (int i = 0; i < n; i++) {
        for (ll r : res[i]) {
            ans[i] -= r * (r + 1) / 2;
        }
    }

    for (ll a : ans) cout << a << '\n';
    return 0;
}

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


int main() {
	string s;
	cin>>s;
	ll l=0,r=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='1'){
			l++;
		}
		else{
			r++;
		}
	}
	cout << min(l,r)*2;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

vector<bool> visited,passed;
vi d;

int dfs(vvi &g,int v){
    if(visited[v])return passed[v]?d[v]:-1;
    visited[v]=true;
    for(int u:g[v]){
        int t=dfs(g,u);
        if(t==-1)return -1;
        d[v]=max(d[v],t+1);
    }
    passed[v]=true;
    return d[v];
}

void run(){
    int n;
    cin>>n;
    vvi a(n,vi(n-1));
    rep(i,n)rep(j,n-1)cin>>a[i][j],a[i][j]--;
    int N=n*(n-1)/2;
    vvi b(n,vi(n));
    int id=0;
    rep(i,n)Rep(j,i+1,n)b[i][j]=b[j][i]=id++;
    vvi g(N);
    rep(i,n)rep(j,n-2)g[b[i][a[i][j]]].eb(b[i][a[i][j+1]]);
    visited=vector<bool>(N);
    passed=vector<bool>(N);
    d=vi(N,1);
    int ans=0;
    rep(i,id){
        int t=dfs(g,i);
        if(t==-1){
            cout<<-1<<endl;
            return;
        }
        ans=max(ans,t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 50300
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>

using namespace std;

int main(void){
    int n, k;
    int max, min;
    
    cin >> n >> k;
    
    if(n > k){
        if(n % k == 0){
            cout << 0 << endl;
        }
        else{
            cout << 1 << endl;
        }
    }
    else if(n == k){
        cout << 0 << endl;
    }
    else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
sub f{$_[0]?eval(join'*',1..pop):1}
($N,$P)=glob<>;
++$a[$_%2]for glob<>;
for($i=$P;$i<=$a[1];$i+=2){
	$x+=f($a[1])/(f($a[1]-$i)*f($i))
}
print$x*2**$a[0],$/


Measured memory_bytes: 768
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}
vector<ll> prime_factor(ll n){
	ll sn = sqrt(n)+1;
	auto prime_list = enum_prime(sn);
	vector<ll> res;
	for(int i=0,ei=prime_list.size();i<ei;i++){
		ll v = prime_list[i];
		if(v*v>n) break;
		while(!(n%v)){
			n /= v;
			res.push_back(v);
		}
	}
	if(n>1){
		res.push_back(n);
	}

	sort(ALL(res));
	return res;
}

ll extend_gcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	ll d = extend_gcd(b,a%b,y,x);
	y -= a/b * x;
	return d;
}

ll mod(ll a,ll m){
	return (a%m+m)%m;
}

ll modinv(ll a,ll m){
	ll x,y;
	extend_gcd(a,m,x,y);
	return mod(x,m);
}

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

	int N=in();
	vector<ll> V=vecin<ll>(N),VINV(N);

	map<int,ll> LCM;
	vector<map<int,ll>> VLCM;
	REP(i,N){
		auto res = prime_factor(V[i]);
		map<int,ll> TLCM;
		for(auto& x:res) TLCM[x]++;
		for(auto& x:TLCM){
			LCM[x.first] = max(LCM[x.first],x.second);
		}
		VINV[i] = modinv(V[i],atcoder_mod);
	}

	ll T=1;
	for(auto& x:LCM){
		ll Q=1;
		REP(k,x.second){
			Q *= x.first;
		}
		T *= Q;
		T %= atcoder_mod;
	}


	ll B=0;
	REP(i,N){
		B += (T*VINV[i])%atcoder_mod;
		B %= atcoder_mod;
	}

	out(B);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, m, x, c[12], a[12][12], alg[12];

int getMin(int k, int cst){
	if(k < n){
		int ret = getMin(k + 1, cst);
		for(int i = 0; i < m; i++) alg[i] += a[k][i];
		ret = min(ret, getMin(k + 1, cst + c[k]));
		for(int i = 0; i < m; i++) alg[i] -= a[k][i];
		return ret;
	}else{
		for(int i = 0; i < m; i++)
			if(alg[i] < x) return INT_MAX;
		return cst;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++){
		cin >> c[i];
		for(int j = 0; j < m; j++) cin >> a[i][j];
	}
	int mn = getMin(0, 0);
	cout << ((mn == INT_MAX) ? -1 : mn) << "\n";
	return 0;
}

Measured memory_bytes: 3668
def mod(num):
    return num % (10 ** 9 + 7)

H, W = map(int, input().split())
dp = [[0] * W for _ in range(H)]

for i in range(H):
    a = input()
    for j in range(W):
        if a[j] == "#":
            dp[i][j] = -1

dp[0][0] = 1

for col in range(1, W):
    if dp[0][col] != -1:
        dp[0][col] = dp[0][col - 1]
    else:
        dp[0][col] = 0

for row in range(1, H):
    for col in range(W):
        if dp[row][col] != -1:
            if col == 0:
                dp[row][col] = dp[row - 1][col]
            else:
                dp[row][col] = mod(dp[row - 1][col] + dp[row][col - 1])
        else:
            dp[row][col] = 0

print(dp[-1][-1])

Measured memory_bytes: 82240
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    ma = max(ai)
    k = 0
    for a in ai:
        if a < ma - 1:
            return False
        if a == ma:
            k += 1

    if k == n:
        if ma + 1 == n:
            return True
        elif 1 <= ma <= n // 2:
            return True
        else:
            return False

    if k >= 2 and 1 <= ma - n + k <= k // 2:
        return True
    return False

print("Yes" if main() else "No")


Measured memory_bytes: 14888
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;

int main(void){
    int n;
    cin >> n;
    long *arr = new long[n];
    for(int i = 0; i < n; i++) {
        cin >> arr[i];
        if(arr[i]==0) {
            cout<<"0\n";
            return 0;
        }
    }

    long p = 1;
    for(int i = 0; i < n; i++) {
        if(1000000000000000000/p>=arr[i]) p*=arr[i];
        else {
            cout<<"-1\n";
            return 0;
        }
    }

    cout<<p<<"\n";
    



    return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)

const ll INF = 10010001010;

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

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    int staya=  A;
    while (T != 0)
    {
        T--;
        staya--;
        if(staya == 0){
            ans += B;
            staya = A;
        }
    }
    cout << ans << endl;
}


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

  int n, m, t, p;
  while (1) {
    cin >> n >> m >> t >> p;

    if (n + m + t + p == 0) break;
    vector<vector<int> > paper(33 * 21, vector<int>(33 * 21, 0));
    int ox = 0, oy = 0, dx = n, dy = m;
    rep(i, m) rep(j, n) paper[i][j] += 1;

    rep(_, t) {
      int d, c;
      cin >> d >> c;
      if (d == 1) {
        dx = max(dx, ox + c * 2);
        FOR(i, ox, ox + c) {
          FOR(j, oy, dy) paper[j][2 * ox + 2 * c - 1 - i] += paper[j][i];
        }
        ox += c;
      } else {
        dy = max(dy, oy + c * 2);
        FOR(i, oy, oy + c) {
          FOR(j, ox, dx) paper[2 * oy + 2 * c - 1 - i][j] += paper[i][j];
        }
        oy += c;
      }
    }

    /*
      FOR(i, oy, dy) {
        FOR(j, ox, dx) cout << paper[i][j];
        cout << endl;
      }
      */

    rep(_, p) {
      int x, y;
      cin >> x >> y;
      cout << paper[y + oy][x + ox] << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 4756
N,K = list(map(int,input().split()))
l = [0]*(10**5+1)
for i in range(N):
  a, b = list(map(int,input().split()))
  l[a] += b 
  
for j in range(1,int(len(l))+2):
  if K > l[j]:
    K -= l[j]
  else:
    print(j)
    break


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

int main(){
  int n,m,x; 
  cin >>n >>m >>x;
  int a[12][12];
  vector<int> c(n);
  rep(i,n) {
    cin >>c[i];
    rep(j,m) cin >>a[i][j];
  }
  int ans = 100100100;
  rep(s,1<<n){
    int cost = 0;
    vector<int> d(m);
    rep(i,n){
      if(s>>i&1){
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool can = true;
    rep(j,m){
      if(d[j]<x) can = false;
    }
    if(can) ans = min(ans, cost);
  }
  if(ans==100100100) cout << -1 << endl;
  else cout << ans << endl;
  return 0; 
}

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

bool next(vector<int> &v, int n, int m) {
	for(int i = n-1; i >= 0; i--) {
		if(v[i] < m) {
			v[i]++;
			for(int j = n-1; j > i; j--) { 
				v[j] = v[i];
			}
			return true;
		}
	}
	return false;
}

int main() {
	int n, m, q;
	cin >> n >> m >> q;
	vector<int> a(q), b(q), c(q), d(q);
	rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	vector<int> now(n, 1);
	int ans = 0;
	
	do {
		// rep(i, n) cout << now[i] << " ";
		// cout << endl;
		int tmp = 0;
		rep(i, q) {
			if (now[b[i]-1] - now[a[i]-1]  == c[i]) tmp += d[i];
		}
		ans = max(ans, tmp);
		
	} while (next(now, n, m)) ;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a, b, c;
	int max;
	for (i = 0; i < n; i++)
	{
		scanf("%d%d%d", &a, &b, &c);
		max = a;
		max=max>b ? max : b;
		max=max > c ? max : c;
		if (2 * max*max == a*a + b*b + c*c){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

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

int main(){
  string s;cin>>s;
  int count=0;
  for(int i=0;i<int(s.size());i++){
    if(s[i]=='1'){
      ++count;
    }
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int puz[3][3];
int tmp[3][3];
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
void empty(int *x,int *y) {

  int i,j;

  for(i = 0;i < 3;i ++)
    {
      for(j = 0;j < 3;j ++)
	{
	  if(!puz[i][j])
	    {
	      *x = j;
	      *y = i;

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

  int tmp;
     
  tmp = *a;
  *a = *b;
  *b = tmp;
}
 
 
int cal() {

  int i,a;
  int sum = 0;
     
  for(i = 0;i < 9;i ++)
    {
      a = puz[i/3][i%3];

      if(a){
	a--;

	sum += abs(i/3 - a/3) + abs(i%3 - a%3);

      }
    }
     
  return sum;
}
 
 
int dfs(int x,int y,int p,int dep,const int lim) {

  int i,h,nx,ny,res;
     
  h = cal();

  if(h == 0){
    return dep;
  }
    
  if(dep+h > lim){
    return -1;
  }
    
  for(i = 0;i < 4;i ++)
    {
      nx = x+dx[i];
      ny = y+dy[i];
         
      if(~p && i==(p+2)%4) continue;
      if(!(0 <= nx && nx < 3 && 0 <= ny && ny<3)) continue;
         
      swap(&puz[y][x],&puz[ny][nx]);

      res = dfs(nx,ny,i,dep+1,lim);

      if(~res){
	return res;
      }
	
      swap(&puz[y][x],&puz[ny][nx]);
    }
     
  return -1;
}

 
 
int main() {

  int i,j,ans,x,y,l;
     
   
  for(i = 0;i < 3;i ++)
    {
      for(j = 0;j < 3;j ++)
	{
	  scanf("%d",&puz[i][j]);
	}
    }
     
     
  empty(&x,&y);

  for(l = 0;l < 100;l ++)
    {
      for(i = 0;i < 3;i ++)
	{
	  for(j = 0;j < 3;j ++)
	    {
	      tmp[i][j] = puz[i][j];
	    }
        }
         
      ans = dfs(x,y,-1,0,l);

      if(ans != -1)
	{
	  printf("%d\n",ans);
	  break;
        }
         
      for(i = 0;i < 3;i ++)
	{
	  for(j = 0;j < 3;j ++)
	    {
	      puz[i][j] = tmp[i][j];
	    }
        }
         
      ans = -1;

      if(l == 99){
	printf("%d\n",ans);
      }
    }     
  return 0;
}

Measured memory_bytes: 600
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scanf("%d", &N)
	values := make([]float64, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%f", &values[i])
	}

	sort.Sort(sort.Float64Slice(values))
	var generated float64
	//fmt.Println(values)
	for i := 0; i < N-1; i++ {
		generated = (values[i] + values[i+1]) / 2
		values[i+1] = generated
	}

	fmt.Println(generated)
}


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

#define MAXN 200010
#define ll long long
#define mod 1000000007

using namespace std;

int n, tot;
ll ans;

int a[MAXN];
int c[MAXN];

string s;

int main() {
        int t;
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) {
                scanf("%d", &a[i]);
                c[a[i]]++;
        }
        for (int i = 1; i <= n; i++) {
                ans += (ll)(c[i] - 1) * c[i] / 2;
        }
        for (int i = 1; i <= n; i++) {
                cout << ans - (ll)(c[a[i]] - 1) << endl;
        }
        return 0;
}

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

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

    int cntInput = 1;
    int cntTap = 0;
    while (cntInput < B) {
        cntInput += A - 1;
        cntTap++;
    }
 

    cout << cntTap << 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 a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if ((a*b)%2==0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}

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

import java.util.*;

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

    InputStream in;
    OutputStream out;

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

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }
    
    int n;
    int[] a;
    Edge[] g;

    int[] ans;

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

        // write your code
        n = sc.nextInt();
        a = new int[n];
        g = new Edge[n];
        ans = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            g[i] = new Edge();
        }

        for (int i = 0; i < n - 1; i++) {
            int u = sc.nextInt() - 1, v = sc.nextInt() - 1;
            g[u].add(v);
            g[v].add(u);
        }

        dfs(0, -1, 0, new int[n]);

        for (int i = 0; i < n; i++) {
            out.println(ans[i]);
        }

        out.flush();
    }

    void dfs(int cur, int par, int len, int[] lis) {
        int x = a[cur];
        if (len == 0 || lis[len - 1] < x) {
            int tmp = lis[len];
            lis[len] = x;
            ans[cur] = len + 1;
            for (int next : g[cur]) {
                if (next == par) continue;
                dfs(next, cur, len + 1, lis);
            }
            lis[len] = tmp;
        } else {
            int r = lowerBound(lis, x, len);
            int tmp = lis[r];
            lis[r] = x;
            ans[cur] = len;
            for (int next : g[cur]) {
                if (next == par) continue;
                dfs(next, cur, len, lis);
            }
            lis[r] = tmp;
        }
    }

    public int upperBound(int[] array, int value, int size) {
        int left = -1;
        int right = size;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] > value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }


    public int lowerBound(int[] array, int value, int size) {
        int left = -1;
        int right = size;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] >= value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }
    
    class Edge extends ArrayList<Integer> {};

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

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

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

#define REP(i,a,b) for(int i=a;i<=b;++i)
#define DREP(i,a,b) for(int i=a;i>=b;--i)
typedef long long ll;

using namespace std;

void File(){
	freopen("l.in","r",stdin);
	freopen("l.out","w",stdout);
}

const int maxn=1e5+10;
int n,m,tp;
ll b[maxn],f[maxn],ans[maxn];

int main(){
	//File();
	scanf("%d%d",&n,&m);
	b[++tp]=n;
	REP(i,1,m){
		scanf("%lld",&b[++tp]);
		while(tp>1 && b[tp]<b[tp-1])b[tp-1]=b[tp--];
	}
	f[tp]=1;
	//REP(i,1,tp)cout<<b[i]<<" ";
	//cout<<endl;
	DREP(i,tp-1,0){
		ll len=b[i+1];
		while(len>b[1]){
			int pos=upper_bound(b+1,b+i+1,len)-b-1;
			f[pos]+=len/b[pos]*f[i+1];
			//printf("(%lld %lld) ",len,b[pos]);
			len%=b[pos];
		}
		//cout<<endl;
		//cout<<len<<" "<<f[i+1]<<endl;
		ans[len]+=f[i+1];
	}
	DREP(i,b[1],1)ans[i]+=ans[i+1];
	REP(i,1,n)printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
ll n,m;
vector<ll> vec[300005];
int vis[100005];
ll dist[100005];
void dfs(int a){
	vis[a]=1;
	ll val = 0;
	for(auto it: vec[a]){
		if(!vis[it]){
			dfs(it);
			val = max(dist[it], val);
		}
		else if(dist[it]!=0){
			val = max(dist[it],val);
		}
	}
	dist[a] = val + 1;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    ll i,j,k,c=0,ans=0,t,z,x=0,y;
	cin>>n>>m;
	rep(i,0,m){
		cin>>x>>y;
		vec[x].pb(y);
	}
	for(i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	rep(i,1,n+1){
		ans = max(ans, dist[i]);
	}
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t S;
  cin>>S;
  if(S!=1000000000000000000){
  cout<<0<<" ";
  cout<<0<<" ";
  cout<<1<<" ";
  cout<<1000000000<<" ";
  cout<<S/1000000000+1<<" ";
  cout<<1000000000-S%1000000000<<" ";
  }
  else{
    cout<<0<<" ";
    cout<<0<<" ";
    cout<<0<<" ";
    cout<<1000000000<<" ";
    cout<<1000000000<<" ";
    cout<<0;
  }

}

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

struct Node{
  int key;
  struct Node *right,*left,*parent;
};

struct Node *root,*nil;

void insert(int k){
  struct Node *y = nil;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = nil;
  z->right = nil;

  while(x != nil){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else {
      x = x->right;
    }
  }
  z->parent =y;
  if(y == nil){
    root = z;
  }else{
    if(z->key <y->key){
      y->left = z;
    }else{
      y->right =z;
    }
  }
}

void inorder(struct Node *u){

  if(u == nil)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){

  if(u == nil)return;
  printf(" %d",u->key );
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,x;
  char com[100];
  scanf("%d",&n);


  for(i =0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      scanf("%d",&x);
        insert(x);
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n" );
      
    }
  }
  return 0;

}



Measured memory_bytes: 25128
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   char str[N+1];
   cin>>str;
   int x=0;
   int max=0;
   for(int i=0;i<N;i++){
       if(str[i]=='I') x++;
       else x--;
       if(max<=x) max=x;
   }
   cout<<max;
   return 0;
}


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

int main(void) {

    ll x;
    cin >> x;

    ll money = 100;
    int cnt = 0;
    while (true) {
        if (money >= x) {
            cout << cnt << endl;
            break;
        }
        money *= 1.01;
        cnt++;
    }

    return 0;

}


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

#define warn printf("!!!***!\n")
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
const int maxn=2e6+6;
const int mod=1e9+7;
const int oo=0x3fffffff;
string s,t,u;
int main()
{
     int n,m;
     cin>>s>>t>>n>>m>>u;
     if(u==s) n--;
     if(u==t) m--;
     cout<<n<<' '<<m<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdio>

#include<vector>
using namespace std;
int n;
vector<int> g[233333];
int dist[2][233333],id;
void dfs(int idx,int par=-1){
	if(par!=-1){
		dist[id][idx]=dist[id][par]+1;
	}
	for(int i=0;i<g[idx].size();i++){
		if(g[idx][i]!=par){
			dfs(g[idx][i],idx);
		}
	}
	return;
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		x--;
		y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(n-1);
	int res=0;
	for(int i=0;i<n;i++){
		if(dist[0][i]<=dist[1][i]){
			res++;
		}
	}
	if(res>=n/2+1){
		puts("Fennec");
	}
	else{
		puts("Snuke");
	}
	return 0;
}

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

const long long P = 1000000007;

long long n, m;

long long fact[100004];

int main() {
	fact[0] = fact[1] = 1;
	for(int i = 2; i < 100004; i++) {
		fact[i] = (fact[i - 1] * i) % P;
	}
	scanf("%d%d", &n, &m);
	if(n < m - 1 || m < n - 1) {
		printf("0\n");
	} else {
		if(n == m) {
			printf("%lld\n", (2 * (fact[n] * fact[m]) % P) % P);
		} else {
			printf("%lld\n", (fact[n] * fact[m]) % P);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n+1];
        for (int i=1;i<=n;i++)a[i]=sc.nextInt();
        for (int i=k+1;i<=n;i++){
            if (a[i]>a[i-k])System.out.println("Yes");
            else System.out.println("No");
        }
    }
}


Measured memory_bytes: 60400
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
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; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  string s;
  while (getline(cin, s), s != ".") {
    stack<char> t;
    rep(i, s.size()) {
      if (s[i] == '[' || s[i] == '(') t.push(s[i]);
      if (s[i] == ')') {
        if (t.size() && t.top() == '(') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
      if (s[i] == ']') {
        if (t.size() && t.top() == '[') {
          t.pop();
        } else {
          cout << "no" << endl;
          goto next;
        }
      }
    }
    cout << (t.size() ? "no" : "yes") << endl;
  next:;
  }
}

Measured memory_bytes: 3152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int main()
{
	ll i,j,k,n;
	cin>>n;
	ll x=0;
	if(n%10==7 ||((n/10)%10)==7||((n/100)%10)==7)
	{
		x=1;cout<<"Yes";
	}
	if(x==0) cout<<"No";
    
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
#define ld long double
#define mp(a,b) make_pair(a,b)
int main(){
    int n;
    cin>>n;
    vector<int> x(n),y(n);
    map<pair<int,int>,int> p;
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            //p[{x[j]-x[i], y[j]-y[i]}]++;
            p[mp(x[j]-x[i], y[j]-y[i])]++;
            p[{x[i]-x[j],y[i]-y[j]}]++;
        }
    }
    int ans=0;
    for(auto c:p){
        //cout<<c.first.first<<" "<<c.first.second<<" "<<c.second<<endl;
        int match = c.second;
        ans = max(ans,match);
    }
    cout<<n-ans<<endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
int main(void)
{
	char s[101],t[101];
	int i,j,tmp,n,m;
	scanf("%s%s",s,t);
	n=strlen(s);
	m=strlen(t);
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			if(s[i]>s[j]){
				tmp=s[i];
				s[i]=s[j];
				s[j]=tmp;
			}
		}
	}
	for(i=0; i<m; i++){
		for(j=i+1; j<m; j++){
			if(t[i]<t[j]){
				tmp=t[i];
				t[i]=t[j];
				t[j]=tmp;
			}
		}
	}
	if(strcmp(s,t)<0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    map <string,int> mps;
    set <string> vec;
    map <int,int> finmap;

    int n;
    cin>>n;
    int cnt=1;
    for(int i=0; i<n; ++i)
    {
    	string s;int x;
    	cin>>s>>x;
    	finmap[x]=i+1;
    	if(mps[s]==0)
    	{
    		mps[s]=cnt;
    		++cnt;
    	}
    	vec.insert(s);
    	adj[mps[s]].pb(x);
    }
    for(int i=1; i<100001; ++i)
    {
    	sort(all(adj[i]));
    }
    for(auto x : vec)
    {
    	for(int j=adj[mps[x]].size()-1; j>=0; --j)
    	{
    		cout<<finmap[adj[mps[x]][j]]<<"\n";
    	}

    }


}

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

void insertionSort(int A[],int n,int g,int *cnt){
	int v,j,c=0;
	for(int i=g;i<n;i++){
		v=A[i];
		j=i-g;
		while(j>=0 && A[j]>v){
			A[j+g]=A[j];
			j=j-g;
			c++;
		}
		A[j+g]=v;
	}
	*cnt+=c;
}

int calc_m(int n){
	int m=0;
	int c=0;
	while(1){
		if(((m*3)+1)>n){
			break;
		}
		m=((m*3)+1);
		c++;
	}
	
	return c;
}

void shellSort(int A[],int n){
	//printf("\n\n");
	int cnt=0;
	int m=calc_m(n);
	int *G=(int*)malloc(sizeof(int)*m),g=0;

	for(int i=(m-1);i>=0;i--){
		G[i]=((g*3)+1);
		g=G[i];
	}
	
	for(int i=0;i<m;i++){
		insertionSort(A,n,G[i],&cnt);
	}
	
	printf("%d\n",m);
	for(int i=0;i<m;i++){
		printf("%d",G[i]);
		if(i==(m-1)){
			printf("\n");
		}else{
			printf(" ");
		}
	}
	printf("%d\n",cnt);
	for(int i=0;i<n;i++){
		printf("%d\n",A[i]);
	}
}

int main(){
    int n;
	int *A;

	scanf("%d",&n);
	A=(int*)malloc(sizeof(int)*n);
	for(int i=0;i<n;i++){
		scanf("%d",&A[i]);
	}

	shellSort(A,n);

	return 0;
}


Measured memory_bytes: 5608
#include <stdio.h>

int n, b[200], ans[200];

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", b + i);
		if(b[i] > i + 1){
			puts("-1");
			return 0;
		}
	}
	for(int i = n; i; --i){
		for(int j = i - 1, bt = 0; j >= 0; --j){
			if(b[j] == j + 1){
				ans[i - 1] = b[j];
				b[j] = bt;
				break;
			}else{
				int tmp = b[j];
				b[j] = bt;
				bt = tmp;
			}
		}
	}
	for(int i = 0; i < n; ++i) printf("%d\n", ans[i]);
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
#define MIN(a, b) ( ( (a) < (b) )? (a) : (b) )
#define MAX(a, b) ( ( (a) < (b) )? (b) : (a) )

int main()
{
    int N, M;
    cin >> N >> M;
    int Lmax = 1, Rmin = N;
    int Ltmp, Rtmp;
    for(int i = 0; i < M; ++i) {
        cin >> Ltmp >> Rtmp;
        Lmax = MAX(Ltmp, Lmax);
        Rmin = MIN(Rtmp, Rmin);
    }
    if(Rmin < Lmax) { cout << 0 << endl; }
    else { cout << Rmin - Lmax + 1 << endl; }
    return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE Strict #-}
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as V

main :: IO ()
main = do
  n <- readLn
  as <- readIntsLn
  bs <- readIntsLn
  print $ solve n as bs

solve :: Int -> V.Vector Int -> V.Vector Int -> Int
solve _ as bs = snd $ V.foldl f ((V.head as), 0) $ V.zip (V.tail as) bs

f :: (Int, Int) -> (Int, Int) -> (Int, Int)
f (a1, s) (a2, b) = (a2', s')
  where a1' = max 0 (a1 - b)
        a2' = max 0 (a2 - (b - d1))
        d1 = a1 - a1'
        d2 = a2 - a2'
        s' = s + d1 + d2

readIntsLn :: IO (V.Vector Int)
readIntsLn = V.unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine


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

typedef int MYDATA;

struct CELL{
	struct CELL* prev;
	struct CELL* next;
	MYDATA value;
};

struct CELL head;

void init();
void insertFirst(MYDATA x);
void insertLast(MYDATA x);
void delete(MYDATA x);
void deleteFirst();
void deleteLast();
void deleteAll();

int main(void){
	struct CELL *p;
	int i,n;
	char s[20];
	MYDATA data;

	init();

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%s",s);
		if(!strcmp(s,"insert")){
				scanf("%d",&data);
				insertFirst(data);
		}else if(!strcmp(s,"delete")){
				scanf("%d",&data);
				delete(data);
		}else if(!strcmp(s,"deleteFirst")){
				deleteFirst();
		}else if(!strcmp(s,"deleteLast")){
				deleteLast();
		}
	}

	for(p = head.next;p != (&head)->prev; p = p->next)
		printf("%d ", p->value);

	
	printf("%d\n", p->value);

	return 0;
}

void init(){
	head.prev = head.next = &head;
}

void insertFirst(MYDATA x){
	struct CELL *temp;

	temp=(struct CELL*)malloc(sizeof(struct CELL));

	temp->value = x;
	temp->prev = &head;
	temp->next = head.next;
	(&head)->next->prev = temp;
	head.next = temp;
}

void insertLast(MYDATA x){
	struct CELL *temp;

	temp=(struct CELL*)malloc(sizeof(struct CELL));

	temp->value = x;
	temp->prev = head.prev;
	temp->next = &head;
	(&head)->prev->next = temp;
	head.prev = temp;
}

void delete(MYDATA x){
	struct CELL *p;

	for(p = head.next;p != &head; p = p->next){
		if(p->value==x){
			p->prev->next = p->next;
			p->next->prev = p->prev;
			break;
		}
	}
}

void deleteFirst(){
	(&head)->next = (&head)->next->next;
	(&head)->next->prev = &head;
}

void deleteLast(){
	(&head)->prev = (&head)->prev->prev;
	(&head)->prev->next = &head;
}

void deleteAll(){
	init();
}

Measured memory_bytes: 34972