akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

void binary(vector<int>& A,int N){
  for(int i=0;N>0;i++){
    A.at(i) = N%2;
    N=N/2;
  }
}

int main()
{
  int N, M, X;
  cin >> N >> M >> X;

  vector<int> C(N);
  vector<vector<int>> A(N,vector<int>(M));
  REP(i, N){
    cin >> C[i];
    REP(j, M){
      cin >> A.at(i).at(j);
    }
  }
  
  int MIN = INF;
  int flag2 = 0;
  FOR(i,1,pow(2,N)){
    vector<int> B(N,0);
    binary(B,i);
    int sumC=0;
    vector<int> sumA(M,0);
    REP(j,N){
      sumC+=B.at(j)*C.at(j);
    }
    REP(j,M){
      REP(k,N){
        sumA.at(j)+=A.at(k).at(j)*B.at(k);
      }
    }
    int flag = 0;
    REP(j,M){
      if(sumA.at(j)<X){
        flag = 1;
      }
    }
    if(flag == 1){
      continue;
    }else{
      MIN = min(MIN,sumC);
      flag2 = 1;
    }
  }
  if(flag2 == 1){
    cout << MIN << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}void _p() {cout << "]\n";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=========================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>n;
    i=1;
    while ((i*n)%360)
    {
        i++;
    }
    
    
    
    
    cout<< i <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3584
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

#%%

def get_field(i, j):
    try:
        ret = field[i][j]
    except:
        ret = '.'
    return ret

ans = True
for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            up = get_field(i-1, j)
            down = get_field(i+1, j)
            left = get_field(i, j-1)
            right = get_field(i, j+1)
            if up == '#' or down == '#' or left == '#' or right == '#':
                ans = True
            else:
                ans = False
                break
    if ans == False:
        break

if ans:
    print('Yes')
else:
    print('No')

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

int main()
{
   static long i,j,k;
   long n;
   long cnt = 0;
   long left,right,mid;
   long ans = 0;
   long a,b,c;
   scanf("%ld %ld",&a,&b);
   printf("%ld %ld %lf\n",a/b,a%b,(double)a/b);



   return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

lli data[400][400];

signed main(){

	set<lli> s;
	lli n,m;
	cin>>n>>m;
	lli flag[400];

	for(lli i=1;i<=m;i++)flag[i]=1;

	REP(i,0,n)REP(j,0,m)cin>>data[i][j];

	lli ans = INF;
	lli ansIndex=-1;
	while(true){
		lli b=0;
		for(lli i=1;i<=m;i++){
			if(flag[i]==1)b=1;
		}
		if(b==0)break;
		lli dp[400];
		REP(i,0,400)dp[i]=0;

		REP(i,0,n){
			if(DEBUG)cout<<"i="<<i<<endl;
			REP(j,0,m){
				lli nowS = data[i][j];
				if(flag[nowS]){
					if(DEBUG)cout<<"nowS=="<<nowS<<endl;
					dp[nowS]++;
					break;
				}
			}
		}
		lli nowMax=0;

		REP(i,0,400){
			if(dp[i]==0)continue;
			if(DEBUG)cout<<"i="<<i<<" dp[i]="<<dp[i]<<endl;
			if(nowMax<=dp[i]){
				nowMax = dp[i];
				ansIndex = i;
			}
		}
		ans = min(ans,nowMax);
		if(DEBUG)cout<<"ansINdex="<<ansIndex<<endl;
		flag[ansIndex]=0;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")


int main() {
	ll Q;
	cin >> Q;
	multiset<ll> L, R;
	ll center =-1;
	ll B = 0;
	ll size = 0;
	ll suml = 0, sumr = 0;
	REP(i, 0, Q) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll a, b;
			cin >> a >> b;
			B += b;
			if (size == 0) {
				center = a;
			}
			else if (size % 2 == 0) {
				if (*L.rbegin() <= a) {
					if (a <= *R.begin()) {
						center = a;
					}
					else {
						center = *R.begin();
						sumr -= *R.begin();
						R.erase(R.begin());
						sumr += a;
						R.insert(a);
					}
				}
				else {
					center = *L.rbegin();
					suml -= *L.rbegin();
					L.erase((++L.rbegin()).base());
					suml += a;
					L.insert(a);
				}
			}
			else {
				if (a <= center) {
					suml += a;
					sumr += center;
					L.insert(a);
					R.insert(center);
				}
				else {
					suml += center;
					sumr += a;
					L.insert(center);
					R.insert(a);
				}
				center = -1;
			}

			++size;
		}
		else {
			PRI(((center == -1) ? *L.rbegin() : center) << " " << sumr - suml + B);
		}
	}
	return 0;
}




Measured memory_bytes: 12876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a;
		for (int i = 1; i <= n; i++) {
			if (i % 3 == 0 || i % 10 == 3) {
				System.out.print(" " + i);
			} else if (i >= 30) {
				a = i;
				while (a >= 30) {
					a /= 10;
					if (a == 3 || a % 10 == 3) {
						System.out.print(" " + i);
						break;
					}
				}
			}
		}
		System.out.println();
	}
}

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

int f(int a,int b,int c){
  int res = a;
  res = a*60 + b;
  res = res*60 + c;
  return res;
}

vector<int> ff(int t){
  vector<int> res(3);
  res[2] = t%60;
  t/=60;
  res[1] = t%60;
  t/=60;
  res[0] = t;
  return res;
}
int main(){
  for(int i=0;i<3;i++){
    int a,b,c;
    cin>>a>>b>>c;
    int start = f(a,b,c);
    cin>>a>>b>>c;
    int end = f(a,b,c);
    auto ans = ff(end-start);
    cout<<ans[0]<<" "<<ans[1]<<" "<<ans[2]<<endl;
  }
}

Measured memory_bytes: 1192
N, K = map(int, input().split())
H = [int(x) for x in input().split()]
inf = float("inf")

dp = [inf] * (N)
dp[0] = 0
dp[1] = abs(H[0]-H[1])

for i in range(1, N):
    for k in range(1,K+1):   
        if i - k < 0:
            break
        else:
            dp[i] = min(dp[i], dp[i-k]+abs(H[i-k]-H[i]))
        
print(dp[N-1])

Measured memory_bytes: 54880
#include <bits/stdc++.h>
using namespace std;
typedef long ll;
const ll mod=(1e9)+7;
string A,B,C;

ll mem[100][11],used[100][11];

ll dfs(int idx,int pre){
  if(idx==-1) return pre==0;
  if(used[idx][pre]++)return mem[idx][pre];
  ll res=0;
  
  int u[10][10][10]={};
  for(int i=idx==0;i<10;i++)
    for(int j=idx==0;j<10;j++)
      for(int k=idx==0;k<10;k++){
	int a=A[idx]=='?'? i:A[idx]-'0';
	int b=B[idx]=='?'? j:B[idx]-'0';
	int c=C[idx]=='?'? k:C[idx]-'0';
	if(u[a][b][c]++||(a+b+pre)%10!=c) continue;
	res=(res+dfs(idx-1,(a+b+pre)/10))%mod;
      }
  return mem[idx][pre] = res;
}

int main(){
  while(1){
    cin>>A;
    if(A=="0")break;
    cin>>B>>C;
    memset(used,0,sizeof(used));
    cout <<dfs(A.size()-1,0)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

char s[105];
int n, dp[105][4][2], K;

int dfs(int num, int use, int limit) {
    int ans = 0;
    if(use > K) return 0;
    if(num > n) return use == K;
    if(dp[num][use][limit] != -1) return dp[num][use][limit];
    int up = limit?s[num]-'0':9;
    for(int i = 0; i <= up; ++i)
        ans += dfs(num+1, use+(i!=0), limit&&i==up);
    return dp[num][use][limit] = ans;
}

void run_case() {
    cin >> (s+1) >> K;
    n = strlen(s+1);
    memset(dp, -1, sizeof(dp));
    cout << dfs(1, 0, 1);
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

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

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> dp(N);
    dp[0]=1;
    for(int i=1;i<N;i++){
        dp[i]=dp[i-1]*(K-1);
    }
    cout<<dp[N-1]*K<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<vector<ll>> cb(m,vector<ll>(2));
    for(int i=0;i<m;i++){
        cin>>cb[i][1]>>cb[i][0];
    }
    sort(a.begin(),a.end());
    sort(cb.begin(),cb.end(),greater<>());
    
    int index=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<cb[i][1];j++){
            if(cb[i][0]<=a[index]) break;
            if(index>=n) break;
            a[index]=cb[i][0];
            index++;
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6528
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 l[]=new int[n];
        for(int i=0;i<n;i++){
            l[i]=sc.nextInt();
        }
        Arrays.sort(l);
        int total=0;
        for(int i=n-1;i>n-1-k;i--){
            total+=l[i];
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 21332
import java.util.*;

class Main{
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		int n= sc.nextInt();
		int a[][]=new int [2][n];
		int sum=0,s=0;
		int c=0,i;
		for(i=0;i<2;i++)
		for(int j=0;j<n;j++)
		a[i][j]=sc.nextInt();
		while(c<n)
		{
		sum=a[0][0];
		for(i=1;i<=c;i++)
		{
		    sum=sum+a[0][i];
		}
		for(i=c;i<n;i++)
		{
		    sum=sum+a[1][i];
		}
		s=Math.max(sum,s);
		c++;
		}
		System.out.println(s);
	}
}
		

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x,y;
  int z,w;
  cin>>x>>y;
  z=stoi(x+y);
  for(w=2;w*w<=z;w++){
    if(w*w==z){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int main(){
	const ll INF = 1e9 + 5;
	ll N, k; cin >> N >> k;
        vector<ll> heights(N), minCost(N, INF);
        minCost[0] = 0;
        for(ll &ele : heights) cin >> ele;
        minCost[0] = 0;
        for(ll place = 0; place < N; ++place){
            for(int jump = 1; jump <= k; ++jump){
                if(place + jump < N){
                   minCost[place + jump] = min(minCost[place + jump],
                    			  minCost[place] 
                                          + abs(heights[place] - heights[place + jump]));
                }
            }
        }
        cout << minCost[N - 1] << endl;
    	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long x,y;
  cin>>x;
  y=x%11;
  x=x/11;
  x*=2;
  if(y<7){
    if(y)x++;
  }else{
    x+=2;
  }
  cout<<x<<endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


#include "bits/stdc++.h"

template<typename T>
struct Dice {
public:

	Dice(std::vector<T> v) : faces(v) {}
	void roll(char c) {
		T tmp;
		switch (c) {
		case 'N':
			tmp = faces[TOP];
			faces[TOP] = faces[FRONT];
			faces[FRONT] = faces[BOTTOM];
			faces[BOTTOM] = faces[BACK];
			faces[BACK] = tmp;
			break;
		case 'S':
			tmp = faces[TOP];
			faces[TOP] = faces[BACK];
			faces[BACK] = faces[BOTTOM];
			faces[BOTTOM] = faces[FRONT];
			faces[FRONT] = tmp;
			break;
		case 'E':
			tmp = faces[TOP];
			faces[TOP] = faces[LEFT];
			faces[LEFT] = faces[BOTTOM];
			faces[BOTTOM] = faces[RIGHT];
			faces[RIGHT] = tmp;
			break;
		case 'W':
			tmp = faces[TOP];
			faces[TOP] = faces[RIGHT];
			faces[RIGHT] = faces[BOTTOM];
			faces[BOTTOM] = faces[LEFT];
			faces[LEFT] = tmp;
			break;
		case 'R':
			tmp = faces[FRONT];
			faces[FRONT] = faces[RIGHT];
			faces[RIGHT] = faces[BACK];
			faces[BACK] = faces[LEFT];
			faces[LEFT] = tmp;
			break;
		case 'L':
			tmp = faces[FRONT];
			faces[FRONT] = faces[LEFT];
			faces[LEFT] = faces[BACK];
			faces[BACK] = faces[RIGHT];
			faces[RIGHT] = tmp;
			break;
		default:
			std::cerr << "invalid char" << endl;
			abort();
		}
	}
	T top() {
		return faces[TOP];
	}
	T front() {
		return faces[FRONT];
	}
	T left() {
		return faces[LEFT];
	}
	T back() {
		return faces[BACK];
	}
	T right() {
		return faces[RIGHT];
	}
	T bottom() {
		return faces[BOTTOM];
	}
private:
	std::vector<T> faces;
	static constexpr int TOP = 0, FRONT = 1, RIGHT = 2, LEFT = 3, BACK = 4, BOTTOM = 5;
};




int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vi v(6);
	REP(i, 6)cin >> v[i];
	Dice<int> d(v);
	string s; cin >> s;
	REP(i, s.size()) {
		d.roll(s[i]);
	}
	cout << d.top() << endl;
}


Measured memory_bytes: 3192
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=2e5+11;
const ll INF=1e18+11;
int n,m,s,t;
ll dfl[N],df1[N],dfc[N],a[N],c[N],cnt,ans=INF,now;
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	n=read();m=read();t=read();
	for(int i=1;i<n;++i){
		s=t;t=read();
		if(s<t){dfc[1]+=t-s;dfc[s+1]-=t-s;dfc[t+1]+=t-s;dfl[s+1]+=t-s;df1[s+1]++;df1[t+1]--;}
		else{dfc[t+1]+=m+t-s;dfc[s+1]-=m+t-s;dfl[s+1]+=m+t-s;df1[s+1]++;dfl[1]+=t;df1[1]++;df1[t+1]--;}
	}
	for(int i=1;i<=m;++i) c[i]=c[i-1]+dfc[i];
	for(int i=1;i<=m;++i){
		now+=dfl[i];cnt+=df1[i];
		c[i]+=now;
		now-=cnt;
	}
	for(int i=1;i<=m;++i) ans=min(ans,c[i]);
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5888
import math
n=input()
a=[0 for i in range(3)]
a[0],a[1],a[2]=n.count("a"), n.count("b"), n.count("c")
a.sort()
if a[2]==math.ceil(sum(a)/3) and a[1]-math.ceil(sum(a)/3)<=1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<set>
#include<utility>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>
#include<stack>
#include<random>

//#include"gap.h"

using namespace std;

const int int_max = 2147483647;



const long long mod = 1e9 + 7;


long long dfs(int K, const vector<vector<int>>&graph, int now, int from){

	int can_color_num;
	if(from == -1){
		can_color_num = K-1;
	}
	else{
		can_color_num = K - 2;
	}

	if(graph[now].size() > K){
		return 0;
	}
	else{
		long long case_num = 1;

		for(auto e : graph[now]){
			if(e == from) continue;

			case_num *= can_color_num;
			can_color_num--;
			case_num %= mod;
		}

		for(auto e : graph[now]){
			if(e == from) continue;

			case_num *= dfs(K, graph, e, now);
			case_num %= mod;
		}

		return case_num;
	}
}

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

	vector<vector<int>> graph(N);

	for(int i=0; i<N-1; i++){
		int a, b;
		cin >> a >> b;

		a--; b--;

		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	long long ans = K * dfs(K, graph, 0, -1) % mod;
	cout << ans << endl;


	return 0;
}


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

int main(){

	int N,M;

	cin >> N >> M;

	//1000000007

	vector<vector<int>> DP(N,vector<int>(M,0));
	vector<string> G;

	for(int i=0;i<N;i++){
		string input;
		cin >> input;
		G.push_back(input);
		
	}



	DP[0][0] = 1;

	int row = DP.size();
	int col = DP[0].size();

	//init
	for(int j=1;j<col;j++){
		if(G[0][j]=='#'){
			DP[0][j] = 0;
		}else{
			// '.'

			DP[0][j] = DP[0][j-1];
		}
	}

	for(int i=1;i<row;i++){
		if(G[i][0]=='#'){
			DP[i][0] = 0;
		}else{
			// '.'

			DP[i][0] = DP[i-1][0];
		}
	}

	for(int i=1;i<row;i++){
		for(int j=1;j<col;j++){

			if(G[i][j]=='#'){
				DP[i][j]=0;
			}else{
				DP[i][j] = (DP[i-1][j]%1000000007+DP[i][j-1]%1000000007)%1000000007;
			}

		}
	}

	cout << DP[row-1][col-1] <<endl;

	return 0;

}

Measured memory_bytes: 8584
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<=1000;i++)
	{
		if(i*100<=n&&n<=i*105)
		{
			cout<<"1"<<endl;
			return 0;
		}
	}
	cout<<"0"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
c = 0
for i in range(n-1):
    if (p[i] == i+1):
        c += 1
        p[i],p[i+1] = p[i+1],p[i]

if (p[n-1] == n):
    c+=1

print(c)


Measured memory_bytes: 14004
def main():
    N = int(input())
    tasks = list()
    for _ in range(N):
        A, B = list(map(int, input().split(' ')))
        tasks.append((B, A))
    tasks.sort()
    current = 0
    for t in tasks:
        dead_line_time, required_time = t
        if current + required_time > dead_line_time:
            print('No')
            exit(0)
        current += required_time
    print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 29400
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from fractions import gcd

class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = I
        self.seg = [I for i in range(self.sz * 2)]
 
    def assign(self, k, x):
        self.seg[k + self.sz] = x
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                R = self.func(R, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return R

def main():
    N = int(readline())
    m = map(int,read().split())
    seg = SegmentTree(N , gcd , 0)
    for i in range(N):
        seg.assign(i , next(m))
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
    print(ans)

main()


Measured memory_bytes: 82980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
int a,b,c,d;
ll mem[3005][3005];
ll dp(int x, int y){
	if (x == a && y == b) return 1ll;
	if (mem[x][y] != -1) return mem[x][y];
	ll res = 0;
	if (x > a){
		res += y*dp(x-1,y);
	}
	if (y > b){
		res += x*dp(x,y-1);
	}
	if (x > a && y > b) res -= (x-1)*(y-1)*dp(x-1,y-1);
	res = ((res % mod) + mod )%mod;
	return mem[x][y] = res;
}

int main(){
	scanf("%d%d%d%d",&a,&b,&c,&d);
	memset(mem,-1,sizeof(mem));
	printf("%lld",dp(c,d));
	
}

Measured memory_bytes: 74668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int N=100020;
int v[3],p[N],q[N];
int main(){
    int n;cin >> n;
    string s;
    for(int i=0;i<3;i++)cin >> v[i];
    for(int i=1;i<=n;i++){
        cin >> s;
        p[i]=s[0]-'A';
        q[i]=s[1]-'A';
    }
    for(int i=1;i<=n;i++){
        if(v[p[i]]>v[q[i]])swap(p[i],q[i]);
        else if(v[p[i]]==v[q[i]])
            if(i<n&&(q[i]==q[i+1]||q[i]==p[i+1]))swap(p[i],q[i]);
        if(!v[q[i]])return 0*printf("No\n");
        v[p[i]]++,v[q[i]]--;
    }
    puts("Yes");
    for(int i=1;i<=n;i++) printf("%c\n",'A'+p[i]);
    return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define tsolve int t;cin>>t;while(t--)  solve();
#define f(i,n)   for(int i=0;i<n;i++)
#define ff first
#define all(a) a.begin(),a.end()
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
int main(){
    int n,t;
    cin>>n>>t;
    cout<<(n+t/2);
    return 0;
}

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


int main() {
  string s,t;
  int ans = 0;
  cin >> s >> t;
  rep(i , s.size()) {
    if(s.at(i) == t.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a[2],b[2],ans=-1000000000000000000000;
  for(int i=0;i<2;i++)
    cin>>a[i];
    for(int i=0;i<2;i++)
    cin>>b[i];

  for(int i=0;i<2;i++)
  {
    for(int j=0;j<2;j++)
    {
      ans=max(ans,a[i]*b[j]);
    }
  }
  if(ans<0)
  {
    if((0>=a[0] && 0<=a[1]) || (0>=b[0] && 0<=b[1]))
      ans=0;
  }
  cout<<ans;
  return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n,k,t;
    cin >> n >> k;
    vector<int> snuke(n+1,0);
    REP(i,k){
        cin >> t;
        int p;
        REP(j,t){
            cin >> p;
            snuke[p]++;
        }
    }
    int count = 0;
    for(int i=1;i<n+1;i++){
        if(snuke[i]==0)count++;
    }
    COUT(count);
    return 0;
}

Measured memory_bytes: 3628
n,k=map(int,input().split())
p1=list(map(int,input().split()))
p2=[]
for i in range(n):
  p2.append(((1+p1[i])/2))
ans=sum(p2[0:k])
sum1=sum(p2[0:k])
for j in range(n-k):
  sum1=sum1+p2[j+k]-p2[j]
  if ans<sum1:
    ans=sum1
print(ans)
  

Measured memory_bytes: 32104
def ints():
  return [int(x) for x in input().split()]
def readi():
  return int(input())

N, M = ints()
N+=1
G=N-1
SUGOROKU = input()

if SUGOROKU[G]==1:
  print(-1)
  exit()

n = N-1
k = 0
tejun = []
while n>0:
  mmax = min(n, M)

  found = False
  for m in reversed(range(1, mmax+1)):
    if SUGOROKU[n-m]=='1':
      continue
    n -= m
    k += 1
    found = True
    tejun.append(m)
    break

  if not found:
    print(-1)
    exit()

print(*list(reversed(tejun)))
  



Measured memory_bytes: 47856
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

a = list(ns())
b = list(ns())

if len(a) > len(b):
    print('GREATER')
elif len(a) < len(b):
    print('LESS')
else:
    for i in range(len(a)):
        if a[i] > b[i]:
            print('GREATER')
            exit()
        elif a[i] < b[i]:
            print('LESS')
            exit()
    print('EQUAL')


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<set>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
  string s,t;
  cin>>s;
  for(int i=0;i<s.size();i+=2)
    t+=s[i];
  cout<<t;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  I n,m;
  cin >> n >> m;
  vector<P> ab(m);
  REP(i,m){
    cin >> ab.at(i).first >> ab.at(i).second;
  }
  UnionFind uf(n+1);
  V t(m);
  I an = n * (n-1) / 2;
  for(I i=m-1;i>=0;i--){
    t.at(i) = an;
    I x,y;
    x = ab.at(i).first;
    y = ab.at(i).second;
    if (uf.find(x) == uf.find(y)){
    }else{
      an -= uf.size(x) * uf.size(y);
      uf.unite(x,y);
    }
  }
  REP(i,m){
    cout << t.at(i) << endl;
  }
  return 0;
}



Measured memory_bytes: 4096
#include<stdio.h>
int main(){
  int i,j,n,count,minj,temp;
  int a[100];

  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
          if(minj!=i){
	temp=a[i];
	a[i]=a[minj];
	a[minj]=temp;
	count++;
      }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[n-1]);
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <cmath>
#include <cassert>
using namespace std;
int N,x[101],y[101],h[101],H[101][101];
int C[101][101] = {0};
int main(){
	cin >> N;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			C[i][j] = -1;
			H[i][j] = 2e9;
		}
	}
	for(int i=0;i<N;i++){
		cin >> x[i] >> y[i] >> h[i];
		for(int j=0;j<=100;j++){
			for(int k=0;k<=100;k++){
				int a = abs(x[i]-j),b = abs(y[i]-k);
				if(h[i]==0) H[j][k] = min(a+b,H[j][k]);
				if(C[j][k]==-1){
					if(h[i]>0) C[j][k] = h[i]+a+b;
				}else if(h[i]!=0 && C[j][k]!=h[i]+a+b) C[j][k] = -100;
			}
		}
	}
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			if(C[i][j]>0 && C[i][j]<=H[i][j]){
				cout << i << " " << j << " " << C[i][j] << endl;
				return 0;
			}
			C[i][j] = 0;
		}
	}
}


Measured memory_bytes: 384
N,M = map(int, input().split())
A = list(map(int, input().split()))
MAX = sum(A)
A = sorted(A,reverse=True)
M_count = 0
for i in A:
  if i >= MAX/(4*M):
    M_count += 1
  else:
    break
if M_count >= M:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9172
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <ctime>
#include <queue>
#include <sstream>
#include <utility>
#include <bitset>

using namespace std;

#define MP make_pair 
#define PB push_back 
#define INF (1000000007) 
#define eps 1e-8
#define MOD (1000000007)

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

int n,m;
int a[305][305],p[305][305],cnt[305],ans=INF,tt=INF,cur[305],tp[305][305];
vector<int >v;

inline void update()
{
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) 
		{
			cnt[j]+=(p[i][j]==1);
		}
	}
//	for(int i=1;i<=m;i++)
//	{
//		cout<<cnt[i]<<"  ";
//	}
//	cout<<endl;
}

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++) 
		{
			cin>>a[i][j];
			tp[i][a[i][j]]=p[i][a[i][j]]=j;
		}
	}
	for(int i=1;i<=m;i++)
	{
		update();
		int ma=0,t=0,mi=INF;
		for(int j=1;j<=m;j++) 
		{
			if(cnt[j]>ma)
			{
				ma=cnt[j];
				t=j;
			}
		}
//		cout<<ma<<" "<<t<<endl;
		ans=min(ans,ma);
		v.PB(t);
		for(int j=1;j<=n;j++)
		{
			int tmp=p[j][t];
			for(int k=1;k<=m;k++)
			{
				if(p[j][k]>tmp)p[j][k]--;
			}
			p[j][t]=-1;
		}
//		cout<<endl;
//		for(int j=1;j<=n;j++)
//		{
//			for(int k=1;k<=m;k++)
//			{
//				cout<<p[j][k]<<" ";
//			}
//			cout<<endl;
//		}
		
//		cout<<endl;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0; i<(int)(n); ++i)
#define REP(i,m,n) for(ll i=(ll)(m); i<(ll)(n); ++i)
#define F first
#define S second
const double PI=acos(-1);
//fixed<<setprecision(11)<<

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int r = (n-1)/2;
  string s_inv = s;
  string s_pre = s.substr(0,r);
  string s_preinv = s_pre;

  reverse(s_inv.begin(),s_inv.end());
  if(s != s_inv){
    cout<<"No"<<endl;
    return 0;
  }

  reverse(s_preinv.begin(),s_preinv.end());
  if(s_pre != s_preinv){
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;
return 0;
}

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

bool isPalindrome(string s) {
    int n = s.length();
    int flag = 0;
    for(int i=0;i<n;i++) {
        if(s[i] != s[n-i-1]) {
            flag = 1;
            break;
        }
    }
    if(flag) return false;
    return true;
} 
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    string s;
    cin >> s;
    int n = s.length();
    string ans = "No";
    if(n % 2 == 1) {
        if(isPalindrome(s) && isPalindrome(s.substr(0, n / 2)) && isPalindrome(s.substr(n / 2 + 1))) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    private static final long NUM = 1000000007;
    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	long N = Long.parseLong(scan.next());
	long M = Long.parseLong(scan.next());

	long min;
	long max;
	if(N < M) {
	    min = N;
	    max = M;
	} else {
	    min = M;
	    max = N;
	}

	long ans;
	long dif = max - min;
	if(dif == 0) {
	    long tmp = factorial(max);
	    ans = 2*tmp*tmp%NUM;
	} else if(dif == 1) {
	    ans = factorial(max)*factorial(min)%NUM;
	} else {
	    ans = 0;
	}
	
	System.out.println(ans);
	scan.close();
    }

    private static long factorial(long x) {
	long result = 1;
	for (long i = 2; i <= x; i++) {
	    result = result * i % NUM;
	}
	return result;
    }
}


Measured memory_bytes: 21844
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;
char a[100010];
bool d=true;
int main(){
	cin>>a;
	int t=strlen(a);
	if(t%2!=0)cout<<"No"<<endl;
	else
	{
		for(int i=0;i<=t/2-1;i++)
		{
			if(a[i]=='b'&&a[t-i-1]!='d')
			{
				d=false;
				break;
			}
			if(a[i]=='d'&&a[t-i-1]!='b')
			{
				d=false;
				break;
			}
			if(a[i]=='q'&&a[t-i-1]!='p')
			{
				d=false;
				break;
			}
			if(a[i]=='p'&&a[t-i-1]!='q')
			{
				d=false;
				break;
			}
		}
		if(d)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}

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

int main(){
int a[13]={0,1,3,1,2,1, 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int x,y;
  cin>>x>>y;
if(a[x]==a[y]){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
S = input()
N = len(S)

N1 = int((N-1)/2)

if N1%2 ==1:
    N2 = int((N1-1)/2)
else:
    N2 = int(N1/2)

result = "Yes"

for i in range(N2):
    if S[i] != S[N1-1-i]:
        result = "No"
        break

if result == "Yes":
    for i in range(N1):
        if S[i] != S[N-1-i]:
            result ="No"
            break
        

print(result)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <unordered_map>

using namespace std;

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

#define ri(a) scanf("%d", &a)
#define rii(a,b) scanf("%d %d", &a, &b)
#define riii(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define rl(a) scanf("%lld", &a)
#define rll(a,b) scanf("%lld %lld", &a, &b)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define ROF(i,n,m) for(int i=n; i>m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second

const int INF = 0x3f3f3f3f;
const ll LLINF = 1e18;
const int maxN = 3010; // CAMBIAR ESTE

// GJNM
bool vis[maxN][maxN][4];
ll dp[maxN][maxN][4];
int r, c, k;
ll v[maxN][maxN];

ll f(int row, int col, int left) {
    if ( row >= r || col >= c )
        return -LLINF;
    if ( row == r - 1 && col == c - 1) {
        if ( left > 0 )
            return v[row][col];
        else
            return 0;
    }
    if ( vis[row][col][left] )
        return dp[row][col][left];
    vis[row][col][left] = true;

    ll &ret = dp[row][col][left] = 0;

    ret = max(ret, f(row + 1, col, 3));
    ret = max(ret, f(row, col + 1, left));

    if ( left > 0 && v[row][col] > 0 ) {
        ret = max(ret, v[row][col] + f(row + 1, col, 3));
        ret = max(ret, v[row][col] + f(row, col + 1, left - 1));
    }
    return ret;
}

int main() {
    riii(r, c, k);
    FOR(i, 0, k) {
        int aux_r, aux_c;
        rii(aux_r, aux_c);
        rl(v[aux_r - 1][aux_c - 1]);
    }

    printf("%lld\n", f(0, 0, 3));

    return 0;
}

Measured memory_bytes: 391888
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

const int N = 26;
int D;
int c[26];
int s[365][26];
int t[365];
int last[26];

signed main() {
	int i, j;
	
	cin >> D;
	rep(i, N) cin >> c[i];
	rep(i, D) rep(j, N) cin >> s[i][j];
	rep(i, D) { cin >> t[i]; t[i]--; }
	
	int score = 0;
	
	rep(i, N) last[i] = -1;
	
	rep(i, D) {
		score += s[i][t[i]];
		last[t[i]] = i;
		rep(j, N) {
			score -= c[j] * (i - last[j]);
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)


using namespace std;


template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};


struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}

ll dx8[8]={1,0,-1,0,1,-1,1,-1};
ll dy8[8]={0,1,0,-1,1,-1,-1,1};
ll dx4[4]={0,0,1,-1};
ll dy4[4]={1,-1,0,0};


int main(){
    IOS;
    make(string,s); ll c=0; ll ans=0;
    fr(i,3){
        if(s[i]=='R') c++;
        else c=0;
        ans=max(ans,c);
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 3652
import Control.Monad (replicateM)
import Data.List (sort)

main = do
    n <- readLn :: IO Int
    answer <- length . filter odd . evenSnds . sort . (`zip` [0..]) <$> replicateM n ((read :: String -> Int) <$> getLine)
    print answer
  where evenSnds ((x, i):ps) = i:(evenSnds (drop 1 ps))
        evenSnds _ = []

Measured memory_bytes: 68988
import java.util.Scanner;
class Dice{
	private int num[] = new int[6];
	private int we[] = new int[4];
	private int ns[] = new int[4];
	public Dice(){
	}
	public void setNum(int n[]){
		for(int i = 0 ; i < 6 ; i++)
			num[i] = n[i];
		we[0] = ns[3] = num[5];
		we[2] = ns[1] = num[0];
		we[1] = num[3];
		we[3] = num[2];
		ns[0] = num[4];
		ns[2] = num[1];
	}
	public void setNum(int n1, int n2, int n3, int n4, int n5, int n6){
		int N1=n1, N2=n2, N3=n3, N4=n4, N5=n5, N6=n6;
		we[2] = ns[1] = num[0] = N1;
		ns[2] = num[1] = N2;
		we[3] = num[2] = N3;
		we[1] = num[3] = N4;
		ns[0] = num[4] = N5;
		we[0] = ns[3] = num[5] = N6;
	}
	public int getNum(int i, int n){
		if(i == 0)
			return we[n];
		else
			return ns[n];
	}
	public void print(int i, int n){
		if(i == 0)
			System.out.println(we[n]);
		else 
			System.out.println(ns[n]);
	}
	public void roll(String order){
		for(int i = 0 ; i < order.length() ; i++){
			switch(order.charAt(i)){
				case 'E' : setNum(num[3],num[1],num[0],num[5],num[4],num[2]); break;
				case 'W' : setNum(num[2],num[1],num[5],num[0],num[4],num[3]); break;
				case 'S' : setNum(num[4],num[0],num[2],num[3],num[5],num[1]); break;
				case 'N' : setNum(num[1],num[5],num[2],num[3],num[0],num[4]); break;
			}
		}
	}
}
public class Main{
	public static boolean samedice(Dice dice1, Dice dice2){
		for(int i = 0 ; i < 4 ; i++)
		{
			dice1.roll("W");
			if(dice1.getNum(0,1) == dice2.getNum(0,1) && dice1.getNum(0,3) == dice2.getNum(0,3))
				break;
		}
		if(!(dice1.getNum(0,1) == dice2.getNum(0,1) && dice1.getNum(0,3) == dice2.getNum(0,3)))
		{
			dice1.roll("S");
			for(int i = 0 ; i < 4 ; i++)
			{
				dice1.roll("W");
				if(dice1.getNum(0,1) == dice2.getNum(0,1) && dice1.getNum(0,3) == dice2.getNum(0,3))
					break;
			}
		}
		if(!(dice1.getNum(0,1) == dice2.getNum(0,1) && dice1.getNum(0,3) == dice2.getNum(0,3)))
			return false;
		else
		{
			for(int i = 0 ; i < 4 ; i++)
			{
				dice1.roll("S");
				if(dice1.getNum(1,0) == dice2.getNum(1,0) && dice1.getNum(1,1) == dice2.getNum(1,1) && dice1.getNum(1,2) == dice2.getNum(1,2) && dice1.getNum(1,3) == dice2.getNum(1,3))
					return true;
			}
			return false;
		}
	}
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Dice dice[] = new Dice[n];
		int num[][] = new int[n][6];
		int judge = 0;
		for(int i = 0 ; i < n ; i++)
		{
			dice[i] = new Dice();
		}
		for(int i = 0 ; i < n ; i++)
		{
			for(int j = 0 ; j < 6 ; j++)
				num[i][j] = sc.nextInt();
		}
		for(int i  = 0 ; i < n ; i++)
			dice[i].setNum(num[i]);
		for(int i = 0 ; i < n ; i++)
		{
			for(int j = i+1 ; j < n ; j++)
			{
				if(samedice(dice[i],dice[j]))
				{
					judge++;
					break;
				}
			}
		}
		if(judge == 0)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 30152
#include <cstdio>

int main(void){
	int n;
	long a, max=-1000000, min=1000000, sum=0;
	scanf("%d", &n);
	for(int i=0; i<n; ++i){
		scanf("%ld", &a);
		if(a>max) max = a;
		if(a<min) min = a;
		sum+=a;
	}
	printf("%ld %ld %ld\n", min, max, sum);
}



Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1LL<<60;

ll p;
struct edge {
  ll from, to, cost;
};

vector<edge> g;
vector<vector<ll>> g1(2510);
vector<vector<ll>> gn(2510);
vector<bool> r1(2510, false);
vector<bool> rn(2510, false);

void dfs(ll s)
{
  if (r1[s]) return;
  r1[s] = true;
  for (auto v:g1[s]) {
    dfs(v);
  }
}

void rdfs(ll s)
{
  if (rn[s]) return;
  rn[s] = true;
  for (auto v:gn[s]) {
    rdfs(v);
  }
}

int main()
{
  ll n, m, p; cin >> n >> m >> p;
  rep(i, m) {
    int a, b, c; cin >> a >> b >> c; a--; b--;
    g.push_back(edge{a, b, p-c});
    g1[a].push_back(b);
    gn[b].push_back(a);
  }

  dfs(0);
  rdfs(n-1);

  if (!r1[n-1]) {
    cout << -1 << endl;
    return 0;
  }

  vector<ll> d(n, INF);
  d[0] = 0;
  bool upd = true;
  int step = 0;
  bool ng = false;
  while (upd) {
    upd = false;
    for (int j=0; j<(int)(g.size()); j++) {
      edge e = g[j];
      if (!(r1[e.to]&&rn[e.to]) || !(r1[e.from]&&rn[e.from])) continue;
      if (d[e.from] == INF) continue;
      if (d[e.to] > d[e.from]+e.cost) {
        upd = true;
        d[e.to] = min(d[e.to], d[e.from]+e.cost);
      }
    }
    step++;
    if (step > n) {
      ng = true;
      break;
    }
  }

  if (ng) cout << -1 << endl;
  else cout << max(0LL, -d[n-1]) << endl;

  return 0;
}


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

  int AC = 0, WA = 0, TLE = 0, RE = 0;

  vector<string> S(N);

  for(int i = 0; i < N; i++){
    cin >> S.at(i);
    if(S.at(i) == "AC"){
      AC++;
    }else if(S.at(i) == "WA"){
      WA++;
    }else if(S.at(i) == "TLE"){
      TLE++;
    }else{
      RE++;
    }
  }

  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;

}

Measured memory_bytes: 6376
n,m = map(int,input().split())
mod = 10 ** 9 + 7
broken = []
for _ in range(m):
  broken.append(int(input()))
here = 0
dp = [0,1]
for i in range(n):
  if here != m:
    if i+1 == broken[here]:
      dp.append(0)
      here += 1
    else:
      dp.append((dp[-2]+dp[-1])%mod)
  else:
    dp.append((dp[-2]+dp[-1])%mod)
print(dp[-1])
#print(dp)

Measured memory_bytes: 7848
#include<stdio.h>
#include<cstring>
char a[100100];
int main()
{
int z,i,p=0;
scanf("%s",a);
z=strlen(a);

for(i=0;i<z;i++)
{
if(a[i]=='p')p++;
}

printf("%d",(z/2)-p);
}

Measured memory_bytes: 256
#include<stdio.h>

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

Measured memory_bytes: 572
/**
 * @author torith
 * @date 2018-10-10
 */

#include <bits/stdc++.h>

using namespace std;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int dp[100000];
    for (int i = 0; i <= N; ++i) {
        dp[i] = 0;
    }

    for (int i = 1; i <= N; ++i) {
        // 1について
        dp[i] = dp[i-1] + 1;

        // 6について
        int j = 6;
        while(i - j >= 0){
            dp[i] = min(dp[i],dp[i-j] + 1);
            j *= 6;
        }

        // 9について
        j = 9;
        while(i - j >= 0){
            dp[i] = min(dp[i],dp[i-j] + 1);
            j *= 9;
        }
    }

    cout << dp[N] << "\n";
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int r, g, b;

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

    void run() {
        FastReader sc = new FastReader();
        r = sc.nextInt();
        g = sc.nextInt();
        b = sc.nextInt();
        solve();
    }

    void solve() {
        if ((r * 100 + g * 10 + b) % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

    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;
        }
    }
}


Measured memory_bytes: 22996