akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)
    x =x->left;
    return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
    return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){

  if(k < u->key) u=u->left;

  else u=u->right;
  }
  return u;
  
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL) y = z;
  else y = treeSuccessor(z);

  if(y->left != NIL) x=y->left;
  else x = y->right;

  if(x!=NIL) x->parent = y->parent;
  if(y->parent==NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right =x;
  
  if(y!= z) z->key = y->key;
  free(y);
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

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

void inorder(Node u){
  if(u == NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  
}
void preorder(Node u){
  if(u ==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  
}


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

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20452
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	int x=s.length();
	
	if(k>=x){
		cout<<s;
	}
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"...";
	}
	
}

Measured memory_bytes: 3628
n = int(input())
v = list(map(int,input().split()))

v1 = [v[i] for i in range(n) if i%2 == 1]
v2 = [v[i] for i in range(n) if i%2 == 0]
            
import collections

v1n = collections.Counter(v1)
v2n = collections.Counter(v2)

v1ns = v1n.most_common(2)
v2ns = v2n.most_common(2)

a = v2ns[0][1]
c = v1ns[0][1]
if v1ns[0][0]!=v2ns[0][0]:
    print(n-a-c)
else:
    if len(v1ns)==1:
        d = 0
    else:
        d = v1ns[1][1]
    if len(v2ns)==1:
        b = 0
    else:
        b = v2ns[1][1]
    print(min(n-a-d,n-c-b))

Measured memory_bytes: 23252
import math

N,M=map(int,input().split())
s=[]
c=[]
for i in range(M):
    a, b = map(int,input().split())
    s.append(a)
    c.append(b)

found = False

start = pow(10,N-1)
stop = pow(10,N)
if N == 1:
    start = 0

for i in range(start, stop):
    
    i_str = str(i)

    passed = True
    for j in range(M):
        if not i_str[s[j]-1] == str(c[j]):
            passed = False
            break
    if passed:
        found = True
        print(i)
        break

if not found:
    print("-1")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
     vector<int> b(N); 
      vector<int> c(N-1);
    for(int i=0;i<N;i++){
    cin >> a[i];
    --a[i];
    }
        for(int i=0;i<N;i++)
    cin >> b[i];
        for(int i=0;i<N;i++)
    cin >> c[i];
    int ans=0;
    for(int i=0;i<N;i++){
    ans += b[a[i]];
    if(a[i-1]+1==a[i] && i>0)
    ans += c[a[i-1]] ;   
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=5e6+69, INF=2e9+6969;

int qq;

int main()
{
	int n;
	cin >> n;
	ll ans =0;
	ans += 1000*(n/500);
	n%=500;
	ans += 5*(n/5);
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
   while(~scanf("%d",&n))
   {
       if(n%10==9||n/10==9)
    {
        printf("Yes\n");
    }
    else
        printf("No\n");
    return 0;
   } 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    int n, k; cin >> n>> k;
    int res = 0;
    double mid = k/2.0;
    REP(i, n){
        int x;
        cin >> x;
        if(mid > x) res += 2*x;
        else res += (k - x)*2;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	if((n*m)&1){
		cout<<"Odd";
	}else{
		cout<<"Even";
	}
    return 0;
}
//.........

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
#define VL vector<lol>
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    //lol result{0};
    char ch; cin >> ch;
    int a = (int)ch;
    a++;
    cout << (char)a << endl;

    //cout << result << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define INF 100000000
using namespace std;
const int mod = 1000000007;

int main() {

  int64_t ans,N,b,r;
  cin>>N>>b>>r;
  ans=b*(N/(b+r));
  if(N%(b+r)>=b)ans+=b;
  else if(N%(b+r)<b)ans+=N%(b+r);
  //vector<int> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int>> A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

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

int f(int a, int b) {
	return max(to_string(a).size(), to_string(b).size());
}

signed main(void)
{
	ll n;
	cin >> n;
	int ret = INF;
	for(int i=1; i*i<=n; ++i) {
		if(n%i==0) ret = min(ret, f(i, n/i));
	}
	cout << ret << endl;

	return 0;
}


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

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
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;
}

class UnionFind {
private:
	vector<int>par;
public:
	//宣言
	UnionFind(int n) {
		for (int i = 0; i < n; i++) par.push_back(-1);
	}

	//根を求める
	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	//同じグループか
	bool same(int x, int y) {
		return root(x) == root(y);
	}

	//併合
	void unite(int x, int y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return;
	}

	//連結成分のサイズ
	int size(int x) {
		return -par[root(x)];
	}
};

signed main() {
	int n, m, a[114514], b[114514];
	cin >> n >> m;
	UnionFind uf(n);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	int out = n * (n - 1) / 2;
	vector<int>ans;
	for (int i = m - 1; i >= 0; i--) {
		ans.push_back(out);
		if (uf.same(a[i], b[i])) continue;
		else {
			out -= uf.size(a[i]) * uf.size(b[i]);
			uf.unite(a[i], b[i]);
		}
	}
	reverse(ans.begin(), ans.end());
	rep(i, m) {
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B;
    cin >>A>>B;
    rep(i,1000000){
        ll a = i*0.08;
        ll b = i*0.1;
        //cout <<i*0.08 <<endl;
        if(a == A && b==B){
            cout << i<<endl;
            return 0;
        }
    }
    cout << -1 << endl;


    return 0;
    

}

Measured memory_bytes: 3612
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define gnr(i,l,r) for(int i=int(r)-1; i>=int(l); i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;


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

  cin>>s; n=s.size();
  rep(i,n-2){
    if(s[i]==s[i+1]){cout<<i+1<<' '<<i+2<<'\n'; return 0;}
    if(s[i]==s[i+2]){cout<<i+1<<' '<<i+3<<'\n'; return 0;}
  }
  if(s[n-2]==s[n-1]){cout<<n-1<<' '<<n<<'\n'; return 0;}
  cout<<"-1 -1\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
pii X[200200];
int ans[200200];

signed main() {
    cin >> N;
    rep(i, N) {
        int x;
        cin >> x;
        X[i] = pii(x, i);
    }
    sort(X, X + N);
    rep(i, N / 2) {
        ans[X[i].second] = X[N / 2].first;
    }
    for (int i = N / 2; i < N; ++i) {
        ans[X[i].second] = X[N / 2 - 1].first;
    }
    rep(i, N) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 6912
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	for(string line; getline(cin, line) && line[0] != '0';)
	{
		int points = 0, one = 0;
		
		istringstream iss(line);
		for(string word; iss >> word; )
		{
			int tmp = atoi(word.c_str());
			
			if(tmp == 1) one++;
			else points += (tmp < 10 ? tmp : 10);
		}
		
		int total = 0;
		for(int i = 0; i <= one; i++)
		{
			int tmp = points + i * 10 + one;
			
			if(tmp <= 21) chmax(total, tmp);
		}
		
		cout << (total <= 21 ? total : 0) << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>

int main()
{
    int asc[3], temp;
    std::cin>>asc[0]>>asc[1]>>asc[2];

    for(int i=0; i<3; i++)
    {
        for(int j=i; j<3; j++)
        {
            if (asc[i]>asc[j]) {
                temp = asc[i];
                asc[i] = asc[j];
                asc[j] = temp;
            } 
        }
    }

    std::cout<<asc[0]<<" "<<asc[1]<<" "<<asc[2]<<std::endl;
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && c != a) cout << "Yes" << endl;
    else if (a == c && b != a) cout << "Yes" << endl;
    else if (c == b && a != b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

  int H,W;

  cin >> H >> W ;

  vector<string> S(H);

  for(int i=0;i<H;i++) cin >> S.at(i);

  vector<int> dx={0,1,1,1,0,-1,-1,-1};
  vector<int> dy={1,1,0,-1,-1,-1,0,1};//時計回りに８通りの座標変化

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){

      if(S.at(i).at(j)=='#') continue;

      int count=0;
      
      for(int d=0;d<8;d++){
        int id=i+dy.at(d);
        int jd=j+dx.at(d);

        if(id<0||H<=id) continue;
        if(jd<0||W<=jd) continue;
        if(S.at(id).at(jd)=='#') count++;
      }

      S.at(i).at(j)=(char)(count+'0');
    
    }
  }//全てのマスについて、その周囲のマスに存在する#のかずに置き換え



  for(int i=0;i<H;i++) cout << S.at(i) << endl;
 
  return 0;
}

Measured memory_bytes: 256
N = int(input())
s = ["" for i in range(N)]
t = ["" for i in range(N)]
for i in range(N):
    s[i], t[i] = map(str, input().split())
    t[i] = int(t[i])
X = str(input())
for i in range(N-1):
    if s[i] == X:
        print(sum(t[i+1:]))
        exit()
print(0)

Measured memory_bytes: 3316
#include<iostream>
using namespace std;
const int maxn = 4e5 + 5;
const int MOD = 998244353;
#define LL long long
LL n,a,b,k;
LL fac[maxn];
LL inv[maxn];
LL C(LL x){
    return (fac[n] * inv[x]%MOD) *inv[n-x] %MOD;
}
int main()
{
    cin>>n>>a>>b>>k;
    if(k == 0){
        cout<<1<<endl;
        return 0;
    }
    fac[0]=inv[0]=inv[1]=1;
	for (int i=2;i<=n;i++)
		inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
	for (int i=1;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%MOD;
		inv[i]=1ll*inv[i-1]*inv[i]%MOD;
	}
	LL ans = 0;
    for(int red = 0;red<=n;red++){
        LL rest = k - red * a;
        LL blue = rest / b;
        if(rest % b == 0 && blue <= n && rest >= 0){
            ans = (ans + C(red) * C((LL)rest / b)) % MOD;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int ck(int v1[], int v2[], int n){
    int a=1;;
    for (int i=0; i<n; i++){
        if (v1[i]!=v2[i]){
            a=0;
            break;
        }
    }
    return a;
}
long long a=1,b=1,n,c,d;
string ss,s1,s2;
int main(){
    cin>>a>>b;
    cout<<(a*b)/__gcd(a,b);
}


Measured memory_bytes: 256
n=int(input())
ans=0
if n<10:
    print(1)
    exit()
count=[[0]*10 for _ in range(10)]

for i in range(1,n+1):
    tmp=str(i)
    a=int(tmp[0])
    b=int(tmp[-1])
    count[a][b]+=1

for i in range(1,10):
    for j in range(1,10):
        ans+=count[i][j]*count[j][i]

print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (c - (a - b) < 0){
    cout << "0\n";
  }
  else{
   cout << c - (a - b) << '\n';    
  }
  return 0; 
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=200005;
int n,m;
char s[maxn];
vector<int>edge[maxn];
queue<int>q;
int cntA[maxn],cntB[maxn];
bool bad[maxn];

int main(){
	scanf("%d%d%s",&n,&m,s+1);
	REP(i,m){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
		if(s[u]=='A')cntA[v]++;
		else cntB[v]++;
		if(s[v]=='A')cntA[u]++;
		else cntB[u]++; 
	}
	REP(i,n)if(!cntA[i]||!cntB[i])q.push(i),bad[i]=true;
	while(!q.empty()){
		int x=q.front();q.pop();
		rep(i,int(edge[x].size())){
			int y=edge[x][i];
			if(s[x]=='A')cntA[y]--;
			else cntB[y]--;
			if(!cntA[y]||!cntB[y]){
				if(!bad[y]){
					bad[y]=true;
					q.push(y);
				}
			}
		}
	}
	REP(i,n)if(!bad[i]){
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
} 

Measured memory_bytes: 12544
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;
    cin >> h >> w >> k;
    vvint ans(h,vint(w,0));
    int now=0;
    vint x(k),y(k);
    REP(i,h){
        string s;
        cin >> s;
        REP(j,w){
            if(s[j]=='#'){
                x[now]=j;
                y[now]=i;
                now++;
                ans[i][j]=now;
            }
        }
    }
    REP(i,k){
        int ny = y[i];
        int s=x[i];
        int e=x[i];
        while(s>0){
            if(ans[ny][s-1]==i+1||ans[ny][s-1]==0){
                s--;
            }else{
                break;
            }
        }
        while(e+1<w){
            if(ans[ny][e+1]==i+1||ans[ny][e+1]==0){
                e++;
            }else{
                break;
            }
        }
        for(int j=s;j<=e;j++){
            ans[ny][j]=i+1;
        }
        int nxy = ny-1;
        while(nxy>=0){
            bool f=true;
            for(int j=s;j<=e;j++){
                if(ans[nxy][j]==i+1||ans[nxy][j]==0){

                }else{
                    f=false;
                    break;
                }
            }
            if(f){
                for(int j=s;j<=e;++j){
                    ans[nxy][j]=i+1;
                }
                nxy--;
            }else{
                break;
            }
        }
        nxy = ny+1;
        while(nxy<h){
            bool f=true;
             for(int j=s;j<=e;j++){
                if(ans[nxy][j]==i+1||ans[nxy][j]==0){

                }else{
                    f=false;
                    break;
                }
            }
            if(f){
                for(int j=s;j<=e;++j){
                    ans[nxy][j]=i+1;
                }
                nxy++;
            }else{
                break;
            }
        }
    }
    REP(i,h){
        REP(j,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
// AtCoder ABC104: C - To Infinity
// 2019.9.11 bal4u

#include <stdio.h>

char S[105];

int main()
{
	int i, c; long long K;
	
	scanf("%s%lld", S, &K); K--;
	for (i = 0; S[i]; i++) {
		if (S[i] != '1')  break;
		if (i == K) break;
	}
	if (S[i] == 0) c = '1';
	else c = S[i];
	putchar(c), putchar('\n');
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define int long long
using namespace std;
int squr(int n)
{
	return ceil(sqrt(n)) == floor(sqrt(n));
}
main()
{
	//freopen("input.txt","rt",stdin);
	int n,m;
	cin>>n>>m;
	int arr[n][m];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>arr[i][j];
		}
	}
	int c =0;
	for(int i=0;i<n;i++)
	{
		for(int k = i+1;k<n;k++)
		{
			int p =0;
			for(int j=0;j<m;j++)
			{
				int q = abs(arr[k][j] - arr[i][j]);
				p += q*q;
			}
			//cout<<p<<endl;
			if(squr(p))
			{
				c++;
			}
	   }
	}

	cout<<c<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
constexpr long long MOD = 1e9 + 7;
constexpr long long MAX = 1000000;

//long long MOD = 998244353;
constexpr ll INF = 1e17;
constexpr double PI = 3.141592653589793;



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

    ll n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2ull == 0) {
        cout << (b - a) / 2ll << endl;
    }
    else {
        if ((n - a) >= b) {
            ll remain = b - a;
            remain -= 1ll;
            ll ans = a + remain / 2ll;
            cout << ans << endl;
        }
        else {
            ll remain = n - a;
            remain -= n - b;
            remain -= 1ll;
            ll ans = n - b + 1ll + remain / 2ll;
            cout << ans << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


N = int(input())

minus = 0

for _ in range(N):
    number = int(input())
    if number != 2 and number%2 == 0:
        minus += 1
        continue
    i = 3
    while i*i <= number:
        if number%i == 0:
            minus += 1
            break
        i += 2

print("%d"%(N-minus))




Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=3e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N];
int main() {
    cin>>n;
    for(int i=1;i<=3*n;i++) a[i]=gi();
    sort(a+1,a+3*n+1);
    ll ans=0;
    for(int i=3*n-1;i>n;i-=2) ans+=a[i];
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long LL;
const int MAXN=200011;
LL ld[MAXN], rd[MAXN];
LL a[MAXN];
int n, m;
LL l, ans;

int main() {
	scanf("%lld%d", &l, &n);
	for(int i=1;i<=n;++i) {
		scanf("%lld", &a[i]);
	}
	ld[n]=0; ld[n-1]=l-(a[n]-a[n-1]);
	int pre=n;
	for(int i=n-2;i>0;--i) {
		if((n-i+1)&1) {
			ld[i]=ld[i+1]-(a[pre-1]-a[i+1])+(l-(a[pre]-a[i]));
		} else {
			ld[i]=ld[i+1]-(a[pre-1]-a[i+1])+(l-(a[pre-1]-a[i]));
			--pre;
		}
	}
	rd[1]=0; rd[2]=l-(a[2]-a[1]);
	pre=1;
	for(int i=3;i<=n;++i) {
		if(i&1) {
			rd[i]=rd[i-1]-(a[i-1]-a[pre+1])+(l-(a[i]-a[pre]));
		} else {
			rd[i]=rd[i-1]-(a[i-1]-a[pre+1])+(l-(a[i]-a[pre+1]));
			++pre;
		}
	}
	ans=0;
	for(int i=1;i<=n;++i) {
		ans=max(ans, a[i]+ld[i]);
		ans=max(ans, l-a[i]+rd[i]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992
#include <stdio.h>

double dp[302][302][302];
int n;

double solve(int c1,int c2,int c3)
{
  if(c3==-1 || c2==-1 || c1==-1)
    return 0;
  else if(dp[c1][c2][c3]!=-1)
    return dp[c1][c2][c3];
  else if(c3==0 && c2==0 && c1==1) return dp[c1][c2][c3]=n;
  return dp[c1][c2][c3]=((double)n/(c1+c2+c3))+(double)c1/(c1+c2+c3)*solve(c1-1,c2,c3)+(double)c2/(c1+c2+c3)*solve(c1+1,c2-1,c3)+(double)c3/(c1+c2+c3)*solve(c1,c2+1,c3-1);
}

int main()
{
  int x;
  double ans;
  scanf("%d",&n);
  int c1=0,c2=0,c3=0;
  for(int i=0;i<302;i++)
  {
    for(int j=0;j<302;j++)
    {
      for(int k=0;k<302;k++)
        dp[i][j][k]=-1;
    }
  }
  for(int i=0;i<n;i++)
  {
    scanf("%d",&x);
    if(x==1) c1++;
    else if(x==2) c2++;
    else if(x==3) c3++;
  }
  ans=solve(c1,c2,c3);
  printf("%.9lf\n",ans);
  return 0;
}


Measured memory_bytes: 215424
from math import factorial                                    
                                                              
# get input                                                   
n, m, r = (int(x) for x in input().strip().split())           
                                                              
# rest of beads                                       
rest = r - n * m                                              
                                                              
# rest + partition                                            
x = rest + (n - 1)                                            
                                                              
# combination (partition + rest)! / (rest! * partition!)      
try:                                                          
  print(factorial(x) // factorial(rest) // factorial(n - 1))  
except ValueError:                                            
  print(0)                                                    
                                                              

Measured memory_bytes: 7788
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c = sc.next();
    char fw = c.charAt(0);
    if (fw == 'a' || fw == 'e' || fw == 'i' || fw == 'o' || fw == 'u') {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }
  }
}

Measured memory_bytes: 23764
import Foundation
let nm = readLine()!.split(separator:" ").map{Int($0)!}
let hill = readLine()!.split(separator:" ").map{Int($0)!}
var ans: Set<Int> = []
for _ in 1...nm[1]{
  let ab = readLine()!.split(separator:" ").map{Int($0)!}
  if hill[ab[0]-1] < hill[ab[1]-1]{
    ans.insert(ab[0]-1)
  }
  else if hill[ab[0]-1] > hill[ab[1]-1]{
    ans.insert(ab[1]-1)
  }
  else{
    ans.insert(ab[0]-1)
    ans.insert(ab[1]-1)
  }
}
print(nm[0]-ans.count)

Measured memory_bytes: 19004
import java.util.*;
import java.util.Arrays.*;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] p = new int[N];
        int result = 0;
        for(int i=0;i<N;i++){
            p[i] = scan.nextInt();
        }
        Arrays.sort(p);
        for(int i=0;i<K;i++){
            result += p[i];
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 38952
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int n,m,min=2000000000,f=0;
    cin>>n>>m;
    vector<long long int>a(1000);
    vector<long long int>b(1000);
    vector<long long int>c(1000);
    vector<long long int>d(1000);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++){
        cin>>c[i]>>d[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if((abs(a[i]-c[j])+abs(b[i]-d[j]))<min){
                min=(abs(a[i]-c[j])+abs(b[i]-d[j]));
                f=j+1;
            }
        }
        cout<<f<<endl;
        f=0;
        min=2000000000;
    }
    
    return 0;
}


Measured memory_bytes: 3584
/*
Author- Aasav Badera
Time- Sun Apr 12 17:40:17 2020
*/
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define ll                 long long    
#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                1e18L+1
#define endl               '\n' 
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // #ifndef ONLINE_JUDGE
    // // for getting input from input.txt
    // freopen("input.txt", "r", stdin);
    // // for writing output to output.txt
    // freopen("output.txt", "w", stdout);
    // #endif
    ll tests = 1;
    // cin >> tests;
    while(tests--)
    {
        cin >> n;
        ll key = 0;
        while(n)
        {
        	if(n%10 == 7)key = 1;
        	n /= 10;
        }
        if(key)cout << "Yes";
        else cout << "No";
          }
    return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define N 100002
#define mod 1000000007
#define lld long long 
int main()
{
    lld x; cin>>x;
    lld res=0;
    res=res+1000*(x/500);
    x%=500;
    lld z=x%5;
    res=res+x-z;
    cout<<res;
}

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

int n;
vector<ll>arr,prefixsum;

void input(){
    cin>>n;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;

        arr.pb(a);
    }
}

void CalcPrefixSum(){
    for(int i=0;i<n;i++){
        if(i==0)    prefixsum.pb(arr[i]);
        else        prefixsum.pb(arr[i]+prefixsum[i-1]);
    }
}

ll sum(int L,int R){
    if(L==0)    return prefixsum[R];
    else        return prefixsum[R]-prefixsum[L-1];
}

ll dp[405][405];

ll Calculate(int L, int R){

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

    if(L==R)return dp[L][R]=0LL;

    ll cost = sum(L,R);
    ll ans = 1e18+9;

    for(int i=L;i<=R-1;i++){
        ans = min (ans, Calculate(L,i)+Calculate(i+1,R)+cost);
    }

    return dp[L][R]=ans;
}

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

    input();
    CalcPrefixSum();
    memset(dp,-1,sizeof dp);
    cout<<Calculate(0,n-1);


}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


i64 N, K;
string direction;

void solve() {
  i64 n_happy = 0; // 幸福である人の数
  REP(i, N) {
    if (direction[i] == 'R' && (i + 1) < N) {
      n_happy += direction[i + 1] == 'R';
    } else if (direction[i] == 'L' && i > 0) {
      n_happy += direction[i - 1] == 'L';
    }
  }

  i64 cnt_rl = 0;
  i64 cnt_lr;
  bool lm = direction[0] == 'L';
  bool rm = direction[N - 1] == 'R'; // 右端がRかどうか
  REP(i, N - 1) {
    cnt_rl += direction[i] == 'R' && direction[i + 1] == 'L';
  }
  cnt_rl += direction[0] == 'L';
  cnt_rl += direction[N - 1] == 'R';
  cnt_lr = cnt_rl - 1;

  REP(i, K) {
    if (cnt_lr == 0) {
      if (!lm && !rm) n_happy++;
      break;
    }
    if (cnt_lr == 1 && lm && rm) {
      n_happy += 1;
    } else {
      n_happy += 2;
    }
    cnt_rl--;
    cnt_lr--;
  }

  cout << n_happy << endl;
}

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

  solve();

  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define ll long long
#define nn 50004
#define lf double
ll bst[nn];
ll a[nn];ll xk;
ll n;
int main()
{
	cin>>n>>xk;
	for(ll i=0;i<n;i++) cin>>a[i],bst[i]=a[i];ll ui=2e17;
	for(ll k=0;k<n;k++)
	{
		ll ans=0;
		for(ll i=0;i<n;i++) bst[i]=min(bst[i],a[(i-k+n)%n]),ans+=bst[i];
		ui=min(ui,ans+1ll*k*xk);
	}
	cout<<ui;
	return 0;
} 

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

int main(int argc, char const* argv[])
{
  string s;
  cin >> s;
  int zero, one;
  zero = count(s.cbegin(), s.cend(), '0');
  one = count(s.cbegin(), s.cend(), '1');
  cout << min(zero, one)*2 << endl;
  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int w, h, n;
    int ans = 0;
    cin >> w >> h >> n;
    int sq[h][w];
    rep(i, h) {
      rep(j, w) {
        sq[i][j] = 0;
      }
    }
    rep(i, n) {
      int x, y, a;
      cin >> x >> y >> a;
      switch(a) {
        case 1:
          rep(i, h) {
            rep(j, x) {
              sq[i][j] = 1;
            }
          }
          break;
        case 2:
          rep(i, h) {
            FOR(j, x, w) {
              sq[i][j] = 1;
            }
          }
          break;
        case 3:
          FOR(i, h - y, h) {
            rep(j, w) {
              sq[i][j] = 1;
            }
          }
          break;
        case 4:
          rep(i, h - y) {
            rep(j, w) {
              sq[i][j] = 1;
            }
          }
          break;
      }
    }

    rep(i, h) {
      rep(j, w) {
        if (sq[i][j] == 0) {
          ans++;
        }
      }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInt >>=  print . length . filter odd . map ( length . show ) . flip take [ 1 .. ]

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

int main(){
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(S[i]=='o'){
      cnt++;
    }
  }
  cout<<700+100*cnt<<endl;
  
  return 0;

}

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

int main() {
	int X; cin >> X;
	int M=1;
	for(int i=2; i*i<=X; ++i){
	    for(int j=i; j<=X; j *= i){
	        if(M<j) M=j;
	    }
	}
	cout << M << endl;
	return 0;
}


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

typedef long long ll;

int main()
{
    int n;
    string s1,s2;
    cin >> n >> s1 >> s2;
    int i = 0;
    int temp = 0;
    ll ans = 1;
    ll waru = 1000000007;
    if(n == 1){
        cout << 3 << endl;
        return 0;
    }
    while(i < n){
        if(i == 0){
            if(s1.at(i) == s1.at(i+1)){
                ans *= 6;
                temp = 1;
                i += 2;
            }else{
                ans *= 3;
                temp = 0;
                ++i;
            }
        }else if(i == n-1){
            if(temp == 0){
                ans *= 2;
            }
            ++i;
        }else{
            if(s1.at(i) == s1.at(i+1)){
                if(temp){
                    ans *= 3;
                }else{
                    temp = 1;
                    ans *= 2;
                }
                i += 2;
            }else{
                if(temp){
                    temp = 0;
                }else{
                    ans *= 2;
                }
                ++i;
            }
        }
        ans %= waru;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
if s[a]=="-":
    s=s[:a]+s[a+1:]
    for i in range(a+b):
        if s[i]=="-":
            print("No")
            break
        if i==a+b-1:
            print("Yes")
            break
else:
    print("No")

    


Measured memory_bytes: 2940
N, M = map(int, input().split())

wa_num = 0
ac_num = 0

WA = [0] * N
AC = [False] * N

for _ in range(M):
    p, S = input().split()
    p = int(p) - 1

    if AC[p]:
        continue

    if S == "AC":
        AC[p] = True
        ac_num += 1
        wa_num += WA[p]
    elif S == "WA":
        WA[p] += 1

print(f"{ac_num} {wa_num}")


Measured memory_bytes: 10320
import java.util.Scanner;

/**
 * 連鎖行列積
 * @author nobu
 * @see <a href="http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_B&lang=ja">ALDS1_10_B</a>
 */
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p[] = new int[n + 1];

		for (int i = 1; i <= n; i++) {
			p[i - 1] = sc.nextInt();
			p[i] = sc.nextInt();
		}

		int m[][] = new int[n + 1][n + 1];
		for (int i = 1; i <= n; i++) m[i][i] = 0;
		// hはiとjの間隔
		for (int h = 2; h <= n; h++) {
			for (int i = 1; i <= n - h + 1; i++) {
				int j = i + h - 1;
				m[i][j] = Integer.MAX_VALUE;
				for (int k = i; k <= j - 1; k++) {
					m[i][j] = Math.min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
				}
			}
		}

		System.out.println(m[1][n]);

		sc.close();
	}

}



Measured memory_bytes: 26764
#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

string s;
int a,b,c,n;
int main(void){
    cin>>s;

    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
        p("Yes");
    }else{
        p("No");
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, m; cin >> n >> m;
	ll hsum = 0; ll wsum = 0;
	ll x[100000], y[100000];
	rep(i, n) {
		cin >> x[i];
	}
	rep(i, m) {
		cin >> y[i];
	}
	rep(i, n - 1) {
		hsum = (hsum + (((ll)(i + 1))*((ll)(n - 1 - i)) % MOD)*(x[i + 1] - x[i]) % MOD) % MOD;
	}
	rep(i, m - 1) {
		wsum = (wsum + (((ll)(i + 1))*((ll)(m - 1 - i)) % MOD)*(y[i + 1] - y[i]) % MOD) % MOD;
	}
	cout << hsum * wsum%MOD << endl;
	return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int[] input = new int[num];
        int i;
        for (i = 0; i < num; i++) {
            input[i] = sc.nextInt();
        }
        for(i = num - 1; i >= 0; i--) {
            System.out.print(input[i]);
            if (i != 0) System.out.print(" ");
        }
        System.out.println();
    }
}


Measured memory_bytes: 26152
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	string str;
	while(cin >> str){
		for(int i=0;i<str.size();i++){
			str[i]=str[i]-3  >= 'A' ? str[i]-3 : 'Z'+1 - abs('A'-(str[i]-3));
		}
		cout << str << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    long long p=1;
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        p*=i;
        p=p%(1000000000+7);
    }
    printf("%lld",p);
    return 0;
}


Measured memory_bytes: 256