akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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

N = INT()
uvw = [LIST() for _ in range(N-1)]

link_dic = defaultdict(list)

for u, v, w in uvw:
	link_dic[u-1].append((v-1, w))
	link_dic[v-1].append((u-1, w))
# print(link_dic)
searched = [0]*N
color = [0]*N
color[0] = 1
def dfs(i):
	# print(i)
	for node, w in link_dic[i]:
		if searched[node] == 1:
			continue
		else:
			if w % 2 == 0:
				color[node] = color[i]
			else:
				color[node] = color[i] * (-1)
			searched[node] = 1
			dfs(node)

dfs(0)
for i in color:
	if i == -1:
		print('0')
	else:
		print('1')

Measured memory_bytes: 107540
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	lli n, i, j, k, x, y, z;
	vi t, a;

	cin >> n;

	t.resize(n);
	a.resize(n);

	rep(i, n) {
		cin >> t[i];
		cin >> a[i];
	}

	i = t[0];
	j = a[0];

	rep(k, n - 1) {
		x = t[k + 1];
		y = a[k + 1];
		z = max(i / x, j / y);
		while (x*(lli)z < i || y*(lli)z < j) {
			z++;
		}
		i = x * (lli)z;
		j = y * (lli)z;
	}

	cout << i + j;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

int main(){
  int H,W;
  cin >> H>>W;
  vvi chizu(H,vi(W,0));
  vvi mindp(H,vi(W,-1));
  char WorB;
  Rep(i,H){
    Rep(j,W){
      cin >> WorB;
      chizu[i][j] = (WorB == '.')? 1:0;
    }
  }
  mindp[0][0]=0;
  Rep1(i,W-1){
    mindp[0][i]=(chizu[0][i-1]== 1 && chizu[0][i]==0)?
      mindp[0][i-1]+1:mindp[0][i-1];
  }
  Rep1(i,H-1){
    mindp[i][0]=(chizu[i-1][0]== 1 && chizu[i][0]==0)?
      mindp[i-1][0]+1:mindp[i-1][0];
  }
  
  Rep1(i,H-1){
    Rep1(j,W-1){
      mindp[i][j]=min(
        (chizu[i-1][j]-chizu[i][j]>0)?
        mindp[i-1][j]+1:mindp[i-1][j],
        (chizu[i][j-1]-chizu[i][j]>0)?
        mindp[i][j-1]+1:mindp[i][j-1]
      );
    }
  }
        
  /*Rep(i,H){
    Rep(j,W){
      cout<<mindp[i][j];
    }
    cout<<endl;
  }*/
  int result=(chizu[0][0]==0)?mindp[H-1][W-1]+1:mindp[H-1][W-1];
  cout<<result;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) {return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }
ll f(ll x,  ll c, ll d) {
    ll res = x;
    res -= (x/c + x/d);
    res+= x/lcm(c,d);
    return res;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = f(b, c, d) - f(a-1, c, d);
    cout << ans << endl;
    return 0;
}

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

// 長さN, ...c2 c1 c0
ll dp[101][4][4][4];
ll mod = 1e9 + 7;

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

	// 初期化???
	// S = 333Sとしても問題ない
	dp[0][3][3][3] = 1;

	rep(l, n+1) {
		rep(c2, 4) {
			rep(c1, 4) {
				rep(c0, 4) {
					// S: ...c2 c1 c0 という文字列にaをつけることを考える
					// = S+1: ...c2 c1 c0 a
					// 数は同じ
					rep(a, 4) {
						// printf("長さ%d %d %d %d : %lld\n", l, c2,c1,c0,dp[l][c2][c1][c0]);
						if (c1==0 && c0==1 && a==2) {
							continue;
						}
						if (c1==0 && c0==2 && a==1) {
							continue;
						}
						if (c1==1 && c0==0 && a==2) {
							continue;
						}
						if (c2==0 && c0==1 && a==2) {
							continue;
						}
						if (c2==0 && c1==1 && a==2) {
							continue;
						}

						dp[l+1][c1][c0][a] += dp[l][c2][c1][c0];
						dp[l+1][c1][c0][a] %= mod;
					}
				}
			}
		}
	}

	ll sum = 0;
	rep(c2,4) {
		rep(c1,4) {
			rep(c0,4) {
				sum += dp[n][c2][c1][c0];
				sum %= mod;
			}
		}
	}

	cout << sum << endl;
}
	



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

int main()
{
 long long int n,m,ans=0,a1,a2;
  cin>>n>>m;
  if(m-(n*2)<0)
  {
    cout<<m/2;
    return 0;
  }
  else
  {
    ans = n;
    m -= n*2;
    ans += m/4;
    cout<<ans;
    
  }
    
 return 0; 
}

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

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

void FIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int n;
vector<int> a(100005);

int dp[100005];

int solve(int start)
{
	if (start == n - 1)
		return 0;

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

	int left = abs(a[start] - a[start + 1]) + solve(start + 1);

	int right = INT_MAX;

	if (start + 2 < n)
	{
		right = abs(a[start] - a[start + 2]) + solve(start + 2);
	}

	return dp[start] = min(left, right);
}

int32_t main()
{
	FIO();
	cin >> n;

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

	memset(dp, -1, sizeof(dp));

	cout << solve(0) << '\n';
	return 0;
}

Measured memory_bytes: 7944
#include <cstdio>
#include <set>
#include <vector>

using namespace std;

inline int abs(int x) { return (x >= 0) ? x : - x; }

int main()
{
    int n;
    long d;
    scanf("%d%ld", &n, &d);
    vector<long> a(n);
    for (int i = 0; i < n; i++)
        scanf("%ld", &a[i]);

    vector<long> b(n);
    for (int i = 0; i < n; i++)
        b[i] = a[i] + i * d;

    set<pair<long, int>> pairs;
    for (int i = 1; i < n; i++)
        pairs.insert(make_pair(b[i], i));

    long cost = 0;
    int j = 0;
    int k = 0;
    while (!pairs.empty()) {
        const int i = pairs.begin()->second;
        cost += abs(i - j) * d + a[i] + a[j];
        pairs.erase(pairs.begin());
        for (k++; k < i; k++) {
            cost += min(abs(i - k) * d + a[i] + a[k], abs(j - k) * d + a[j] + a[k]);
            pairs.erase(make_pair(b[k], k));
        }
        if (a[i] < a[j] + abs(i - j) * d)
            j = i;
    }

    printf("%ld\n", cost);

    return 0;
}


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

int main(){
	string S[3];
	cin >> S[0] >> S[1] >> S[2];
	int i=0;

	while(1){
		if(S[i].size()==0){
			cout << (char)(i+'A');
			return 0;
		}
		char c=S[i][0];
		S[i].erase(S[i].begin());
		i=c-'a';
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 1e9+7;
int main() {
	ll a,b;
	slld(a);slld(b);
	ll g=gcd(a,b);
	int ans=1,c;
	for(int i = 2; i <= sqrt(g); i++){
		c=0;
		while(g%i==0){
			g/=i;c++;
		}
		if(c)ans++;
	}
	if(g>1) ans++;
	pd(ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a ;
  int b ;
  scanf("%d %d", &a, &b);

  if(a < b){
    printf("a < b\n");
  }
  else if(a > b){
    printf("a > b\n");
  }
  else{
    printf("a == b\n");
  }
  return 0;


}



Measured memory_bytes: 2064
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int ai[n];
    int highest,current;
    long long total=0;
    cin >> highest;
    for(int i=1;i<n;i++){
        cin >> current;
        if(current<highest){
            total+=highest-current;
        }else{
            highest=current;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 3616
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int a,b,k;
            cin>>k>>a>>b;
            if(b/k==a/k && a%k!=0 && b%k!=0)
            {
                cout<<"NG"<<endl;
            }
            else
            {
                cout<<"OK"<<endl;
            }
        }
        return 0;
    }


Measured memory_bytes: 3688
# coding:utf-8


def main():
    N = int(input())
    # N, M = map(int, input().split())
    A = list(map(int, input().split()))
    # print(A)
    ans = 0

    for i in range(1, N-1):
        if A[i] > A[i-1] and A[i] < A[i+1]:
            # print(i)
            ans += 1
        elif A[i] < A[i-1] and A[i] > A[i+1]:
            # print(i)
            ans += 1
        elif A[i] == A[i-1] and A[i] < A[i+1]:
            # print(i)
            ans += 1
        elif A[i] == A[i+1] and A[i] < A[i-1]:
            # print(i)
            ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <string.h>

int main() {
	char S[10];
	scanf("%s",S);
	if (strlen(S) % 2 != 0) {
		printf("No");
		return 0;
	}
	else {
		for (int i = 0; i < strlen(S) / 2;i++) {
			if (S[2 * i] != 'h' || S[2 * i + 1] != 'i') {
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
j = -2
ans = 0
for i in a:
    if j == i-1:
        ans += c[i-2]
    j = i
ans += sum(b)
print(ans)

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

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

int lcm(int a,int b){
   return a*b/gcd(a,b);
}

bool prime_number(int n){
   vector<bool> i;
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int a,b,c,t,h=0;
   char d;
   
   while(cin >> a >> d >> b  >> d >> c){
      if(a==b) h++;
      if(a!=b&&c==sqrt(a*a+b*b)) t++;
   }
   cout << t << endl;
   cout << h << endl;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

inline int next(void) {
	register int ret = 0;
	register int neg = false;
	register int bit = getchar();
	for (; bit < '0'; bit = getchar())
		if (bit == '-')neg ^= true;
	for (; bit >= '0'; bit = getchar())
		ret = ret * 10 + bit - '0';
	return neg ? -ret : ret;
}

int n, m;

int root;
int cmpk;

struct node {
	int id;
	int pos[2];
	int son[2];
	int min[2];
	int max[2];
	inline friend bool operator < 
		(const node &a, const node &b) {
			return a.pos[cmpk] < b.pos[cmpk];
	}
}tree[500005];

inline void update(int t) {
	for (int k = 0; k < 2; ++k) {
		tree[t].min[k] = tree[t].max[k] = tree[t].pos[k];
		for (int i = 0, s; i < 2; ++i)if (s = tree[t].son[i]) {
			if (tree[t].min[k] > tree[s].min[k])
				tree[t].min[k] = tree[s].min[k];
			if (tree[t].max[k] < tree[s].max[k])
				tree[t].max[k] = tree[s].max[k];
		}
	}
}

int build(int l, int r, int k) {
	int d = (l + r) / 2; cmpk = k;
	nth_element(tree + l, tree + d, tree + r + 1);
	tree[d].son[0] = l == d ? 0 : build(l, d - 1, k ^ 1);
	tree[d].son[1] = r == d ? 0 : build(d + 1, r, k ^ 1);
	return update(d), d;
}

inline void build(void) {
	for (int i = 1; i <= n; ++i) {
		tree[i].id = i - 1;
		tree[i].pos[0] = next();
		tree[i].pos[1] = next();
	}
	root = build(1, n, 0);
}

int st[2], ed[2], ans[500005], tot = 0;

inline bool judge(const node &t) {
	return t.pos[0] >= st[0]
		&& t.pos[0] <= ed[0]
		&& t.pos[1] >= st[1]
		&& t.pos[1] <= ed[1];
}

inline bool check(const node &t) {
	return t.min[0] <= ed[0]
		&& t.max[0] >= st[0]
		&& t.min[1] <= ed[1]
		&& t.max[1] >= st[1];
}

void query(int t) {
	if (judge(tree[t]))ans[tot++] = tree[t].id;
	if (tree[t].son[0] && check(tree[tree[t].son[0]]))query(tree[t].son[0]);
	if (tree[t].son[1] && check(tree[tree[t].son[1]]))query(tree[t].son[1]);
}

inline void query(void) {
	for (int i = 0; i < m; ++i, tot = 0) {
		st[0] = next();
		ed[0] = next();
		st[1] = next();
		ed[1] = next();
		tot = 0;
		query(root);
		sort(ans, ans + tot);
		for (int j = 0; j < tot; ++j)
			printf("%d\n", ans[j]);
		puts("");
	}
}

signed main(void) {
	n = next(); build();
	m = next(); query();
	//system("pause");
}

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

typedef long long 		ll;
typedef vector<ll> 		vll;
typedef pair<ll,ll> 	pll;
typedef vector<pll> 	vpll;
typedef vector<int> 	vi;
typedef pair<int,int> 	pii;
typedef vector<pii> 	vpii;

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				cerr<<"yaha aya"<<"\n"
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	int n;
	cin >> n;
	int boss[n+1];
	fill(boss, 0);
	rep(i, 2, n){
		int temp;
		cin >> temp;
		++boss[temp];
	}
	rep(i, 1, n){
		cout << boss[i] << "\n";
	}
	nl;
}

Measured memory_bytes: 4380
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
 
 
using namespace std;
 
int main(int argc, char *argv[]){
 
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i = 0; i < N; i++){
    cin >> D[i];
  }
  int M;
  cin >> M;
  vector<int> T(M);
 
  sort(D.begin(), D.end());
  for(int i = 0; i < M; i++){
    cin >> T[i];
  }
  sort(T.begin(), T.end());
  int dcounter = 0;
  int tcounter = 0;
  while(dcounter < N && tcounter < M){
    if(D[dcounter] == T[tcounter]){
      dcounter++;
      tcounter++;
    }else{
      dcounter++;
    }
    if((N-dcounter) < (M-tcounter))
      goto NO;
  }
 
  cout << "YES" << endl;
  return 0;
 
  NO:
  cout << "NO" << endl;
  return 0;
}

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

using namespace std;
const int inf =  10e9 + 5;
int main() {
	int n;
	cin>>n;
	vector<int> dp(3);
	
	for(int days = 0; days < n;++days) {
		vector<int> cost(3);
		for(int i = 0;i<3;i++) {
			cin>>cost[i];
		}
		vector<int> newDp(3, 0);
		for(int i = 0;i<3;i++) {
			for(int j = 0;j<3;j++) {
				if(i!=j) {
					newDp[j] = max(newDp[j], dp[i] + cost[j]);
				}
			}
		}
		dp = newDp;
	}
	
	
	cout<< max({dp[0], dp[1], dp[2]})<<endl;
	
}

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

int main() {
  vector<vector<int>> A(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> A.at(i).at(j);
  int N;
  cin >> N;
  vector<int> b(N);
  rep(i, N) cin >> b.at(i);
  rep(i, 3) rep(j, 3) rep(k, N) if (A.at(i).at(j) == b.at(k)) A.at(i).at(j) = 0;
  bool ans = false;
  rep(i, 3) if (A.at(i).at(0) == 0 && A.at(i).at(1) == 0 && A.at(i).at(2) == 0) ans = true;
  rep(i, 3) if (A.at(0).at(i) == 0 && A.at(1).at(i) == 0 && A.at(2).at(i) == 0) ans = true;
  if (A.at(0).at(0) == 0 && A.at(1).at(1) == 0 && A.at(2).at(2) == 0) ans = true;
  if (A.at(0).at(2) == 0 && A.at(1).at(1) == 0 && A.at(2).at(0) == 0) ans = true;
  if (ans == true) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3576
while True:
    sum = 0
    n, x = map(int, input().split())
    if n == x == 0:
        break
    for i in range(1, n+1):
        for j in range(i+1, n+1):
            for k in range(j+1, n+1):
                if (i + j + k) == x:
                    sum += 1
    print(sum)       


Measured memory_bytes: 5596
$_=<>;($a,$b)=glob<>;s/^F*/$a-=length$&/e;s#F+#push@{$`=~y/T//&1},length$&#ge;$s=$_?b:a,map$$s>0?$$s-=$_:($$s+=$_),sort{$b-$a}@$_ for 0,1;print$a|$b?No:Yes

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;++i)
	{
		if(i%k==0)
		{
			cout<<"OK";
			return 0;
		}
	}	
	cout<<"NG";
} 

Measured memory_bytes: 3636
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
# from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

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

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n = I()

# 数字nを10進数からb進数へ変換
def base10to(n,b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

# 数字numをb進数から10進数へ変換
def base10from(num, b):
    n = 0
    numlist = list(num);
    while (numlist):
        n *= b
        n += int(numlist.pop(0))
    return n

count = 0

for i in range(3,10):
    m = 3**i
    for j in range(m):
        s = list(base10to(j,3))
        a = "".join(s)
        b = a.zfill(i)
        c = list(b)
        for k in range(i):
            if c[k]=="0":
                c[k] = "3"
            elif c[k]=="1":
                c[k] = "5"
            elif c[k]=="2":
                c[k] = "7"
            else:
                print("E")
        d = "".join(c)
        e = int(d)
        if e<=n:
            if len(set(c))==3:
                count += 1
            else:
                pass
        else:
            print(count)
            exit()

print(count)
exit()

Measured memory_bytes: 59480
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, x, a[114];
int ans;
int cnt;

signed main() {
	cin >> n >> x;
	ans = 1;
	rep(i, n) cin >> a[i];
	rep(i, n) {
		if (cnt + a[i] <= x) {
			ans++;
			cnt += a[i];
		}
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define MAX 500015
#define NIL -1

typedef struct{ 
	int p, lc, rc, key;
}node;

node T[MAX];
int i, m, size=0, root;
char inst[8];

void insert(int z){
	int x,y;
	y = NIL; //parent of x
	x = root;
	size++;
	T[size].key = z;
		
	while (x != NIL){// || x != 0){
		y = x; //parent
		if (z < T[x].key)
			x = T[x].lc;
		else x= T[x].rc;
	}
	T[size].p = y;
	
	if (y == NIL)
		root = size;
	else if (z < T[y].key)
		T[y].lc = size;
	else T[y].rc = size;
}

int find(int x, int k){
	if (k == T[x].key)
		return 1;
	if (k < T[x].key && T[x].lc != NIL && T[x].lc != 0){
		if (find(T[x].lc, k))
			return 1;
	}
	if (k > T[x].key && T[x].rc != NIL && T[x].rc != 0) {
		if (find(T[x].rc, k))
			return 1;
	}
	return 0;
}

void preOrder(int u){
	if (u == NIL)
		return;
	printf(" %d", T[u].key);
	preOrder(T[u].lc);
	preOrder(T[u].rc);
}

void inOrder(int u){
	if (u == NIL)
		return;
	inOrder(T[u].lc);
	printf(" %d", T[u].key);
	inOrder(T[u].rc);
}


int main(void) {
	int k,f;
	root = NIL;
	scanf("%d", &m);
	//initialize
	for (i=0; i<m; i++){
		T[i].p = T[i].lc = T[i].rc = T[i].key = NIL;
	}
	
	for(i=0; i<m; i++){
		scanf("%s", &inst);
		if (inst[0] == 'i'){
			scanf("%d", &k);
			insert(k);
		}
		else if (inst[0] == 'f'){
			scanf("%d", &f);
			if(find(1, f))
				printf("yes");
			else printf("no");
			printf("\n");
		}
		else{
				inOrder(root);
				printf("\n");
				preOrder(root);
				printf("\n");
			
		}
	}

	return 0;
}



Measured memory_bytes: 9520
n = int(input())
info = [list(map(int, input().split())) for i in range(2*n)]

for i in range(n):
    info[i].append("r")
for i in range(n, 2*n):
    info[i].append("b")
info = sorted(info)
a = []
for i in range(2*n):
    a.append(info[i][1:3])
used = [False] * (2*n)
ans = 0
for i in range(2*n):
    for j in range(2*n):
        if a[j][1] == "r" and a[j][0] == 2*n - (i+1):
            tmp = j
            break
    else:
        continue
    for j in range(tmp+1, 2*n):
        if a[j][1] == "b" and a[tmp][0] < a[j][0] and not used[j]:
            used[j] = True
            ans += 1
            break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
	int n, x;
	cin >> n >> x;
	int rem = x;
	int a[102];
	rep(i, n) cin >> a[i];
	sort(a, a+n);
	rep(i, n) {
		if (rem < a[i]) {
			cout << i << endl;
			return 0; 
		}
		rem -= a[i];
	}
	if (rem == 0) cout << n << endl;
	else cout << n-1 << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
import math

def calc_distance(pos_i, pos_j):
  return math.sqrt((pos_i[0] - pos_j[0]) ** 2 + (pos_i[1] - pos_j[1]) ** 2)

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N = int(input())

pos_dict = {i: list(map(int, input().split())) for i in range(1, N + 1)}

sum_distance = 0
for p in itertools.permutations(range(1, N + 1)):
  for i in range(len(p) - 1):
    sum_distance += calc_distance(pos_dict[p[i]], pos_dict[p[i+1]])

print(sum_distance / permutations_count(N, N))

Measured memory_bytes: 3064
#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};
ll N=1e5+5;



int main(){
    IOS;
    make(string,s);
    stack <char> st;
    ll n=s.length();
    fr(i,n){
        if(s[i]!='B') st.push(s[i]);
        else{
            if(!st.empty()) st.pop();
        }
    }
    string t="";
    while(!st.empty()) {t+=st.top(); st.pop();}
    reverse(t.begin(),t.end());
    cout<<t<<endl;



    return 0;
}


Measured memory_bytes: 3652
SA = str(input())
SB = str(input())
SC = str(input())
a=[]
b=[]
c=[]
for i in range(len(SA)):
    a.append(SA[i])

for i in range(len(SB)):
    b.append(SB[i])

for i in range(len(SC)):
    c.append(SC[i])

p = a.pop(0)


for _ in range(len(a)+len(b)+len(c)):
    if p=='a':
        if len(a)!=0:
            p=a.pop(0)
        else:
            print('A')
            break
    if p=='b':
        if len(b)!=0:
            p=b.pop(0)
        else:
            print('B')
            break
    if p=='c':
        if len(c)!=0:
            p=c.pop(0)
        else:
            print('C')
            break


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int Nums[5];
  int k;
  rep(i, 0, 5) {
    scanf("%d", &Nums[i]);
  }
  scanf("%d", &k);

  char yes[5] = "Yay!";
  char no[5] = ":(";
  char *ans = yes;
  rep(i, 0, 5) {
    rep(j, i, 5) {
      if (abs(Nums[i] - Nums[j]) > k) {
        ans = no;
        break;
      }
    }
  }
  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		int max = h[0];
		boolean flag = true;
		for(int i = 1; i < n; i++) {
			if(h[i] < max-1) {
				flag = false;
				break;
			}
			if(h[i] > max) {
				max =h[i];
			}
		}
		if(flag) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 49216
#include <bits/stdc++.h>
using namespace std;
#define y1 adfasfafa
const int maxn = 2e5+7;
typedef long long ll;

int n,m;
int ar[maxn];

char s[maxn],t[maxn];
int l[maxn],r[maxn],u[maxn],d[maxn];
int main()
{
    int h,w;
    scanf("%d%d",&h,&w);
    scanf("%d",&n);
    int sr,sc;scanf("%d%d",&sr,&sc);
    scanf("%s",s);
    scanf("%s",t);
    int x,y,flag=1;
    x=sr,y=sc;
    int mx=0,ins1=0,ins2=0;
    for(int i=n-1;i>=0;i--){
        if(t[i]=='R'){
            if(ins1>0)ins1--;
        }
        if(t[i]=='L'){
            if(ins2>0)ins2--;
        }
        if(s[i]=='L')ins1++;
        if(s[i]=='R')ins2++;
        l[i] = ins1+1;
        r[i] = w-ins2;
        if(l[i]>r[i]){
            flag=0;
            break;
        }
    }
    if(y>=l[0] && y<=r[0]);
    else flag=0;
    //for(int i=0;i<n;i++)cout<<l[i]<<" ";cout<<endl;
    //for(int i=0;i<n;i++)cout<<r[i]<<" ";cout<<endl;

    memset(l,0,sizeof(l));
    memset(r,0,sizeof(r));
    mx=0,ins1=0,ins2=0;
    for(int i=n-1;i>=0;i--){
        if(t[i]=='D'){
            if(ins1>0)ins1--;
        }
        if(t[i]=='U'){
            if(ins2>0)ins2--;
        }
        if(s[i]=='U')ins1++;
        if(s[i]=='D')ins2++;
        l[i] = ins1+1;
        r[i] = h-ins2;
        if(l[i]>r[i]){
            flag=0;
            break;
        }
    }
    if(x>=l[0] && x<=r[0]);
    else flag=0;
    //for(int i=0;i<n;i++)cout<<l[i]<<" ";cout<<endl;
    //for(int i=0;i<n;i++)cout<<r[i]<<" ";cout<<endl;



    printf("%s\n",flag==1?"YES":"NO");
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    std::string s, t;
    std::cin >> s >> t;
    std::vector<std::vector<int>> dp(s.size() + 1, std::vector<int>(t.size() + 1));
    for (int i = 1; i <= s.size(); i++) {
        for (int j = 1; j <= t.size(); j++) {
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            } else {
                dp[i][j] = std::max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }

    std::string ret = "";
    int i = s.size(), j = t.size();
    while (i != 0 && j != 0) {
        if (s[i - 1] == t[j - 1]) {
            ret += s[i - 1];
            i--; j--;
        } else if (dp[i][j - 1] > dp[i - 1][j]) {
            j--;
        } else {
            i--;
        }
    }

    // std::cout << dp.back().back() << std::endl;
    for (int i = ret.size() - 1; i >= 0; i--) std::cout << ret[i];
    std::cout << std::endl;

    return 0;
}

Measured memory_bytes: 35584
#include<stdio.h>

int main(){
    int d,t,s;
    scanf("%d%d%d",&d,&t,&s);
    int key = d/s;
    if(d%s != 0){
        key = key+1;
    }
    //printf("%d\n",key);
    if(key <= t){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

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

    vector<vector<int>> vv(N);
    for (int i = 0; i < N; i++) {
        int t, d;
        cin >> t >> d;

        vv[--t].push_back(d);
    }

    for (auto& v : vv) {
        sort(v.rbegin(), v.rend());
    }

    vector<int> inc, others;
    for (auto v : vv) {
        for (int i = 0; i < v.size(); i++) {
            if (!i) inc.push_back(v[i]);
            else others.push_back(v[i]);
        }
    }

    sort(inc.begin(), inc.end());
    sort(others.begin(), others.end());

    inc.push_back(0);
    others.push_back(0);

    reverse(inc.begin(), inc.end());
    reverse(others.begin(), others.end());

    for (int i = 1; i < inc.size(); i++) {
        inc[i] += inc[i - 1];
    }

    for (int i = 1; i < others.size(); i++) {
        others[i] += others[i - 1];
    }

    int ans = 0;
    for (int i = 1; i <= K; i++) {
        if (i >= inc.size()) break;
        if (K - i >= others.size()) continue;

        int t = i * i;
        t += inc[i] + others[K - i];
        ans = max(ans, t);
    }
    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n;

	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		int k, p;
		scanf("%d%d", &k, &p);
		printf("%d\n", (k % p == 0) ? (p) : (k % p));
	}

	return (0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
int n, a[55], b[55];
set<long long> s[55], t;
bool fuck(int x, int y, long long v) {
	set<int> st, ed;
	st.insert(x);
	for (int i = 50; i > 0; i--) {
		if (v >> i & 1) {
			for (int j: st) {
				ed.insert(j);
				ed.insert(j % i);
			}
			st = ed;
			ed.clear();
		}
	}
	if (st.find(y) != st.end()) {
		return true;
	}
	return false;
}

bool fuckall(long long v) {
	for (int i = 0; i < n; i++) {
		if (!fuck(a[i], b[i], v)) {
			return false;
		}
	}
	return true;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	long long v = 0;
	for (int i = 50; i > 0; i--) {
		if (!fuckall(v | ((1LL << i) - 2))) {
			v |= 1LL << i;
		}
	}
	if (v == 2251799813685246LL) {
		printf("-1\n");
	} else {
		printf("%lld\n", v);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 1) {
      if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

const double PI = 3.1415926535897932384626433832795;

int main() {
	double X; cin >> X; X = X * PI / 180.0;
	double x = cos(0), y = sin(0), t = 0;
	int n = 1;
	while (!(fabs(x) < 1e-9 && fabs(y) < 1e-9)) {
		t += X;
		x += cos(t);
		y += sin(t);
		n++;
	}
	printf("%d\n", n);
}

Measured memory_bytes: 4076
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_101_B.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N      PIC X(11).
    01 NUM    PIC 9(10).
    01 X      PIC 9(10).
    01 R      PIC 9(10).
    01 i      PIC 9(2).
    01 SN     PIC 9(3).
    01 now    PIC 9(1).
    01 ans    PIC Z(18).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N.

    MOVE N TO NUM.
    MOVE 0 TO SN.

    PERFORM VARYING i FROM 1 BY 1 UNTIL N(i:1) = SPACE
        MOVE N(i:1) TO now
        COMPUTE SN = SN + now
    END-PERFORM.

    DIVIDE SN INTO NUM GIVING X REMAINDER R.

    IF R = 0 THEN
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

    STOP RUN.


Measured memory_bytes: 636
#include <stdio.h>
typedef long long ll;
#define MOD 1000000007
int main() {
	int n, num[1000] = {0}, x;
	ll ans = 1;
	scanf("%d", &n);
	for (int i = 2; i <= n; i++) {
		x = i;
		for (int j = 2; j <= x; j++) {
			while (x % j == 0) {
				num[j - 1]++;
				x /= j;
			}
		}
	}
	for (int i = 1; i < 1000; i++) {
		ans *= num[i] + 1;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int i,j,temp,a[3];
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<3-1;i++){
    for(j=0;j<3-i-1;j++){
      if(a[j]>a[j+1]){
	temp=a[j];
	a[j]=a[j+1];
	a[j+1]=temp;
      }
    }
  }
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return(0);
}

Measured memory_bytes: 2724
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
ll mergecount(vector<ll> &a) {
    ll count = 0;
    int n = (int)a.size();
    if (n > 1) {
        vector<ll> b(a.begin(), a.begin() + n/2);
        vector<ll> c(a.begin() + n/2, a.end());
        count += mergecount(b);
        count += mergecount(c);
        for (int i = 0, j = 0, k = 0; i < n; ++i)
            if (k == c.size())       a[i] = b[j++];
            else if (j == b.size())  a[i] = c[k++];
            else if (b[j] <= c[k])   a[i] = b[j++];
            else                   { a[i] = c[k++]; count += n/2 - j; }
    }
    return count;
}
int main(){
    int n;
    ll k;
    scanf("%d %lld",&n,&k);
    vector<ll>a(n);
    vector<ll>b(n+1);
    b[0] = 0;
    rep(i,n){
        scanf("%lld",&a[i]);
        b[i+1] = a[i] - k + b[i];
    }
    ll N = (ll)n;
    cout << (ll)N*(N+1)/2 -mergecount(b) << endl;
}

Measured memory_bytes: 6528
str = input()
if str == 'SUN':
    num = 7
elif str == 'MON':
    num = 6
elif str == 'TUE':
    num = 5
elif str == 'WED':
    num = 4
elif str == 'THU':
    num = 3
elif str == 'FRI':
    num = 2
elif str == 'SAT':
    num = 1
print(num)

Measured memory_bytes: 3060
w = int(input())
n = int(input())

wlst = [i for i in range(1, w+1)]
for i in range(n):
    inputlst = list(map(int, input().split(',')))
    a, b = inputlst[0]-1, inputlst[1]-1
    wlst[a], wlst[b] = wlst[b], wlst[a]

for i in wlst:
    print(i)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    string s, t;cin>>s>>t;
    int slen = s.size();
    int tlen = t.size();
    int max_v = 0;
    for (int i = 0; i < slen - tlen + 1; i++) {
        string k = s.substr(i, tlen);
        int cnt = 0;
        for(int j = 0; j < tlen; j++) {
            if(k[j] == t[j]) cnt++;
        }
        if(max_v < cnt) max_v = cnt;
    }
    cout << tlen - max_v;
}


Measured memory_bytes: 3656
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    last = [0]*26
    ans = []
    for d in range(D):
        s = 0
        t = 0
        for i in range(26):
            tmp = S[d][i]
            if tmp > s:
                s = tmp
                t = i + 1
        ans.append(t)
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()


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

using namespace std;

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

const int N = 1e5 + 5;

char s[N];
int n,a[N],ans[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> (s + 1);
  n = strlen(s + 1);
  for (int i = 1 ; i <= n ; i++)
    if (s[i] == 'L') {
      ans[i] += a[i % 2];
      ans[i - 1] += a[(i + 1) % 2];
      a[1] = a[0] = 0;
    }
    else
      a[i % 2]++;
  a[1] = a[0] = 0;
  for (int i = n ; i >= 1 ; i--)
    if (s[i] == 'R') {
      ans[i] += a[i % 2];
      ans[i + 1] += a[(i + 1) % 2];
      a[1] = a[0] = 0;
    }
    else
      a[i % 2]++;
  for (int i = 1 ; i <= n; i++)
    cout << ans[i] << " ";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,y,w,u,v;
  cin>>x>>y;
  vector<int> z(x);
  for(w=0;w<y;w++){
    cin>>u>>v;
    u--;v--;
    z[u]++;
    z[v]++;
  }
  for(w=0;w<x;w++) cout<<z[w]<<endl;
}

Measured memory_bytes: 3612
#include<stdio.h>

int main(void)
{
int S,x,h,m,s;

scanf("%d\n",&S);

h=S/(60*60);

x=S%(60*60);

m=x/60;

s=x%60;

printf("%d:%d:%d\n",h,m,s);

return 0;
}

Measured memory_bytes: 596
#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
#define int long long
using namespace std;
signed main() {
    int N;
    cin >> N;
    cout << 48 - N << endl;
}


Measured memory_bytes: 3548
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    str_N=str(N)
    ans=0
    ans2=0
    for i in range(1,N+1):
        s=str(i)
        if s[-1]=='0':
            continue
        if s[0]==s[-1]:
            ans+=1
        if int(s[-1]+s[0])<=N:
            ans+=1
        f=True
        n=1
        while f:
            z=int(s[-1]+str(10**n-1)+s[0])
            if z<=N:
                ans+=10**n
            else:
                if int(s[-1]+str('0'*n)+s[0])>N:
                    pass
                else:
                    m=int(str_N[1:-1])
                    ans+=m
                    if int(str_N[-1])>=int(s[0]):
                        ans+=1
                f=False
                break
            n+=1
    print(ans-ans2)
                

if __name__ == '__main__':
    main()


Measured memory_bytes: 42732
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef struct
{
	int a;
	int b;
} abc086a_t;

int product (const abc086a_t given_data)
{
	return given_data.a * given_data.b;
}

bool isProdEven (const abc086a_t given_data)
{
	return ( ( product(given_data) % 2 ) == 0 );
}

void ABC086A (const abc086a_t given_data)
{
	if ( isProdEven(given_data) ) printf( "Even\n" );
	else                          printf( "Odd\n"  );
}

int main (void)
{
	// variables for `main`
	abc086a_t given_data;
	int       retval_scanf;

	// STEP.01
	// read out the given data
	retval_scanf = scanf("%d %d", &given_data.a, &given_data.b);

	// STEP.02
	// calculate & output the answer
	ABC086A(given_data);

	// STEP.END
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int n;
	cin >> n;
	vi(v)(n);
	FOR(n)
		cin >> v[i];
	sort(ALL(v));
	int m = (n - 1) / 2;
	cout << v[m + 1] - v[m] << endl;
	return 0;
}

Measured memory_bytes: 640