akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

string list[15] = {"Rock", "Fire", "Scissors", "Snake", "Human", "Tree", "Wolf", "Sponge", "Paper", "Air", "Water", "Dragon", "Devil", "Lightning", "Gun"};

int n;

int main() {
    map<string,int> ma;
    for (int i = 0; i < 15; ++i) ma[list[i]] = i;
    while (cin >> n) {
        if (n == 0) break;
        bool lose[20] = {0};
        map<int,int> member;
        for (int i = 0; i < n; ++i) {
            string str; cin >> str; int id = ma[str];
            member[id]++;
            for (int j = 1; j <= 7; ++j) {
                int nid = (id + j) % 15;
                lose[nid] = true;
            }
        }
        string win = "";
        EACH(it,member) {
            if (!lose[it->first]) win = list[it->first];
        }
        if (win == "" || member.size() == 1) puts("Draw");
        else cout << win << endl;
    }
    return 0;
}


Measured memory_bytes: 1216
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;
using ld = long double;

int main()
{
    int N, M;
    ld P;
    cin >> N >> M >> P;
    P /= 100;
    vector<pair<int, int>> edge(M);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edge[i] = {u, v};
    }
    const int maximum = 1 << N;
    vector<ld> dp(maximum, 0);
    for (int i = 1; i < maximum; i++) {
        int ind = 0;
        for (; ind < N; ind++) {
            if (i & (1 << ind)) {
                break;
            }
        }
        dp[i] = 1;
        int num = 0;
        while (num < i) {
            if (num & (1 << ind)) {
                const int res = i - num;
                int cnt = 0;
                for (const auto& e : edge) {
                    const int u = e.first;
                    const int v = e.second;
                    if ((num & (1 << u) and res & (1 << v)) or (num & (1 << v) and res & (1 << u))) {
                        cnt++;
                    }
                }
                dp[i] -= dp[num] * pow(P, cnt);
            }
            num = (num - i) & i;
        }
    }
    cout << fixed << setprecision(15) << dp[maximum - 1] << endl;
    return 0;
}



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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m);
    cin >> a[0];
    int ma=0;
    for(int i=1;i<m;i++){
        cin >> a[i];
        int tmp = (a[i]-a[i-1])/2;
        ma = max(ma,tmp);
    }
    //cout << ma << endl;
   // cout << a[0]-1 << endl;
    ma = max(ma,n-a[m-1]);
    if(ma <= a[0]-1){
        cout << a[0]-1 << endl;
    }else{
        cout << ma << endl;
    }
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
typedef vector<vint>mat;
const int mod=1000000007;
 
mat mul(mat A,mat B){
     mat C(A.size(),vint(B[0].size()));
     rep(i,C.size()){
        rep(j,C[0].size()){
            rep(k,A[0].size()){
                (C[i][j]+=A[i][k]*B[k][j])%=mod;
            }
        }
     }
     return C;
}
 
mat mpow(mat A,int m){
    mat B(A.size(),vint(A.size()));
    rep(i,A.size())B[i][i]=1;
    for(;m;m>>=1,A=mul(A,A))if(m&1)B=mul(A,B);
    return B;
}
 
int N,K,C,T;
int a[114514],b[114514],t[114514];
signed main(){
    cin>>N>>K>>C>>T;C--;
    rep(i,K)cin>>a[i]>>b[i]>>t[i],a[i]--;
 
    mat X(N*5,vint(1)),A(N*5,vint(N*5));
    X[C][0]=1;
    rep(i,N*4)A[N+i][i]=1;
    rep(k,K){
        int bb=(t[k]-1)*N;
        rep(i,N){
            if(i<a[k])A[i+b[k]][bb+i]++;
            else if(i<a[k]+b[k])A[i-a[k]][bb+i]++;
            else A[i][bb+i]++;
        }
    }
 
 
    X=mul(mpow(A,T),X);
    cout<<X[0][0]<<endl;
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    LL W;cin >> W;
    vector<LL> w(N);
    vector<LL> v(N);
    rep(i,N)cin >> w[i] >> v[i];

    LL dp[110][110][310] = {0};
    rep(i,N)rep(j,101)rep(k,301){
        chmax(dp[i+1][j+1][k + w[i] - w[0]],dp[i][j][k] + v[i]);
        chmax(dp[i+1][j][k],dp[i][j][k]);
    }
    LL ans = 0;
    LL ct = W/w[0];
    rep(i,N+1){
        LL sum = w[0]*i;
        LL modi = W - sum;
        if(modi >= 0){
            chmax(ans,dp[N][i][min(300LL,modi)]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 29568
/*
 * じょえチャンネル
 * 高評価・チャンネル登録よろしくおねがいします！
 * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
 */
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)
template<class T> inline void chmin(T &a, T b) {
	a = min(a, b);
}
template<class T> inline void chmax(T &a, T b) {
	a = max(a, b);
}

int N;
vector<int>G[200005];
int co[200005];
bool used[200005];
void dfs(int x){
	used[x]=true;
	for(int i:G[x]){
		if(!used[i]){
			co[i]=co[x]*-1;
			dfs(i);
		}
	}
}
int ans[200005];
int dis[200005];
void dfs2(int x){
	used[x]=true;
	for(int i:G[x]){
		if(!used[i]){
			dis[i]=dis[x]+1;
			dfs2(i);
		}
	}
}
int dis2[200005];
void dfs3(int x){
	used[x]=true;
	for(int i:G[x]){
		if(!used[i]){
			dis2[i]=dis2[x]+1;
			dfs3(i);
		}
	}
}
set<int>kouho;
vector<int>v1,v2;
signed main(){
	cin>>N;
	rep(i,N)kouho.insert(i+1);
	rep(i,N-1){
		int a,b;cin>>a>>b;a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	co[0]=1;
	dfs(0);
	int cnt1=(N+2)/3,cnt2=(N+1)/3;
	rep(i,N){
		if(co[i]==1)v1.push_back(i);
		else v2.push_back(i);
	}
	memset(used,false,sizeof(used));
	dfs2(0);
	int mx=0,idx;
	rep(i,N){
		if(dis[i]>mx){
			mx=dis[i];idx=i;
			dis[i]=0;
		}
	}

	auto it=v1.begin();
	if(v1.size()<cnt1){
		rep(i,v1.size()){
			ans[v1[i]]=3*(i+1);
			kouho.erase(3*(i+1));
		}
		rep(i,N){
			if(!ans[i]){
				ans[i]=*kouho.begin();
				kouho.erase(ans[i]);
			}
		}
	}else if(v2.size()<cnt2){
		rep(i,v2.size()){
			ans[v2[i]]=3*(i+1);
			kouho.erase(3*(i+1));
		}
		rep(i,N){
			if(!ans[i]){
				ans[i]=*kouho.begin();
				kouho.erase(ans[i]);
			}
		}
	}else {
		rep(i,cnt1){
			ans[v1[i]]=1+3*i;
		}
		rep(i,cnt2){
			ans[v2[i]]=2+3*i;
		}
		int cnt=1;
		rep(i,N){
			if(!ans[i]){
				ans[i]=cnt*3;
				cnt++;
			}
		}
	}
	rep(i,N)cout<<ans[i]<<" ";
	cout<<endl;
}


Measured memory_bytes: 31976
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod || x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

const int MAX_N = 2e5 + 10;
ll perm[MAX_N], invp[MAX_N];

ll howm(ll x1, ll y1, ll x2, ll y2) {
    ll len1 = x2 - x1;
    ll len2 = y2 - y1;
    return (((perm[len1 + len2] * invp[len1]) % mod) * invp[len2]) % mod;
}

ll fpow(ll x, ll p) {
    if(p == 0) {return 1;}
    ll ans = fpow(x, p / 2);
    ans = (ans * ans) % mod;
    if(p & 1) {
        return (ans * x) % mod;
    } else {
        return ans;
    }
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    perm[0] = invp[0] = 1;
    for(int i = 1; i < MAX_N; i ++) {
        perm[i] = (perm[i - 1] * i) % mod;
        invp[i] = fpow(perm[i], mod - 2);
    }
    ll n, m, a, b;
    cin >> n >> m >> a >> b;
    ll ans = howm(1, 1, n, m);
    for(int i = 1; i <= b; i ++) {
        ll curr = howm(1, 1, n - a, i);
        //cout << curr << endl;
        curr = (curr * howm(n - a + 1, i, n, m)) % mod;
        //cout << ans << " " << curr << endl;
        ans -= curr;
        fix(ans);
    }
    cout << ans << endl;
    return 0;
}




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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/d.in", "r", stdin);
//  freopen("../IO/d.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

constexpr int P = 1'000'000'007;
void solve(std::istream &in, std::ostream &out) {
  int S;
  in >> S;
  vector<int> dp(S+ 1,0 );
  dp[0] = 1;
  for (int i = 3; i <= S; ++i) {
    for (int j = 3; i - j >= 0; ++j) {
      (dp[i] += dp[i - j]) %= P;
    }
  }
  out << dp[S] << '\n';
}

Measured memory_bytes: 3652
N = int(input())
A = list(map(int, input().split()))

di = {}

for i in A:
    if i in di:
        di[i] += 1
    else:
        di[i] = 1

for i in range(N):
    if i+1 not in di.keys():
        print(0)
    else:
        print(di[i+1])

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

string cont(const vector<int>& v, int& i) {
  int begin = v[i];
  int pre = v[i];

  while(++i < v.size() & v[i] == pre + 1)
    pre = v[i];

  if (begin == pre)
    return to_string(begin);
  else
    return to_string(begin) + "-" + to_string(v[i - 1]);
}

void solve(const vector<int>& v) {
  string result;
  int i = 0;
  cout << cont(v, i);
  while(i < v.size()) {
    cout << " " << cont(v, i);
  }
  cout << endl;
}

int main() {
  int n;
  while(cin >> n, n) {
    vector<int> v(n);
    for (auto i = 0; i < n; ++i) cin >> v[i];
    solve(v);
  }
  
  return 0;
}


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

#define for0(i, n) for (int i = 0; i < (int)(n); ++i) 
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) 
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) 
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) 
#define forrc(i,l,r) for (int i= (int)(r); i>= (int)(l); --i)

#define pb push_back
#define fi first
#define se second
#define mp make_pair

#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 


#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


#define present(c,x) ((c).find(x) != (c).end())


#define cpresent(c,x) (find(all(c),x) != (c).end())

#define sz(a) int((a).size())

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

using namespace std;


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
typedef long long ll;
typedef unsigned long long int ull;
bool isPrime(int n){
  for(int i=2; i*i<=n; i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}

int MOD=1000000007;

int main(){
  fastio; 
  
  int n,m;
  cin >> n >> m;
  char a[n][m];
  for0(i,n)
    for0(j,m) cin >> a[i][j];
  int dp[n][m];
  for0(i,n){
    for0(j,m){
      if(a[i][j]=='.'){
        if(i==0 && j==0){
            dp[i][j]=1%MOD;
            continue;
        }
        dp[i][j]=0;
        if(i-1>=0){
          dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
        }
        if(j-1>=0){
          dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD;
        }
      }else{
        dp[i][j]=0;
      }
    }
  }
  cout << dp[n-1][m-1];
}

Measured memory_bytes: 5120
#include<iostream>

#include<cmath>

using namespace std;

int main(){

 int h,w;

 while(1){

  cin >> h >> w;

  if(h==0)break;

  int r=h*h+w*w;

  for(int f=0;;r++,f++){

   for(int H=1;H<r;H++){

    if(f==0&&H<=h) continue;

    int W=r-H*H;

    if(W>H*H){

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

      if(i*i==W){

       cout <<H << ' ' << sqrt(W) << endl;

       goto a;

      }

     }

    }

   }

  }

 a:;

 }

 return 0;

}

Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#define ill long long
#define rep(i, a, b) for(ill i = (ill)(a); i < (ill)(b); i++)
#define fcout cout << fixed << setprecision(10)
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  vector<int> v = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  if(v[a-1] == v[b-1]) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 3596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Pair
    {
        public int num;
        public int count;
    }

    class Program
    {
        static void Main()
        {
            //ここから
            int[] str = ReadLineToIntArray();
            int N = str[0];
            int M = str[1];
            int X = str[2];
            int Y = str[3];

            int[] x = ReadLineToIntArray();
            int[] y = ReadLineToIntArray();

            string ans = "War";

            for(int Z = X + 1; Z <= Y; Z++)
            {
                bool flag = true;
                for(int i = 0; i < N; i++)
                {
                    if (x[i] >= Z)
                    {
                        flag = false;
                        break;
                    }
                }
                for(int i = 0; i < M; i++)
                {
                    if (y[i] < Z)
                    {
                        flag = false;
                        break;
                    }
                }

                if (flag == true)
                {
                    ans = "No War";
                    break;
                }
            }

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }

        long mod = 1000000007;
        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }


        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


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

int n,ans;
bool flag=false;
int a[100010];

inline int get_num()
{
	int now=0,fh=1;char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		now=(now<<1)+(now<<3)+ch-'0';
		ch=getchar();
	}
	return now*fh;
}

int main()
{
	n=get_num();
	for(int i=1;i<=n;i++){
		a[i]=get_num();
	}
	for(int i=1;i<=n;i++){
		if(a[i]==i){
			if(a[i-1]==i-1&&flag==true){
				flag=false;
				continue;
			}
			ans++;flag=true;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>


#define MYSCAN scanf

int main(void){
	int b, r, g, c, s, t;
	int medal, game, bonus;

	while (1){
		MYSCAN("%d %d %d %d %d %d", &b, &r, &g, &c, &s, &t);
		if (b + r + g + c + s + t == 0){ break; }

		game = 0;
		bonus = 0;
		medal = 100;

		// テ」ツδ愿」ツδシテ」ツδ甘」ツつケテ」ツつイテ」ツδシテ」ツδ?
		bonus = b * 5 + r * 3;
		game += bonus;
		// 1テ」ツつイテ」ツδシテ」ツδ?」ツ?づ」ツ?淌」ツつ?テヲツ楪堙」ツ?ョテ」ツδ。テ」ツδ?」ツδォテ」ツつ津ヲツ環陛・ツ?・テ」ツ?凖」ツつ凝」ツ?ィ
		medal -= bonus * 2;
		// ティツ?ェテ・ツ仰陛」ツ?ァ15テヲツ楪堙」ツ?ョテ」ツδ。テ」ツδ?」ツδォテ」ツ?古・ツ?コテ」ツ?ヲテ」ツ?湘」ツつ?
		medal += bonus * 15;

		// テ」ツδ禿」ツδε」ツつー/テ」ツδャテ」ツつョテ」ツδ・テ」ツδゥテ」ツδシ1テ・ツ崢榲ゥツ鳴凝・ツァツ凝」ツ?ォテ」ツ?、テ」ツ??5テヲツ楪堙」ツ?ョテヲツ可陛」ツ??・ツ?コテ」ツ??
		medal += (b + r) * 15;

		// テ」ツδ姪」ツδ嘉」ツつヲ
		// テゥツ?堙・ツクツクテ」ツつイテ」ツδシテ」ツδ?、ツクツュテ」ツ?ョテ」ツδ姪」ツδ嘉」ツつヲテ」ツ?ッ7テヲツ楪堙」ツ?ョテヲツ可陛」ツ??・ツ?コテ」ツ??
		medal += g * 7;

		// テ」ツδ?」ツつァテ」ツδェテ」ツδシ
		// テ」ツδ?」ツつァテ」ツδェテ」ツδシテ」ツ?古ヲツ渉ε」ツ??」ツ?ィ2テヲツ楪堙」ツ?ョテヲツ可陛」ツ??・ツ?コテ」ツ??
		medal += c * 2;

		// テ」ツつケテ」ツつソテ」ツδシ
		// テ」ツつケテ」ツつソテ」ツδシテ」ツ?古ヲツ渉ε」ツ??」ツ?ィテ」ツ??」ツδ。テ」ツδ?」ツδォテ」ツ?ッティツイツーテ」ツ?暗」ツ?ェテ」ツ??」ツ?古ヲツャツ。テ」ツ?ョテ」ツつイテ」ツδシテ」ツδ?」ツつ津ァツ?。テヲツ鳴凖」ツ?ァティツ。ツ古」ツ??」ツ?禿」ツ?ィテ」ツ?古」ツ?ァテ」ツ?催」ツつ?
		// テッツシツ暗」ツつイテ」ツδシテ」ツδ?・ツ崢榲ヲツ閉ーテ」ツ?古ァツ?。テヲツ敖。テ、ツサツカテ」ツ?ォ1テ・ツ崢榲・ツ「ツ療」ツ?暗」ツつ凝ッツシツ?
		game += s;

		// テ、ツサツ拡ameテ・ツ、ツ嘉ヲツ閉ーテ」ツ?ォテ・ツ?・テ」ツ?」テ」ツ?ヲテ」ツ??」ツ?ェテ」ツ??・ツ按?」ツ?ョテ」ツつイテ」ツδシテ」ツδ?ヲツ閉ーテ」ツ?古ゥツ?堙・ツクツクテ」ツつイテ」ツδシテ」ツδ?
		// テゥツ?堙・ツクツクテ」ツつイテ」ツδシテ」ツδ?」ツ?ッ1テ・ツ崢?テ」ツつウテ」ツつ、テ」ツδウ
		medal -= (t - game) * 3;

		printf("%d\n", medal);
	}
	
	return 0;
}

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

using namespace std;
int main()
{
    long long n, k;
    long long i = 0;
    long long mod = 1000000007;
    
    cin >> n;
    cin >> k;

    long long ans = 0;
    long long cur2 = (k*(k-1)/2);
    long long cur1 = k;
    long long k1 = k;
    //cout << cur1 << endl;
    while(i<n-k+2){
        ans = (ans + (k1*n)%mod - (2*cur2)%mod + 1)%mod;
        //cout << ans << " " << k1*n << " " << 2*cur2 << endl;
        cur2 = (cur2 + cur1);
        i++;
        k1++;
        cur1++;
        
    }
    cout << ans%mod;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007, INFL = 1ll << 60, INF = 1 << 30;
ll A[1000000] = {}, X[1000] = {}, coun[60] = {}, bcou[60] = {};
ll dp[100000] = {};
int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
vector <ll> v;
ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, n = 0, su = 0, ma = INF, mi = -1;
double ans;
pair<str, ll> S[1000];
bool an = false, bn = false;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Code Line
	for (int i = 1; i < 100000; i++)dp[i] = INF;
	cin >> n;
	for (int i = 0; i < n; i++)cin >> A[i];
	for (int i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], abs(A[i] - A[i + 1]) + dp[i]);
		dp[i + 2] = abs(A[i] - A[i + 2]) + dp[i];
	}
	cout << dp[n - 1] << endl;
	cin >> n;
	//Code Line
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int a, b;
	string sa, sb,u;
	cin >> sa >> sb >> a >> b >> u;
	if (sa == u)a--;
	else b--;
	cout << a << " " << b << endl;

}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int max2k = 4e3+5;

int CB[max2k][max2k];
int CW[max2k][max2k];
int B[max2k][max2k];
int W[max2k][max2k];

int lowbit(int x){return (-x)&x;}
void add(int i,int j,char c){
    if(c == 'W'){
        W[i][j]++;
    }
    else{
        B[i][j]++;
    }
}

inline int sumW(int xx,int yy,int x,int y){
    return CW[xx][yy] - CW[xx][y-1] - CW[x-1][yy] + CW[x-1][y-1];
}

inline int sumB(int xx,int yy,int x,int y){
    return CB[xx][yy] - CB[xx][y-1] - CB[x-1][yy] + CB[x-1][y-1];
}
int N,K;

void pre_do(){
    int K4 = 4*K;
    _rep(i,1,K4){
        _rep(j,1,K4){
            CB[i][j] = CB[i-1][j] + CB[i][j-1] - CB[i-1][j-1] + B[i][j];
            CW[i][j] = CW[i-1][j] + CW[i][j-1] - CW[i-1][j-1] + W[i][j];
        }
    }
}

int main()
{

    cin >> N >> K;
    int K2 = 2*K;
    int K4 = 4*K;
    _for(i,0,N){
        int x,y;
        string s;
        cin >> x >> y >> s;
        add((x%K2)+1,(y%K2)+1,s[0]);
        add((x%K2)+K2+1,(y%K2)+1,s[0]);
        add((x%K2)+1,(y%K2)+K2+1,s[0]);
        add((x%K2)+K2+1,(y%K2)+K2+1,s[0]);
    }

    pre_do();

    int res = 0;
    _for(i,K2,K4+1){
        _for(j,K2,K4+1){
            int temp = 0;
            temp += sumW(i,j,i-K+1,j-K+1);
            temp += sumW(i-K,j-K,i-K2+1,j-K2+1);
            temp += sumB(i-K,j,i-K2+1,j-K+1);
            temp += sumB(i,j-K,i-K+1,j-K2+1);
            res = max(res,temp);
        }
        //cout <<"ok"<<endl;
    }
    cout << res << endl;
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>a(n);
	for(auto&i:a)cin>>i;
	sort(a.begin(),a.end(),[](auto a,auto b){return a>b;});
	int tmp=a.front(),place=0;
	while(tmp){
		++place;
		tmp/=2;
	}
	vector<int>cnt1(place+1,0),cnt0(place+1,0);
	for(auto&i:a){
		int j=1,p=1;
		while(j<=place){
			if(p&i)++cnt1.at(j);
			else ++cnt0.at(j);
			++j;
			p=p<<1;
		}
	}
	bool yes=true;
	for(int i=1;i<cnt1.size();++i){
		if(cnt1.at(i)%2!=0||(cnt1.at(i)!=0&&cnt1.at(i)%2==0&&cnt0.at(i)==0)){
			yes=false;
		}
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;

int main() {
    ll N; cin >> N;
    int L = 3500;
    rng(h, 1, L+1) {
        rng(n, h, L+1) {
            ll ls = 4*h*n - N*h - N*n;
            ll rs = N*n*h;
            if (ls > 0 && rs%ls == 0) {
                cout << h << " " << n << " " << rs/ls << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
weights = []
hoge = input().split()
for i in range(N):
  weights.append(int(hoge[i]))

abs_result = abs(weights[0] - sum(weights[1:]))
for i in range(N-1):
  S1 = weights[:i+1]
  S2 = weights[i+1:]
  if abs(sum(S1)-sum(S2)) < abs_result:
    abs_result = abs(sum(S1)-sum(S2))

print(abs_result)

Measured memory_bytes: 3064
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b > 2*c:
	ans = c*2*min(x,y)
	if x<y:
		if b > 2 * c:
			ans += 2*c*(y-x)
		else:
			ans += b*(y-x)
	else:
		if a > 2 * c:
			ans += 2*c*(x-y)
		else:
			ans += a*(x-y)
else:
	ans = a*x+b*y	
print(ans)


Measured memory_bytes: 3060
from itertools import combinations
n=int(input())
l=list(map(int, input().split()))
base = list(combinations(l,3))
c = len(base)
ans=0
for i in range(c):
  if base[i][0]==base[i][1] or base[i][0]==base[i][2] or base[i][1]==base[i][2]:
    continue
  ct1 = base[i][0]+base[i][1]
  ct2 = base[i][0]+base[i][2]
  ct3 = base[i][1]+base[i][2]
  if ct1>base[i][2] and ct2>base[i][1] and ct3>base[i][0]:
    ans+=1
    #print(base[i])
print(ans)
#print(ct1)

Measured memory_bytes: 20616
o = input()
e = input()

l = [0]*(len(o)+len(e))

#print((len(o)+len(e))//2)

for i in range((len(o)+len(e))//2):
#	print(i)
	l[i*2] = o[i]
	l[i*2+1] = e[i]

if len(o)!=len(e):
	l[len(o)+len(e)-1] = o[len(o)-1]

print(''.join(l))



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

int main(){

  int cnt[26]={}, co=0;
  string s;

  cin>>s;

  for(int i=0;i<s.length();i++) cnt[s[i]-'a']++;
  for(int i=0;i<26;i++) if(cnt[i]%2) co++;

  cout<<co/2<<endl;

  
  return 0;
}

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

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

  vector<long long> vec(N + 1);
  vec.at(0) = 2;
  vec.at(1) = 1;
  for (int i = 2; i < N + 1; i++) {
    vec.at(i) = vec.at(i - 1) + vec.at(i - 2);
  }

  cout << vec.at(N) << endl;
}

Measured memory_bytes: 256
x=[int(input()) for i in range(5)]
y=[0]*5
for i in range(5):
  if x[i]%10>0:
    y[i]=(x[i]//10+1)*10
  else:
    y[i]=x[i]
    
z=[x[i]%10 for i in range(5)]
for i in range(5):
  if z[i]==0:
    z[i]=10
    
t=sum(y)-10+min(z)
print(t)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	char s[4];
	int a = 0, b = 0;
	int i;

	scanf("%s", s);

	for(i=0; i<3; i++){
		if(s[i] == 'A'){
			a = 1;
		}else{
			b = 1;
		}
	}

	printf("%s", ( a == 1 && b == 1) ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 128
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
  A = list(map(int,input().split()))
  tmp = 0
  for j in range(M):
    tmp += A[j]*B[j]
  if tmp + C > 0:
    ans += 1
print(ans)


Measured memory_bytes: 9116
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int ans = numeric_limits<int>::max();
    for(int i=0; i<=max(X, Y); ++i) {
        ans = min(ans, 2*C*i + A*max(0, X-i) + B*max(0, Y-i));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100007
using namespace std;
int n,v[N],c[N],d[N];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&v[i]);
    for(int i=1;i<=n;i+=2)++c[v[i]];
    for(int i=2;i<=n;i+=2)++d[v[i]];
    int of=0,os=0;
    for(int i=1;i<N;++i)
        if(c[i]>c[of])os=of,of=i;
        else if(c[i]>c[os])os=i;
    int ef=0,es=0;
    for(int i=1;i<N;++i)
        if(d[i]>d[ef])es=ef,ef=i;
        else if(d[i]>d[es])es=i;
    if(of!=ef){printf("%d\n",(n-n/2-c[of])+(n/2-d[ef]));return 0;}
    cout<<min((n-n/2-c[of])+(n/2-d[es]),(n-n/2-c[os])+(n/2-d[ef]))<<endl;
}


Measured memory_bytes: 1408
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


n, m = map(int, input().split())
l = []
for _ in range(n):
    k, *ls = map(int, input().split())
    l.append(ls)

uf = UnionFind(m)

for li in l:
    for e1, e2 in zip(li, li[1:]):
        e1 -= 1
        e2 -= 1
        uf.unite(e1, e2)

p = uf.find_set(l[0][0] - 1)
ans = "YES"
for e, *_ in l:
    if uf.find_set(e - 1) != p:
        ans = "NO"

print(ans)


Measured memory_bytes: 87768
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector< set<int> >q(30);

int main(){
    int n,i,j,t,l,r,k,u,ans;
    string s;
    char c;
    cin>>n>>s;
    for(int i=0;i<26;i++) q[i]={n};//先存入n，防止后续查找越界
    for(int i=0;i<n;i++) q[s[i]-'a'].insert(i);
    cin>>t;
    while(t--){
        cin>>u;
        if(u==1){
            cin>>k>>c;k--;
            if(s[k]!=c) q[s[k]-'a'].erase(k);
            s[k]=c;q[c-'a'].insert(k);
        }
        else{
            ans=0;
            cin>>l>>r;l--;r--;
            for(int j=0;j<26;j++) if(*q[j].lower_bound(l)<=r) ans++;
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24196
#include <stdio.h>
#include <algorithm>

using namespace std;

inline bool check(int n)
{
    int rep = min(n, 40000);
    
    for(int x = 1; x < rep; x++)
    {
        if((n - x) % (2 * x + 1) == 0)
        {
            return true;
        }
    }
    
    return false;
}

int main()
{
    int n, q, c = 0;
    
    scanf("%d", &q);
    
    for(int i = 0; i < q; i++)
    {
        scanf("%d", &n);
        
        c += check(n) ? 0 : 1;
    }
    
    printf("%d\n", c);
    
    return 0;
}

Measured memory_bytes: 2680
#include <iostream>

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  int p = 0;
  int cnt = p <= x;
  while (n--) {
    int tmp;
    cin >> tmp;
    p += tmp;
    cnt += p <= x;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3612
import Data.List
import qualified Data.IntSet as IS
main=putStrLn.solve.map read.words=<<getLine
solve[a,b,c,d,e,f]=unwords$map show[w+s,s]where
  (w,s)=maximumBy(\(w1,s1)(w2,s2)->compare(w2*s1)(w1*s2))sws
  sws=map h$g a b$f`div`100
  ss=IS.fromList$g c d$f*e`div`100
  h w=(w*100,s)where Just(s)=IS.lookupLE(min(w*e)(f-w*100))ss
g x y z=[v|x<-xs,y<-ys,let v=x+y,x+y<z]
  where[xs,ys]=map(\x->map(*x)[0..z`div`x])[x,y]

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int ans = 0;
long long N;
void dfs(long long k){

 	if(k > N) return ;

 	long long tmp = k;
	int t_c = 0, f_c = 0, s_c = 0;
	while(tmp != 0){
		switch(tmp % 10){
		 case 3 : t_c += 1;  break;
		 case 5 : f_c += 1;	break;
		 case 7 : s_c += 1;  break;
		 default : break;
		}

		tmp /= 10;
	}
	if(t_c > 0 && f_c > 0 && s_c > 0)	ans++;

	dfs(k * 10 + 3);
	dfs(k * 10 + 5);
	dfs(k * 10 + 7);

}

int main(void){

  	cin >> N;
 	dfs(0);
	cout << ans << endl; 


 return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
judge = [1]*n
H = list(map(int,input().split()))

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    if H[a] > H[b]:
        judge[b] *= 0
    elif H[a] < H[b]:
        judge[a] *= 0
    else:
        judge[a] *= 0
        judge[b] *= 0
print(sum(judge))

Measured memory_bytes: 85756
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a,b = map(int, input().split())
    x=
    A.append(a)
    B.append(b)'''

n,X=map(int, input().split())
x = list(map(int, input().split()))
sa=[]
for i in range(n):
    sa.append(abs(x[i]-X))

def yakusuu(n):
    #約数リスト生成,バラバラに出るので.sort()を使う必要あるかも
    #PyPy推奨
    yakusuu_list = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yakusuu_list.append(i)
            if i != n // i:
                yakusuu_list.append(n//i)
    return yakusuu_list
#print(sa)
slis=yakusuu(min(sa))
slis.sort()
#print(slis)
for item in slis:
    cnt=0
    for i in range(n):
        if sa[i]%item==0:
            cnt+=1
    if cnt==len(x):
        maxx=item
print(maxx)

Measured memory_bytes: 14252
using System;
using System.Linq;

class B
{
	static void Main()
	{
		Console.ReadLine();
		Console.WriteLine(Console.ReadLine().Split().Select(int.Parse).All(x => x % 2 != 0 || x % 3 == 0 || x % 5 == 0) ? "APPROVED" : "DENIED");
	}
}


Measured memory_bytes: 18976
n=int(input())
a=[]
b=[]
c=[]
for j in range(n):
	aa,bb,cc=map(int,input().split())
	a.append(aa)
	b.append(bb)
	c.append(cc)

i=n-2
while i>-1:
	a[i]+=max(b[i+1],c[i+1])
	b[i]+=max(a[i+1],c[i+1])
	c[i]+=max(b[i+1],a[i+1])
	i=i-1
print(max([a[0],b[0],c[0]]))

Measured memory_bytes: 15012
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vvp g;
	public:
	int DIJ(int s,int t){
		priority_queue<P> q;
		vi d(n,inf);
		d[s]=0;
		q.push({0,s});
		while(!q.empty()){
			P p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first,D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d[t];
	}
	Graph(int v){
		n=v;
		g=vvp(v);
	}
	void add_edge(int s,int t,int c){
		g[s].push_back({t,c});
		g[t].push_back({s,c});
	}
};

int main(){
	while(1){
		int h,w;
		cin>>w>>h;
		if(h==0) break;
		Graph g(h*w);
		for(int i=0;i<h;i++){
			for(int j=0;j<w-1;j++){
				int x;
				cin>>x;
				if(x==0) g.add_edge(i*w+j,i*w+j+1,1);
			}
			if(i<h-1){
				for(int j=0;j<w;j++){
					int x;
					cin>>x;
					if(x==0) g.add_edge(i*w+j,(i+1)*w+j,1);
				}
			}
		}
		int res=g.DIJ(0,h*w-1);
		if(res==inf) res=-1;
		cout<<res+1<<endl;
	}
}


Measured memory_bytes: 3144
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main(){
  string s,t;
  cin>>s>>t;
  int cnt=0;
  rep(i,3){
   if( s[i]==t[i]) ++cnt;
  }
   cout<<cnt<<endl;
}


Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int n, m;
    cin >> n >> m;
    if (m >= n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#define int long long



using namespace std;


signed main(){
    int H, W;
    cin >> H >> W;
    
    int a[H][W];
    int b[H][W];
    
    
    
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> a[i][j];
            a[i][j] %= 2;
            b[i][j] = a[i][j];
        }
    }
    
    int cnt = 0;
    
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W - 1; ++j){
            if(a[i][j] == 1){
                a[i][j + 1] = (a[i][j + 1] + 1) % 2;
                ++cnt;
            }
        }
    }
    
    for(int i = 0; i < H - 1; ++i){
        if(a[i][W - 1] == 1){
            a[i + 1][W - 1] = (a[i + 1][W - 1] + 1) % 2;
            ++cnt;
        }
    }
    
    cout << cnt << endl;
    
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W - 1; ++j){
            if(b[i][j] == 1){
                cout << i + 1 << " " << j + 1 << " " << i + 1 << " " << j + 2 << endl;
                b[i][j + 1] = (b[i][j + 1] + 1) % 2;
            }
        }
    }
    
    for(int i = 0; i < H - 1; ++i){
        if(b[i][W - 1] == 1){
            cout << i + 1 << " " << W << " " << i + 2 << " " << W << endl;
            b[i + 1][W - 1] = (b[i + 1][W - 1] + 1) % 2;
        }
    }
    return 0;
    
}


Measured memory_bytes: 4096
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

ll n, m, q;
vector<ll> a, b, c, d;

ll dfs(vector<ll> &A) {
	if (sz(A) == n) {
		ll sum = 0;
		rep(i, q) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				sum += d[i];
			}
		}
		return sum;
	}

	ll res = 0;
	ll prev = A.empty() ? 0 : A.back();
	for (int ad = prev; ad < m; ad++) {
		A.push_back(ad);
		chmax(res, dfs(A));
		A.pop_back();
	}
	return res;
}

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

	cin >> n >> m >> q;

	a.resize(q); b.resize(q);
	c.resize(q); d.resize(q);
	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--; b[i]--;
	}

	vector<ll> A;

	out(dfs(A));

	return 0;
}

Measured memory_bytes: 3588
if __name__ == '__main__':
    s = input()
    l = s.replace('AA', '_').strip('A').split('A')
    if ''.join(l) == 'KIHBR' and len(l) > 0 and l[0][:3] == 'KIH':
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 2940
//#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 n,k;
    cin >> n >> k;
    ll ans = 0;
    vint h(n);
    REP(i,n){
        cin >> h[i];
    }
    sort(rALL(h));
    REP(i,n){
        if(k>0){
            k--;
        }else{
            ans+=(ll)h[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#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 <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;


void solve(long long N, std::vector<long long> X){
    vector<long long>li = X;
    SORT(li);
    int med = (li.size())/2 - 1;
    int med_low = li[med];
    int med_high = li[med+1];
    for(int i=0; i < N; i++){
        if(X[i]<med_high){
            cout<<med_high<<endl;
        }
        else{
            cout<<med_low<<endl;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> X(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&X[i]);
    }
    solve(N, std::move(X));
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

struct UnionFind{
	ll par[201000];
	ll rank[201000];
	ll siz[201000];

	void init(){
		for (ll i = 0; i < 201000; i++){
			par[i] = i;
			rank[i] = 1;
			siz[i] = 1;
		}
	}

	ll find(ll x){
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}

	void unite(ll x, ll y){
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (rank[x] < rank[y]){
			par[x] = y;
			siz[y] += siz[x];
		}
		else{
			par[y] = x;
			siz[x] += siz[y];
			if (rank[y] == rank[x])rank[x]++;
		}
	}

	bool same(ll x, ll y){
		return find(x) == find(y);
	}

	ll size(ll x){
		return siz[find(x)];
	}
};

UnionFind uf;
ll n,m;

int main(){
	cin >> n >> m;
	uf.init();
	vector<P> vp;
	rep(i,m){
		ll a,b;
		cin >> a >> b;
		vp.push_back(P(a,b));
	}
	reverse(ALL(vp));
	vector<ll> ans;
	ll num = n*(n-1)/2;
	rep(i,vp.size()){
		ll a = vp[i].first;
		ll b = vp[i].second;
		ans.push_back(num);
		if(uf.find(a) == uf.find(b))continue;
		num -= uf.size(a)*uf.size(b);
		uf.unite(a,b);
	}
	reverse(ALL(ans));
	rep(i,ans.size())cout << ans[i] << endl;
}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define MX 2010
#define EPS 0.00000000001
#define MOD 1000000007
#define PI acos(-1)
#define INF 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin>>n;
    LL ans = 0;
    loop(i,1,n + 1)
    {
        if((i % 3) && (i % 5)) ans+=i;
    }

    cout<<ans<<'\n';

    return 0;
}


Measured memory_bytes: 3592
n, m = list(map(int, input().split()))
X = list(map(int, input().split()))
if n >= m:
    print(0)
    exit()
X.sort()
dX = [X[i + 1] - X[i] for i in range(m - 1)]
dX.sort()
print(sum(dX[:m - n]))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    lli n, p;
    cin >> n >> p;
    lli sum = 0;
    vector<lli> v;
    lli a, b;
    rep(i, n)
    {
        cin >> a >> b;
        sum += -b * p;
        v.push_back(a * (100 - p) + b * p);
    }
    sort(v.begin(), v.end(), greater<lli>());
    rep(i, n)
    {
        sum += v[i];
        if (sum >= 0) {
            cout << i + 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int ans=700;
int main() {
	char a,b,c;
	cin>>a>>b>>c;
	if(a=='o') ans+=100;
	if(b=='o') ans+=100;
	if(c=='o') ans+=100;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, a[100005], s;

int main(){
	
	cin >> n;
	for( int i = 1 ; i <= n ; i++ ){
		cin >> a[i];
	}
	
	for( int i = 1 ; i <= n + 1 ; i++ ){
		s += abs(a[i] - a[i - 1]);
	}
	
	for( int i = 1 ; i <= n ; i++ ){
		int a1 = min( a[i - 1], a[i + 1] );
		int a2 = max( a[i - 1], a[i + 1] );
		if( a[i] > a2 ){
			cout << s - 2 * ( a[i] - a2 ) << endl;
		}
		if( a[i] < a1 ){
			cout << s - 2 * ( a1 - a[i] ) << endl;
		}
		if( a[i] >= a1 && a[i] <= a2 ){
			cout << s << endl;
		}
	}
}

Measured memory_bytes: 1664