akhauriyash/Code-Regression huggingface dataset:
#include <set>
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    string S; int n;
    
    set<string> T;
    
    scanf("%d", &n);
    
    while(n--)
    {
        cin >> S;
        
        int c = 0;
        
        for(int i = 1; i < S.size(); i++)
        {
            c += (S[i - 1] == S[i] ? 1 : 0);
        }
        
        if(c + 1 == S.size())
        {
            printf("1\n");
        }
        else
        {
            T.clear();
            
            for(int j = 1; j < S.size(); j++)
            {
                string A = S.substr(0, j);
                string B = S.substr(j, S.size() - j);
                
                string C = A; reverse(C.begin(), C.end());
                string D = B; reverse(D.begin(), D.end());
                
                T.insert(A + B);
                T.insert(B + A);
                T.insert(A + D);
                T.insert(D + A);
                T.insert(C + B);
                T.insert(B + C);
                T.insert(C + D);
                T.insert(D + C);
            }
            
            printf("%d\n", T.size());
        }
    }
    
    return 0;
}

Measured memory_bytes: 1328
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

int main() {
	char S[20];
	string T;
	string p;
	string Q;
	double m;
	int a = 0;
	int A = 0;
	int b = 0;
	int B = 0;
	int c = 0;
	int C = 0;
	int q, w, z;
	int n = 0;
	int x = 0;
	int y = 0;
	int ans = 0;
	cin >> a >> b;
	if (a <= 5) {
		cout << 0;
	}
	else if (a <= 12) {
		cout << b / 2;
	}
	else {
		cout << b;
	}

}

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

int main(){
	int a, b;
	string op;
	
	for (;;){
		cin >> a >> op >> b;
		if ( op == "?") break;
		if ( op == "+" ){
			cout << a + b << endl;
		} else if ( op == "-" ){
			cout << a - b << endl;
		} else if ( op == "*" ){
			cout << a * b << endl;
		} else {
			cout << a / b << endl;
		}
	}
return 0;
}


Measured memory_bytes: 3148
s=input()[::-1];t=input()[::-1]
l=len(t)
for i in range(len(s)-l+1):
	f=1
	for j,k in enumerate(s[i:i+l]):
		if "?"!=k!=t[j]:
			f=0;break
	if f:
		s=s[:i]+t+s[i+l:]
		print(s.replace("?","a")[::-1])
		exit()
print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
ll inf = 1e9;
ll r, c, sy, sx, gy, gx, dis[55][55], nx, ny;
ll dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
char yan[55][55];
ll habatan() {
	queue<P> yojo;
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) dis[i][j] = inf;
	}
	yojo.push(P(sx, sy));
	dis[sx][sy] = 1;
	while (!yojo.empty()) {
		P siri = yojo.front();
		yojo.pop();
		if (siri.first == gx && siri.second == gy)break;
		for (int i = 0; i < 4; i++) {
			nx = siri.first + dx[i], ny = siri.second + dy[i];
			if (nx&&ny&&yan[nx][ny] == '#'&&dis[nx][ny] == inf) {
				yojo.push(P(nx, ny));
				dis[nx][ny] = dis[siri.first][siri.second] + 1;
			}
		}
	}
	return dis[gx][gy];
}
int main() {

	cin >> r >> c;
	sx = sy = 1;
	gx = r; gy = c;
	ll cnt = 0;
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> yan[i][j];
			if (yan[i][j] == '#')cnt++;
		}
	}
	for (int i = 0; i <= r + 1; i++)yan[0][i] = yan[r + 1][i] = '.';
	for (int i = 0; i <= c + 1; i++)yan[i][0] = yan[i][c + 1] = '.';
	if (habatan() == cnt && cnt == r + c - 1)cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a[13]={};
    char b[13];
    int sum=0,x,ans,count=0;
    cin>>b;
    for(int i=0;i<12;i++){
        if(b[i]=='?'){x=i;
        }else{a[i]=b[i]-'0';}
    }
    for(int i=0;i<10;i++){
        a[x]=i;
        sum=a[0]*6+a[1]*5+a[2]*4+a[3]*3+a[4]*2+a[5]*7+a[6]*6+a[7]*5+a[8]*4+a[9]*3+a[10]*2;
        if(a[11]==11-(sum%11)){
            count++;
            ans=i;
        }else if(sum%11<=1&&a[11]==0){
            count++;
            ans=i;
        }
    }
    if(count>1){
        cout<<"MULTIPLE"<<endl;

    }else{cout<<ans<<endl;}


}



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

const int maxn = 100010;
int n, m, q, a[maxn];
bool mark[maxn][11];
vector<int> G[maxn];
vector<tuple<int, int, int>> Q;

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1, u, v; i <= m; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    scanf("%d", &q);
    for (int i = 1, v, d, c; i <= q; i++) {
        scanf("%d %d %d", &v, &d, &c);
        Q.push_back(make_tuple(v, d, c));
    }
    reverse(Q.begin(), Q.end());
    for (auto p : Q) {
        int v = get<0>(p), d = get<1>(p), c = get<2>(p);
        function<void(int, int)> dfs = [&](int v, int d) {
            if (mark[v][d]) return;
            mark[v][d] = 1;
            if (!d) { a[v] = c; return; }
            dfs(v, d - 1);
            for (int u : G[v]) dfs(u, d - 1);
        };
        dfs(v, d);
    }
    for (int i = 1; i <= n; i++) {
        printf("%d\n", a[i]);
    }
    return 0;
}

Measured memory_bytes: 12272
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int x;
	cin >> x;
	int count=0;
	for (long long int i = 0; i < 301; ++i)
	{
	   if(count!=0){
	       break;
	   }
	   else{
		long long int a=i*i*i*i*i;
		for (long long int j = -301; j < 301; ++j)
		{
			long long int b = j*j*j*j*j;
			if(a-b==x){
				cout << i <<" " << j << endl;
				count++;
				break;
			}
			
		}
	   }
	    

	}
}

Measured memory_bytes: 3624
# ABC152a


def main():
    import sys
    input = sys.stdin.readline

    sys.setrecursionlimit(10 ** 6)
    n, m = map(int, input().split())
    if n == m:
        print('Yes')
        exit(0)
    print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
n,m,v,p = map(int,input().split())
a = list(map(int, input().split()))

a.sort()

l = -1
r = n-1
while r-l>1:
    i = (l+r)//2
    flag = 1
    if a[i]+m<a[n-p]:
        flag = 0
    elif i+p-1>=v:
        flag = 1
    else:
        rest = (v-i-p)*m
        for j in range(i+1,n-p+1):
            rest -= min(m,a[i]+m-a[j])
        if rest<=0:
            flag = 1
        else:
            flag = 0
    if flag:
        r = i
    else:
        l = i

print(n-r)




Measured memory_bytes: 62576
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;cin >> n;
  vi l(n,0);
  rep(i,n) cin >> l.at(i);

  int ans = 0;
  rep(i,n) srep(j,i+1,n) {
    srep(k,j+1,n) {
      int a = l.at(i),b=l.at(j),c=l.at(k);
      if(a+b > c and b+c > a and c+a > b and a != b and b!=c and c!=a) ans++;
    }
  }

  cout << ans << endl;


  return 0;
}


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

int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

int myMatch(char A[100][100], char B[100][100], int N, int M, int i, int j){
    for(int k=0;k<M;k++){
        if(memcmp(A[i+k]+j,B[k],M))
            return 1;
    }
    return 0;
}


int main(void){
    int N,M;
    char A[100][100]={},B[100][100]={};

    scanf("%d %d%*c",&N,&M);
    for(int i=0;i<N;i++){
        my_gets(A[i],100,stdin);
    }
    for(int i=0;i<M;i++)
        my_gets(B[i],100,stdin);
    
    for(int i=0; i <= N-M; i++){
        char *ptr=A[i];

        //printf("i:%d\n",i);
        while((ptr=strstr(ptr,B[0]))!=NULL ){
            if(myMatch(A, B, N, M, i, (int)(ptr-A[i])) == 0){
                puts("Yes");
                return 0;
            }
            ptr++;
        }
    }
    puts("No");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    string S;
    cin >> N >> S;
    int cnt[26] = {};
    for(int i = 0; i < S.size(); i++) {
        cnt[S[i]-'a']++;
    }
    int ans = 1;
    for(int i = 0; i < 26; i++) {
        ans*=(cnt[i]+1);
        ans = ans%INF;
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 3740
/*siddharth goyal*/
#include<bits/stdc++.h>
using namespace std;
#define   pb              push_back
#define   REP(i,n)        for(i=1;i<=n;i++)
#define   FOR(i,a,b)      for(i=a;i<=b;i++)
#define   all(v)          v.begin(),v.end()
#define   F               first
#define   S               second
#define   vl              vector<LL>
#define   itr             ::iterator it
#define   lb              lower_bound
#define   ub              upper_bound
#define   LL              long long
#define   ULL             unsigned long long
LL n,i,j,ans = 0;
int main()
{   // Read the constraints,highlights,Time Limit,Test Cases
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s ;
    cin>>s ; 
    if(s.length()==2) cout<<s ; 
    else 
    {
        reverse(all(s)) ; 
        cout<<s ; 
    }
}
//Check for 0,1 and other corner cases.

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

int a,b;

int main(){
    cin>>a>>b;
    if(a==1)a+=13;
    if(b==1)b+=13;
    if(a>b)out("Alice");
    else if(a==b)out("Draw");
    else out("Bob");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b, c;
    cin >> a >> b >> c ;
    
    //*
    if(b - a == c - b){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    //*/
    
    //cout << ( a + b ) % 24 << endl;

    return 0; 
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int n,k;
Vi a,dp;

int f(int now){
    if(dp[now]!=-1) return dp[now];
    int win=0;
    REP(i,0,n){
        if(now-a[i]<0) continue;
        if(f(now-a[i])==0) win=1;
    }
    return dp[now]=win;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    cin>>n>>k;
    a.resize(n);
    REP(i,0,n) cin>>a[i];

    dp.resize(k+1,-1);
    dp[0]=0;
    // REP(i,1,k+1){
    //     int win=0;
    //     REP(j,0,n){
    //         if(i-a[j]<0) continue;
    //         if(dp[i-a[j]]==0) win=1;
    //     }
    //     dp[i]=win;
    // }
    // f(k);
    // vout(dp);
    if(f(k)==1) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 5760
#include<iostream>
#include<cmath>

using namespace std;

int happy[3];
int buf[3];
int v[3];
int n;

int main() {
    cin >> n;
    happy[0] = happy[1] = happy[2] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[0] >> v[1] >> v[2];
        buf[0] = v[0] + max(happy[1], happy[2]);
        buf[1] = v[1] + max(happy[0], happy[2]);
        buf[2] = v[2] + max(happy[0], happy[1]);
        happy[0] = buf[0];
        happy[1] = buf[1];
        happy[2] = buf[2];
    }
    cout << max({happy[0], happy[1], happy[2]}) << endl;
}


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

int main(){
  int n, a, b, c, d;
  cin>>n;
  d=n%10;
  n/=10;
  c=n%10;
  n/=10;
  b=n%10;
  n/=10;
  a=n;

  while(true){
    if(a+b+c+d==7){
      cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
      break;
    }
    if(a+b+c-d==7){
      cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
      break;
    }
    if(a+b-c+d==7){
      cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
      break;
    }
    if(a-b+c+d==7){
      cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<7<<endl;
      break;
    }
    if(a+b-c-d==7){
      cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
      break;
    }
    if(a-b-c+d==7){
      cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<7<<endl;
      break;
    }
    if(a-b+c-d==7){
      cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<7<<endl;
      break;
    }
    if(a-b-c-d==7){
      cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<7<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
using namespace std;
int main() {
    string N;
    cin>>N;
    int slength = N.length();
    int sum = 0;
    for(int i = 0; i < slength; i++){
        sum = sum + N[i] -'0';//'0'はマジックナンバー。内部表現数値からchar '0'(48)を引くとchar'N'は数字になるという寸法。
    }
    // cout << slength <<endl;
    if(sum%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef deque<int> DI;
typedef deque<LL> DLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

const LL MAXN = 2e5+10;
LL N, K, A[MAXN];

bool predicate(LL val) {
	LL ans = 0;
	rep(i, 0, N) {
		LL y = A[i];
		if(y < 0) {
			// A[j] is the first element for which A[j] * A[i] <= val and also for all A[j..N-1]
			LL j = (partition_point(A, A+N, [&y, &val](LL x) { return (x * y) > val; }) - A);
			if(j <= i)	ans += N - i - 1; // j <= i then only count elements after i excluding i
			else	ans += N - j; // otherwise count all elements after j including j
		}
		else if(y >= 0) {
			// A[j] is the last element for which A[j] * A[i] <= val so also for all A[0..j]
			LL j = (partition_point(A, A+N, [&y, &val](LL x) { return (x * y) <= val; }) - A) - 1;
			if(j > i)	ans += (j-i); // only count elements which come after A[i] exluding A[i]
		}
	}
	// cout << val << " " << ans << endl;
	return ans >= K;
} 

int main() {
	N = scanLong(); K = scanLong();
	rep(i, 0, N)	A[i] = scanLong();
	sort(A, A+N);

	LL low = -(1e18+10), high = 1e18+10;
	while(low < high) {
		LL mid = (low + high) >> 1;
		// cout << low << " " << mid << " " << high << endl;
		if(predicate(mid))	high = mid;
		else	low = mid+1;
		// cout << "-----" << endl;
	}
	pll(high); nl;
}


Measured memory_bytes: 1792
# coding: utf-8
n = int(input().rstrip())
S = list(map(int,input().rstrip().split()))
q = int(input().rstrip())
T = list(map(int,input().rstrip().split()))
count = 0
for i in range(q):
    if T[i] in S:
        count+=1

print(count)


Measured memory_bytes: 6320
n,a,b = list(map(int, input().split()))
sum = 0
for i in range(n+1):
  qu = i//10000
  th = (i%10000)//1000
  hu = (i%1000)//100
  te = (i%100)//10
  on = i%10
  m = qu+th+hu+te+on
  if a<=m<=b:
    sum += i
print(sum)

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

void solve(long long X){
    ll n_500 = X /500;
    ll n_5 = (X - (X/500) * 500)/5;
    printf("%lld\n",1000 * n_500 + 5 * n_5);

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const long double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m,l;
    cin >> n >> m >> l;
    vector<long double> p(n),t(n),v(n);
    rep(i,0,n){
        cin >> p[i] >> t[i] >> v[i];
        if(v[i]==0) v[i]=1e-12;
    }

    ll comb[51][51]={};
    rep(i,0,51){
        comb[i][i]=1;
        comb[i][0]=1;
    }
    rep(i,1,51) rep(j,1,i){
        if(i>0 and i>j) comb[i][j]+=comb[i-1][j];
        if(j>0) comb[i][j]+=comb[i-1][j-1];
    }

    vector<unordered_map<int,long double>> x(n);
    rep(i,0,n) rep(j,0,m+1) x[i][t[i]*j]+=powl((100-p[i])/100,m-j)*comb[m][j]*powl(p[i]/100,j);
    rep(i,0,n){
        long double s1=0;
        for(const auto& p1:x[i]){
            long double tmp=p1.second;
            rep(j,0,n){
                if(j==i) continue;
                long double s2=0;
                for(const auto& p2:x[j]) if(p2.first+l/v[j]>p1.first+l/v[i]) s2+=p2.second;
                tmp*=s2;
            }
            s1+=tmp;
        }
        cout << fixed << setprecision(8) << s1 << endl;
    }
}

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

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

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

Measured memory_bytes: 4048
#include<stdio.h>
int main(void){//float?????????double???
int i,j,h,w,a;
a=1;

while(a==1){
scanf("%d %d",&h,&w);
if(h==0&&w==0){
	break;
}
for(i=1;i<=h;i++){
	 for(j=1;j<=w;j++){
		if((i>=2&&j>=2)&&(i!=h&&j!=w)) printf(".");
		else printf("#");
	}
	printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 1744
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        mut a_vec: [i64; n],
    }

    for _ in 0..k {
        let mut b: Vec<i64> = vec![0; n + 1];
        for (i, d) in (0_i64..).zip(a_vec.iter()) {
            let l = std::cmp::max(0, i - d) as usize;
            let r = std::cmp::min(i + d + 1, n as i64) as usize;
            b[l] += 1;
            b[r] -= 1;
        }
        for i in 0..n {
            b[i + 1] += b[i];
        }
        b.pop();
        if a_vec == b {
            break;
        }
        a_vec = b;
    }
    for a in a_vec {
        println!("{} ", a);
    }
}


Measured memory_bytes: 6536
#include <bits/stdc++.h>
using namespace std; 
int n,m,k,arr[20][20],sum[20],c[20],ans;

string s,t;
int main(){
    cin>>n>>m>>k;
    for(int i =1;i<=n;i++){
        cin>>c[i];
        for(int j =1;j<=m;j++){
            cin>>arr[i][j];
            sum[j]+=arr[i][j];
        }
    }
    bool sabi=1;
    for(int i =1;i<=m;i++){
        if(sum[i]<k)sabi=0;
    }
    if(!sabi){
        cout<<-1<<endl;
        return 0;
    }
    ans=1e9;
    for(int i =1;i<=(1<<n)-1;i++){
        int cnt=1;
        int tmp=i;
        int cost=0;
        vector<long long> jml(m+5);
        while(tmp>0){
            if(tmp%2==1){
                for(int j =1;j<=m;j++){
                    jml[j]+=arr[cnt][j];
                }
                cost+=c[cnt];
            }
            cnt++;
            tmp/=2;
        }
        sabi=1;
        for(int j =1;j<=m;j++){
            if(jml[j]<k)sabi=0;
        }
        if(sabi)ans = min(ans,cost);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#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(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible" << endl;
	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}
 

Measured memory_bytes: 504
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int price[20];
int a[20][20];

const int MAX = 1000000000;

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    for (int i = 0; i < n; i++) {
        cin >> price[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    int ans = MAX;
    for (int s = 0; s < (1 << n); s++) {
        int skill[20];
        int p = 0;
        memset(skill, 0, sizeof(skill));
        for (int i = 0; i < n; i++) {
            if (s & (1 << i)) {
                p += price[i];
                for (int j = 0; j < m; j++) {
                    skill[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for (int i = 0; i < m; i++) {
            if (skill[i] < x) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = min(ans, p);
        }
    }
    if (ans == MAX) {
        printf("-1\n");
    } else {
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 3764
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [i32; n],
    }

    l.sort();
    let max = *l.iter().last().unwrap();
    let sum_without_max: i32 = l.iter().sum::<i32>() - max;

    if max < sum_without_max {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2140
#include <iostream>
#include<algorithm>
using namespace std;
int d[551][551];
int n,m,q;
void updata(int x,int y)
{
	int t;
	while(x>0)
	{
		t=y;
		while(t<=n)
		{
			d[x][t]++;
			t+=t&-t;
		}
		x-=x&-x;
	}
}
int que(int x,int y)
{
	int sum=0;
	int t;
	while(x<=n)
	{
		t=y;
		while(t>0)
		{
			sum+=d[x][t];
			t-=t&-t;
		}
		x+=x&-x;
	}
	return sum;
}
int main(int argc, char *argv[])
{
	cin>>n>>m>>q;
	int a,b;
	for(int i=1;i<=m;i++)
	{
		cin>>a>>b;
		updata(a,b);
	}
	for(int i=0;i<q;i++)
	{
		cin>>a>>b;
		cout<<que(a,b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 4632
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
ll solve(vector<vector<ll>> &graph, vector<ll>&dp, ll node){

    if(dp[node]!=-1)
        return dp[node];

    //db(node);

    ll ans = 0;
    for(auto child : graph[node]){
        ll temp = solve(graph,dp,child);
        ans=max(ans,1+temp);
    }
    return dp[node]=ans;
}


void solve(){

    ll n,m;
    cin>>n>>m;
    char mat[n][m];
    rep(i,n){
        rep(j,m){
            cin>>mat[i][j];
        }
    }

    ll dp[n][m];
    dp[n-1][m-1]=1;

    repD(i,n-2,0){
        if(mat[i][m-1]=='.')
            dp[i][m-1] = dp[i+1][m-1];
        else
            dp[i][m-1] = 0;
    }

    repD(i,m-2,0){
        if(mat[n-1][i]=='.')
            dp[n-1][i] = dp[n-1][i+1];
        else
            dp[n-1][i] = 0;
    }

    //ll mod = 1e9+7;

    repD(i,n-2,0){
        repD(j,m-2,0){
            if(mat[i][j]=='.'){
                dp[i][j] = (dp[i+1][j]%mod+dp[i][j+1]%mod)%mod;
            }
            else{
                dp[i][j] = 0;
            }
        }
    }

    db1(dp[0][0]);

}
int main(){ 

int t=1;
//cin>>t;
while(t--){
 solve();
}
  return 0; 
}





Measured memory_bytes: 9088
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	int ret = 0;
	if(2 * C < A + B){
		int a = min(X, Y);
		ret += 2 * C * a;
		X -= a;
		Y -= a;
	}

	if(2 * C < A) ret += 2 * C * X;
	else ret += A * X;
	if(2 * C < B) ret += 2 * C * Y;
	else ret += B * Y;

	cout << ret << endl;
	return 0;
}

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

int main(){
  int N; cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++) cin >> a[i];
  
  int sum=0;
  for(int i=0; i<N; i++){
    sum^=a[i];
  }
  for(int i=0; i<N; i++){
    cout << (a[i]^sum);
    if(i==N-1) cout << endl;
    else cout << " ";
  }
}

Measured memory_bytes: 3972
from collections import deque
 
H, W = map(int, input().split())
S = [list(input().split()[0]) for _ in range(H)]


def bfs(S, H, W, start):
    INF = -1
    stack=deque([start])
    distance = [[INF]*W for _ in range(H)]
    distance[start[1]][start[0]] = 0
    while stack:
        x, y = stack.popleft()
        for i, j in [(1,0),(0,1),(-1,0),(0,-1)]:
            next_x = x + i
            next_y = y + j
            if not(0 <= next_x < W and 0 <= next_y < H):
                continue
            if S[next_y][next_x] != '#' and distance[next_y][next_x] == -1:
                stack.append([next_x, next_y])
                distance[next_y][next_x] = distance[y][x] + 1
    return max(map(max, distance))
 
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != "#":
            ans = max(ans, bfs(S, H, W, (j, i)))
print(ans)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args){
        int N;
        Scanner sc = new Scanner (System.in);
        N = sc.nextInt();
        Map <Integer, Integer> mp = new HashMap<Integer, Integer>();
        int h;
        for (int i=1; i<=N; i++){
            h = sc.nextInt();
            mp.put(h, i);
        }
        for (int i=1; i<=N; i++){
            System.out.print(mp.get(i)+" ");
        }
        System.out.println();
    }
}

Measured memory_bytes: 72460
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main() {
  lli A,B,C,D,E,F,N,M,K,sum=0,num=0,ans=0;
  cin >> N;
  string S;cin>>S;
  if(N>3199)Out(S);
  else Out("red");
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        int num = 0;
        if(n%2==0){
            num = n/2;
           // System.out.println(n);
        }else{
            num = n/2+1;
        }

        System.out.println(num);
    }
}

Measured memory_bytes: 21844
from sys import stdin
n = int(stdin.readline())
M = [None] + [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [None] + [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
    global tt
    sndf[u][0] = True
    tt += 1
    sndf[u].append(tt)
    for v in M[u]:
        if not sndf[v][0]:
            dfs(v)
    tt += 1
    sndf[u].append(tt)
for i in range(1, n + 1):
    if not sndf[i][0]:
        dfs(i)
    print(*sndf[i][1:])

Measured memory_bytes: 7784
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define t int t;scanf("%d",&t);for(int v=1;v<=t;v++)
#define loop_arr(i,a,b) for(int i=a;i<b;i++)
#define loop_norm(i,a,b) for(int i=a;i<=b;i++)
#define minheap priority_queue<int,vector<int>,greater<int> >
#define maaheap priority_queue<int>
#define pb push_back()
#define pop pop_back()
ll BIGMOD ( ll a, ll p, ll m )
{
    ll result = 1;
    ll x = a;

    while ( p )
    {
        if ( p & 1 ) //p is odd
        {
            result = ( result * x ) % m;
        }
        x = ( x * x ) % m;
        p = p >> 1;
    }

    return result;
}

bool isPrime(int n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int main()
{
   //fastread;
   int n;
   cin>>n;
   string str;
   cin>>str;
   for(int i=0;i<str.length();i++)
   {
       str[i]='A'+((str[i]-'A')+n)%26;
       cout<<str[i];
   }
   cout<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int c,n,m,i,j,t,d[103],queue[1000];
	for(;scanf("%d %d",&n,&m)&&(n||m);){
		c=0;
		for(i=0;i<103;i++)d[i]=0;
		for(i=0;i<n;i++){
			for(j=0;j<m;j++){
				scanf("%d",&t);
				if(t)d[j+1]++;
			}
		}
		for(i=0;i<=1000;i++){
			for(j=m;j>0;j--){
				if(d[j]==i){
					queue[c]=j;
					c++;
				}
			}
		}
		for(i=c-1;i>=0;i--){
			if(i-c+1)printf(" ");
			printf("%d",queue[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  int c = a * b;
 
  if (c % 2 == 0) {
    cout << "Even" << endl;
  } else {
     cout << "Odd" << endl;
  }
}

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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    cout<<x2-(y2-y1)<<" "<<y2+(x2-x1)<<" "<<x1-(y2-y1)<<" "<<y1+(x2-x1)<<"\n";
    
}

Measured memory_bytes: 3648
n = int(input())

m = 0
c = [0, 3, 5, 7]
count = 0

def p753(m):
    i = 0
    s = 0 if m > 0 else c[0]
    while m > 0:
        s += 10**i * c[m % 4]
        i += 1
        m = m // 4
    return s

p = p753(m)

while p <= n:
    mt = m
    f = [False, False, False, False]
    
    while mt > 0:
        f[mt % 4] = True
        if mt % 4 == 0:
            break
        mt = mt // 4
    if (not f[0]) and f[1] and f[2] and f[3]:
        count += 1
    m += 1
    p = p753(m)

print(count)

Measured memory_bytes: 3064
N,L = gets.split.map &:to_i

if L > 0
  puts (L+1).upto(L+N-1).inject(:+)
elsif L + N - 1 <= 0
  puts L.upto(L+N-2).inject(:+)
else
  puts L.upto(L+N-1).inject(:+)
end

Measured memory_bytes: 3836
#include<iostream>
using namespace std;
int main()
{
    int n,k,q=0;
    cin>>n>>k;
    int array[n];
    for(int i=0;i<n;i++){
        cin>>array[i];
        if(array[i]>=k){
            q++;
            }
    }
    cout<<q<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

void yes() {
  printf("Yes\n");
  exit(0);
}

void no() {
  printf("No\n");
  exit(0);
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  rep (i, n+1) {
    int lv = k - (i * m);
    if (lv == 0) {
      yes();
    }
    int df = (n - i) - i;
    if (df == 0) {
      continue;
    }
    if (lv * df < 0) {
      continue;
    }
    if (lv < 0) {
      lv *= (-1);
      df *= (-1);
    }
    if (lv % df == 0) {
      if (lv / df <= m) {
        yes();
      }
    }
  }
  no();
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MOD 10000
using namespace std;

int main() {
	int n, k, d[100], dp[100][3][3];
	scanf("%d%d", &n, &k);
	memset(d, -1, sizeof(d));
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < k; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		d[a - 1] = b - 1;
	}
	if (~d[0]) dp[0][d[0]][1] = 1;
	else { dp[0][0][1] = dp[0][1][1] = dp[0][2][1] = 1; }
	for (int i = 1; i < n; i++) {//day
		for (int j = 0; j < 3; j++){//pasta(today)
			for (int t = 0; t < 3; t++){//pasta(yesterday)
				for (int p = 0; p < 3; p++){//count(yesterday)
					if (~d[i] && d[i] != j)continue;
					int cnt = 1;
					if (j == t)cnt = p + 1;
					if (cnt >= 3)continue;
					dp[i][j][cnt] = (dp[i][j][cnt] + dp[i - 1][t][p]) % MOD;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			sum = (sum + dp[n - 1][i][j]) % MOD;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 2608
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
s = input()
lis = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(lis)):
    if lis[i] in s:
        pass
    else:
        print(lis[i])
        exit()
print('None')


Measured memory_bytes: 10296
import sys
from collections import deque
 
 
def bfs(H, W, maze, visited, sharp):
    queue = deque([[0, 0]])
    visited[0][0] = 0
    while queue:
        y, x = queue.popleft()
        if[y, x] == [H-1, W-1]:
            return ((H*W-sharp)-(visited[y][x]+1))
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            new_y, new_x = y+j, x+k
            if  new_y != -1 and new_y != H and  \
                new_x != -1 and new_x != W and  \
                maze[new_y][new_x] == "." and   \
                visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
 
    return -1
 

def main():
    sharp = 0
 
    H, W = map(int,input().split())
    maze = [input() for i in range(H)]
    visited = [[-1]*W for j in range(H)]
 
    for k in range(H):
        sharp += maze[k].count('#')
 
    print(bfs(H, W, maze, visited, sharp))
 
main()

Measured memory_bytes: 3316
S = input()
X, Y = [int(_) for _ in input().split()]
V = [[0], [0]]
d = 0
f = 1
for s in S:
    if s == 'F':
        if f:
            X -= 1
        else:
            V[d][-1] += 1
    else:
        f = 0
        d = 1 - d
        if V[d][-1]:
            V[d] += [0]
V = [sorted(_) for _ in V]
xs = set()


def judge(diff, vs):
    se = set([0])
    for v in vs:
        sen = set()
        for s in se:
            sen.add(s + v)
            sen.add(s - v)
        se = sen
    if diff not in se:
        print('No')
        exit()


judge(X, V[0])
judge(Y, V[1])
print('Yes')


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main() {
    int i;

    string s,t;
    cin>>s>>t;
    if(s.length() > 10 || (int)t.length() != (int)s.length() +1){
    	cout<<"No\n";
    	return 0;
    }
    for(i=0;i<(int)s.length();++i){
    	if(s[i] != t[i])
    		break;
    }
   	
    if(i != (int)s.length())
    	cout<<"No\n";
    else
    	cout<<"Yes\n";

    return 0;
}

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

char *strcut(char *str, const char *seek)
{
    char *p = str;
    if (strncmp(str, seek, strlen(seek)) == 0) {
        p += strlen(seek);
    }
    return p;
}

int solve(char *str)
{
    char *p = str;
    char *k;
    k = strcut(p, "maerd");
    if (k != p) { p = k; }
    k = strcut(p, "remaerd");
    if (k != p) { p = k; }
    k = strcut(p, "esare");
    if (k != p) { p = k; }
    k = strcut(p, "resare");
    if (k != p) { p = k; }
    if (p == str) {
        return 0;
    } else if (strcmp(p, "") == 0) {
        return 1;
    } else {
        return solve(p);
    }
}

int main(void)
{
    char s[100001] = "";
    scanf("%s", s);
    size_t len = strlen(s);
    for (size_t i = 0u; i < len / 2; ++i) {
        char tmp = s[i];
        s[i] = s[len - 1 - i];
        s[len - 1 - i] = tmp;
    }
    puts(solve(s) == 1 ? "YES" : "NO");

    return 0;
}


Measured memory_bytes: 256
import java.util.*;


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

		int n=sc.nextInt();
		int h[]=new int[n];
		boolean ans=true;


		for(int i=0;i<n;i++){
			h[i]=sc.nextInt();
		}

		int a=h[0];

		if(n==2 && h[0]>h[1]){
			if(h[0]-1!=h[1]){
				ans=false;
			}
		}

		ma:for(int i=1;i<n;i++){
			if(h[i]==a-1){
				a=h[i];
				for(int s=i+1;s<n;s++){
					if(h[s]==a-1){
						ans=false;
						break ma;
					}else if(h[s]>a){
						break;
					}else if(h[s]<a-1){
						ans=false;
						break ma;
					}
				}
			}
			if(h[i]<a-1){
				ans=false;
				break;
			}
			a=h[i];
		}

		if(ans==true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 49876
#include<stdio.h>
int main()
{
	int a,b,c,d,e,f,k;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	scanf("%d",&k);
	if(e-a>k)
	{
		printf(":(\n");
	}
	else
	{
		printf("Yay!\n");
	}
	return 0;
	
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N,T,A,t,a;
	cin>>N;
	t=a=1;
	for(long long n=0;n<N;n++)
	{
		cin>>T>>A;
		long long k=max((t+T-1)/T,(A+a-1)/A);
		t=k*T;
		a=A*k;
		//cout<<t<<" "<<a<<endl;
	}
	cout<<t+a<<endl;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var T = (double)input[0];
            var X = (double)input[1];

            Console.WriteLine(T / X);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
using namespace std;



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

	int n;
	cin >> n;
	ll mod = 1000000007;
	vector<ll> a(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i] % mod;
	}

	ll ans = 0;
	for (int i = 0; i < n; i++) {
		sum = (sum - a[i] + mod) % mod;
		ans = (ans + (sum * a[i]) % mod) % mod;
	}

	cout << ans << '\n';


	

}

Measured memory_bytes: 4748