akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, k, sum=0;
    cin >> n >> k;
    //aの各桁の1の合計, i桁目を1,0にするとどれだけ合計が増えるか
    vector<ll> num(40, 0), one(40, 0), zero(40, 0), ans;
    rep(i, n) {
        ll a; cin >> a;
        ll bit = 0;
        while(a>0) {
            if((a%2) != 0) {
                num[bit]++;
            }
            a /= 2;
            bit++;
        }
    }
    rep(i, 40) {
        one[i] = a_n(2, i)*(n-num[i]);
        zero[i] = a_n(2, i)*num[i];
    }
    vector<ll> bi(40, 0);
    ll bit = 0;
    while(k>0) {
        if((k%2) != 0) {
            bi[bit]++;
        }
        k /= 2;
        bit++;
    }

    for(ll i = 39; i >= 0; i--) {
        // bi[i] == 1 の時x[i]を0としてその後の合計をチェック
        if(bi[i] == 0) {
            sum += zero[i];
        }
        else {
            ll tmp = 0;
            tmp += zero[i];
            for(ll j = i-1; j >= 0; j--) {
                tmp += max(zero[j], one[j]);
            }
            ans.push_back(sum+tmp);
            sum += one[i];
        }
    }
    ans.push_back(sum);
    sort(ALL(ans), greater<ll>());

    cout << ans[0] << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

ll my_gcd(ll a, ll b) {
    if(b == 0) return a;
    return my_gcd(b, a%b);
}

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<deque>
using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> x(n,0),y(n,0);
    for (int i=0;i<n;i++) {
        int a,b;cin>>a>>b;
        x[i]=a;
        y[i]=b;
    }
    map<vector<ll>,vector<vector<ll>>> test;
    for (int i=0;i<n;i++) {
        for (int j=0;j<n;j++) {
            if (i<j) {
                ll dx,dy;
                ll st,ed;
                if (x[j]-x[i]>0) {
                    dx = x[j]-x[i];
                    dy = y[j]-y[i];
                    st = i;
                    ed = j;
                }
                else if (x[i]==x[j]) {
                    if (y[j]-y[i]>0) {
                        dx = 0;
                        dy = y[j]-y[i];
                        st = i;
                        ed = j;
                    }
                    else {
                        dx = 0;
                        dy = y[i]-y[j];
                        st = j;
                        ed = i;
                    }
                }
                else {
                    dx = x[i]-x[j];
                    dy = y[i]-y[j];
                    st = j;
                    ed = i;
                }
                vector<ll> tempv = {dx,dy};
                test[tempv].push_back({st,ed});
            }            
        }
    }

    map<vector<ll>,vector<vector<ll>>> test2;
    for(auto tt:test) {
        bool flag = true;
        while (flag) {
            flag = false;
            bool change = false;
            for (auto testi = tt.second.begin();testi != tt.second.end();testi++) {
                if (change) break;
                for (auto testj = tt.second.begin();testj != tt.second.end();testj++) {
                    if (testi<testj) {
                        if ((*testi).back()==(*testj).front()) {
                            copy((*testj).begin()+1,(*testj).end(),back_inserter(*testi));
                            tt.second.erase(testj);
                            change = true;
                            flag = true;
                            break;
                        }
                        if ((*testi).front()==(*testj).back()) {
                            copy((*testi).begin()+1,(*testi).end(),back_inserter(*testj));
                            tt.second.erase(testi);
                            change = true;
                            flag = true;
                            break;
                        }
                    }                    
                }
                
            }
        }
        test2[tt.first] = tt.second;    
    }

    ll g = 999999;
    for(auto tt:test2) {
        ll ttsize = tt.second.size();
        ll usePoint = 0;
        for(auto ttt2:tt.second) {
            for(auto p=ttt2.begin();p!=ttt2.end();p++) {
                usePoint++;
            }
        }
        g = min(g, ttsize + n-usePoint);
    }
    if (n==1) cout << 1 << endl;
    else cout << g << endl;
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef queue<int> qi;

int main(){
  int n, r;
  while(~scanf("%d%d", &n, &r)){
    int c[50];
    rep(i, r) scanf("%d", c+i);

    qi aq;

    rep(i, n) aq.push(i);

    rep(i, r){
      qi bq, cq;
      rep(j, n-(n+1)/2){
	bq.push(aq.front()); aq.pop();
      }

      /*      rep(j, aq.size()){
	int a = aq.front(); aq.pop();
	printf("%d ", b);
	aq.push(a);
      } puts("");
      printf("%d\n", (int)bq.size());
      rep(j, bq.size()){
	int b = bq.front(); bq.pop();
	printf("%d ", b);
	bq.push(b);
	}puts("");*/

      while(!aq.empty() || !bq.empty()){
	rep(j, c[i]) if(!aq.empty()){ cq.push(aq.front()); aq.pop();}
	rep(j, c[i]) if(!bq.empty()){ cq.push(bq.front()); bq.pop();}
      }
      aq = cq;
    }

    printf("%d\n", aq.back());
  }
  return 0;
}

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

#define ll long long

ll get_lcm(ll a, ll b){
    return (a*b) / (__gcd(a, b));
}

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

    ll n, m;
    cin >> n >> m;
    ll a[n];
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        a[i] >>= 1;
    }
    ll lcm = a[0];
    bool good = true;
    for(ll i = 0; i < n; i++){
        lcm = get_lcm(lcm, a[i]);
    }
    for(auto x : a){
        if(lcm/x % 2 == 0){
            good = false;
            break;
        }
    }
    if(!good){
        cout << 0 << endl;
    }
    else{
        cout << ((m / lcm)+1)/2 << endl;
    }

}

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

typedef long long ll;

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<string.h>
using namespace std;

double dp[100001][31];//100*pow(2,-i) ?¢????
double K[100001];
signed main() {
	dp[0][0] = 1;
	for (int i = 0; i < 100000; i++) {
		double T = 0;
		for (int j = 0; j < 30; j++) {
			//??????????????????
			dp[i + 1][j + 1] += dp[i][j] * pow(2, -j);
			T += dp[i][j] * pow(2, -j);
			//????????????
			dp[i + 1][0] += dp[i][j] * (1- pow(2, -j));
		}
		K[i + 1] =K[i]+ T;
	}
	int a;
	while (cin >> a, a) {
		printf("%.10lf\n", K[a]);
	}
}

Measured memory_bytes: 28172
#include <stdio.h>

int main(){
   long long a,bb;
   int i;
   char b[5];

   scanf("%lld %s",&a,b);
   bb=0;
   for (i=0;b[i]!='\0';i++)
      if (b[i]!='.') bb=bb*10+b[i]-'0';
   printf("%lld\n",a*bb/100);
   return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,h;
  cin>>n>>h;
  vector<vector<int>> ab(n*2,vector<int>(2));
  for(int i=0;i<n*2;i+=2){
    int a,b;
    cin>>a>>b;
    ab.at(i)={a,0};
    ab.at(i+1)={b,1};
  }
  sort(ab.begin(),ab.end());
  int c=0;
  int p=2*n-1;
  while(h>0){
    if(ab.at(p).at(1)){
      c++;
      h-=ab.at(p).at(0);
      p--;
    }else{
      c+=(h+ab.at(p).at(0)-1)/ab.at(p).at(0);
      h=0;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 11136
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('a1.in')


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


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


def read_int():
    return int(input())


def read_str():
    return input()


def main_0():
    H, A = read_int_list()
    res = 0
    for i in range(10001):
      H = H - A
      res += 1
      if H <= 0:
        break
    print(res)


def main_1():
    H, A = read_int_list()
    res = H // A
    if H % A != 0:
      res += 1
    print(res)


def main():
    H, A = read_int_list()
    res = 0
    while H > 0:
      H -= A
      res += 1
    print(res)

main_1()


Measured memory_bytes: 3828
#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;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[2123456]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}


//extended euclidean algorithm( x is inverse of a wrt b onlt if gcd!=1)
ll gcd(ll a,ll b,ll &x,ll &y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1,y1;
	ll d=gcd(b,a%b,x1,y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;

}


int main()
{
speed
ll n;
cin>>n;
ll a[n];
rep(i,0,n) cin>>a[i];
ll f=0;

for(int i=n-1;i>=0;i--)
{
	ll z=a[i];
	
	
	for(ll j=2;j*j<=z;j++)
	{
		ll c=0;
		while(z%j==0) {
			c++;
			z/=j;
		}
		if(c>0&&vis[j])
		{
			f=1;
			//break;
		}
		if(c>0) vis[j]++;
	}
	if(z>1)
	{
		if(vis[z]) f=1;
		vis[z]++;
	}
}
if(f==0) cout<<"pairwise coprime\n";
else
{	f=0;
	rep(i,1,1000001) if(vis[i]>=n) f=1;
	if(f==0) cout<<"setwise coprime\n";
	else cout<<"not coprime\n";
}
}



Measured memory_bytes: 23800
#include <bits/stdc++.h>
using namespace std;
const long long modu=1e9+7;
long long ans;
long long qm(long long x,long long base)
{
	if(x==1)return base;
	long long val;//cout<<val<<endl;
	if(x%2==1){
		long long temp=qm(x>>1,base);
		val=base*((temp*temp)%modu);	
	}
	else{
		long long temp=qm(x>>1,base);
		val=temp*temp;
	}
	val%=modu;
	return val;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n;
	cin>>n;
	if(n==1){
		cout<<0<<endl;
		return 0;	
	}
	else if(n==2){
		cout<<2<<endl;
		return 0;
	}
	ans=2;
	//cout<<qm(n,9)<<endl;
	ans*=qm(n,9);
	ans%=modu; 
	//cout<<ans<<endl;
	ans-=qm(n,8);
	ans%=modu;	
	//cout<<ans<<endl;
	ans=qm(n,10)+modu-ans;//cout<<ans<<endl;
	ans%=modu;
	cout<<ans<<endl;
	return 0;
}

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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << max({a+b, a-b, a*b}) << endl;
}


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

int main(void){
    long n;
    cin >> n;
    vector<string> v(n);
    for(long i=0; i<n; i++){
        cin >> v[i];
        for(long j=0; j<i; j++){
            if(v[i]==v[j]){
                cout << "No" << endl;
                return 0;
            }
        }
        if(i>0){
            if(v[i-1].back() != v[i].front()){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" <<endl;
    return 0;
}


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

using ll = long long;
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define file freopen("in.txt", "r", stdin);
#define pii pair<int, int>
#define pll pair<ll, ll>

const int maxn = 1e5 + 5;
ll dp[maxn];
int n, k, arr[maxn];
ll inf = 1e11;

ll call(int i){
	if(i >= n-1)return 0;
	if(dp[i] != -1)return dp[i];
	ll ret = inf;
	for(int j=1; j<=k; j++){
		if(i+j <= n-1)ret = min(ret, abs(arr[i] - arr[i+j]) + call(i+j));
	}
	return dp[i] = ret;
}

int main(){
	//file
	scanf("%d %d", &n, &k);
	for(int i=0; i<n; i++)scanf("%d", &arr[i]);
	memset(dp, -1, sizeof dp);
	cout<<call(0)<<endl;
}

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

using namespace std;
using vi = vector <int>;

void fileIO() {
    #ifdef ROBIN
        freopen("in", "r", stdin);
        freopen("out", "w", stdout);
    #endif // ROBIN
}

int main() {
    // optimize();
    fileIO();
    int n; cin >> n;
    int a, b;
    vi P, Q, original_permutation;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        P.push_back(x);
    }

    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        Q.push_back(x);
    }

    for (int i = 1; i <= n; i++) original_permutation.push_back(i);
    //ekhon shobgula permutations bair korbo
    int koto_tomo = 1;
    do {
        if (original_permutation == P) a = koto_tomo;
        if (original_permutation == Q) b = koto_tomo;
        koto_tomo++;
    } while (next_permutation(original_permutation.begin(), original_permutation.end()));

    cout << abs(a - b) << endl;
}


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

using namespace std;

long n, ans;
map<long, long> x, y;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		long p;
		cin >> p;
		x[i + p]++;
		y[i - p]++;
	}

	for (auto it : x) ans += it.second * y[it.first];
	cout << ans;
}


Measured memory_bytes: 37892
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=3100000;
const int inf=0x3f3f3f3f;
const ll mod=1000000007;

int tl[Maxn],tr[Maxn],n,m;
ll tn[Maxn],flag[Maxn];

void build(int root,int l,int r) {
	tl[root]=l;tr[root]=r;
	int mid=l+r>>1;
	if(l==r) return;
	build(root<<1,l,mid);
	build((root<<1)|1,mid+1,r);
}

inline void update(int root) {
	tn[root]=max(tn[root<<1],tn[(root<<1)|1]);
}

void pushdown(int root) {
	if(flag[root]) {
		flag[root<<1]+=flag[root];
		tn[root<<1]+=flag[root];
		flag[(root<<1)|1]+=flag[root];
		tn[(root<<1)|1]+=flag[root];
		flag[root]=0;
	}
}

ll query(int root,int x) {
	int l=tl[root],r=tr[root],mid=l+r>>1;
	if(r==x) return tn[root];
	pushdown(root);
	if(x<=mid) return query(root<<1,x);
	else return max(tn[root<<1],query((root<<1)|1,x));
}

void change(int root,int l,int r,ll x) {
	int lc=tl[root],rc=tr[root],mid=lc+rc>>1;
	if(l<=lc&&r>=rc) {
		flag[root]+=x;
		tn[root]+=x;
		return;
	}
	pushdown(root);
	if(l<=mid) change(root<<1,l,r,x);
	if(r>mid) change((root<<1)|1,l,r,x);
	update(root);
}

struct node {
	int l,r;
	ll x;
}b[Maxn];

int cmp(node a,node b) {
	return a.r<b.r;
}

signed main() {
//	freopen("test.in","r",stdin);
	read(n,m);
	for(int i=1;i<=m;i++)
		read(b[i].l,b[i].r,b[i].x);
	sort(b+1,b+m+1,cmp);
	build(1,1,n);
	int zhy=1,nh=1;
	for(int i=1;i<=n;i++) {
		change(1,i,i,query(1,i));
		while(b[nh].r==i) {
			change(1,b[nh].l,b[nh].r,b[nh].x);
			nh++;
		}
	}
	printf("%lld",max(tn[1],0ll));
	return 0;
}



Measured memory_bytes: 24704
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    long xx = Long.parseLong(x);
    long balance = 100;
    long ans = 0;
    while(balance < xx){
      balance = balance + (long)(balance * 0.01);
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35680
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int p[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int d[25]={0};

int main() {
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        for(int j=0;j<25;j++){
            int k=i;
            while(k%p[j]==0){
                d[j]++;
                k /= p[j];
            }
        }
    }
    ll n2=0,n4=0,n14=0,n24=0;
    rep(i,25){
        if(d[i]>=2) n2++;
        if(d[i]>=4) n4++;
        if(d[i]>=14) n14++;
        if(d[i]>=24) n24++;
    }
    ll ans=0;
    if(d[0]>=74) ans++;
    ans += n4*(n4-1)*(n2-2)/2 + n24*(n2-1) + n14*(n4-1);
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

void dfs1(int v, int &k, mat &G, vec &level){
    level[v] = -2;
    for(int to : G[v]){
        if(level[to] == -1) dfs1(to, k, G, level);
    }
    level[v] = k++;
}

void dfs2(int v, mat &G, vector<bool> &used, vec &res){
    used[v] = true;
    res.push_back(v);
    for(int to : G[v]) if(!used[to]) dfs2(to, G, used, res);
}

void scc(mat &G, mat &res){
    int n = G.size();
    mat G_rev(n, vec(0));
    rep(u, n) rep(v, (int)G[u].size()) G_rev[G[u][v]].push_back(u);
    vec level(n, -1), ord(n);
    vector<bool> used(n, false);
    int k(0);
    rep(i, n) if(level[i] == -1) dfs1(i, k, G, level);
    rep(i, n) ord[level[i]] = i;
    Rrep(i, n) {
        if(!used[ord[i]]) {
            vec temp(0);
            dfs2(ord[i], G_rev, used, temp);
            res.push_back(temp);
        }
    }
}

int main() {
    cin>>N>>M;
    mat G(N, vec(0));
    vec num_in(N, 0);
    rep(i,M){
        int a, b;
        cin>>a>>b;
        G[a].push_back(b);
    }
    mat scc_list(0);
    scc(G, scc_list);
    cout<<(int)scc_list.size()<<endl;
    for(vec v : scc_list){
        int n = v.size();
        cout<<n<<' ';
        rep(i, n) cout<<v[i]<<" \n"[i == n - 1];
    }
}


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

int N;
vector<int> g[1000000];
ll dp[1000000][2];
bool checked[1000000];

void dfs(int p) {
    dp[p][0] = 1;
    dp[p][1] = 1;
    for (int q : g[p]){
        if (!checked[q]){
            checked[q] = true;
            dfs(q);
            dp[p][0] = dp[p][0] * (dp[q][0] + dp[q][1]) % mod;
            dp[p][1] = dp[p][1] * dp[q][0] % mod;
        }
    }
    return;
}

int main() {
    cin >> N;
    int x, y;
    REP(i, N-1){
        cin >> x >> y;
        g[x-1].push_back(y-1);
        g[y-1].push_back(x-1);
    }
    REP(i, N) checked[i] = false;
    checked[0] = true;
    dfs(0);
    cout << (dp[0][0] + dp[0][1]) % mod << endl;

}

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;

int main() {
    
    int h, w, k;
    cin >> h >> w >> k;

    int ans = 0;

    char a;
    int c[h][w];
    rep(y, h) {
        rep(x, w) {
            cin >> a; // w.1, b#0
            int add = 0;
            if (a == '.') add = 1;
            c[y][x] = add;
        }
    }

    for (int i = 0; i < (1 << h); i++) { // 行
        for (int j = 0; j < (1 << w); j++) { // 列

            int sum = 0;
            rep(y, h) { //y
                if (i & (1 << y)) {
                    continue;
                }

                rep(x, w) { //x 
                    if (j & (1 << x)) {
                        continue;
                    }

                    if (c[y][x] == 0)
                        sum++;
                }
            }

            if (sum == k)
                ans++;
            //cout << endl;
            /*

            
            for (int k = 1; k <= h; k++)
            {
                for (int l = 1; l <= w; l++)
                {

                    bool is = true;
                    rep(o, ww.size()) {
                        rep(p, hh.size()) {
                            if (k == ww[o] || l == hh[p])
                            {
                                is = false;
                            }
                        }
                    }

                    if (is && c[k - 1][l - 1] == 0)
                        sum++;
                }
            }

            //AA(sum);
            if (sum == k) {
                cout << "列";
                rep(o, ww.size())
                        cout
                    << ww[o];

                cout << " 行";

                rep(p, hh.size())
                        cout
                    << hh[p];

                cout << endl;

                ans++;
            }*/

            
        }
                
    }

    AA(ans);
}

Measured memory_bytes: 3624
n,d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]

cnt=0

for i in range(n):
    for j in range(i+1,n):
        sum=0.0
        for dd in range(d):
            sum+=(x[i][dd]-x[j][dd])**2
        sum=sum**(1/2)
        if sum.is_integer():
            cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll a[55],b[25];
ll ans=0;
ll kouho=INF;
 
int main(){
	cin>>n;
	if(n>=14){
		ans=1;
		for(i=0;i<n;i++){
			cin>>a[i];
		}
		for(i=0;i<=12;i++){
			b[i]=0;
		}
		for(i=0;i<n;i++){
			m=a[i];
			b[m]++;
		}
		for(i=1;i<=11;i++){
			if(b[i]>=3){
				ans=0;
			}
		}
		if(b[12]>=2 || b[0]>=1)ans=0;
		//0ninarubeki nanoni 0zyanai

	}else{
		for(i=0;i<n;i++){
			cin>>a[i];
		}
		a[n]=0;
		for(i=0;i<=16383;i++){
			for(j=0;j<n+1;j++){
				if(i & 1<<j){
					b[j]=a[j];
				}else{
					b[j]=24-a[j];
				}
			}
			kouho=INF;
			for(k=0;k<n+1;k++){
				for(j=0;j<n+1;j++){
					if(k==j)continue;
					kouho=min(min(24-abs(b[k]-b[j]),abs(b[k]-b[j])),kouho);
				}
			}
		ans=max(ans,kouho);
		}
	}
	if(n==1)ans=min(a[0],24-a[0]);
	p(ans);
				
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n;
    int x=0;
    cin >> n;
    map<int,int>mp;
    rep(i,n){
        int a;
        cin >> a;
        if(1<=a&&a<=399) mp[0]++;
        if(400<=a&&a<=799) mp[1]++;
        if(800<=a&&a<=1199) mp[2]++;
        if(1200<=a&&a<=1599) mp[3]++;
        if(1600<=a&&a<=1999) mp[4]++;
        if(2000<=a&&a<=2399) mp[5]++;
        if(2400<=a&&a<=2799) mp[6]++;
        if(2800<=a&&a<=3199) mp[7]++;
        if(a>=3200) x++;
    }
    int mn=mp.size();
    if(mn==0){
        if(x>0)mn=1;
        else mn=0;
    }
    int mx=mp.size()+x;
    cout << mn << " " << mx <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int time, key;
} job;

void merge_sort(job x[], int n)
{
	static job y[200001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	job X[200001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%d %d", &(X[i].time), &(X[i].key));

	int flag = 1, t = 0;
	merge_sort(X, N);
	for (i = 0; i < N; i++) {
		if (t + X[i].time <= X[i].key) t += X[i].time;
		else break;
	}
	if (i == N) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3328
N,M = map(int, input().split())
E = [[int(e) for e in input().split()] for _ in range(M)]

E.sort()
L = []
idx = N
for i in range(M):
    if E[i][0] == 1:
        L.append(E[i][1])
    else:
        idx = i
        break
        
L.sort()
ans = "IMPOSSIBLE"
for i in L:
    while idx < M:
        if E[idx][0] == i:
            if E[idx][1] == N:
                ans = "POSSIBLE"
                idx = M
            else:
                idx += 1
        elif E[idx][0] < i:
            idx += 1
        else:
            break
            
print(ans)

Measured memory_bytes: 85284
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1e6 + 7;

int n;
int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    string s1, s2;
    cin >> s1;
    cin >> s2;
    if(s1.size() + 1 == s2.size() && s1 == s2.substr(0, s1.size()))cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  int q;
  cin >> s >> q;
  
  bool r = 0;//反転していれば1
  
  rep(i, 1, q+1) {
    int t; cin >> t;
    
    if(t==2) {
      int f; string c; cin >> f >> c;
      if(f==2) {
        if(r) s.insert(0, c);
        else s += c;
      }
      if(f==1) {
        if(!(r)) s.insert(0, c);
        else s += c;
      }
    }
    
    if(t==1) r = !(r);
    
  }
  
  if(r) reverse(all(s));
  
  cout << s << "\n";

}


Measured memory_bytes: 912
#include<stdio.h>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> g[11000];
vector<int> g2[11000];
int c[11000];
int r[11000];
int ijk[11000];
int v[11000];
int bfs[11000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",c+i,r+i);
	}
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);g[q].push_back(p);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++)bfs[j]=-1;
		bfs[i]=0;
		queue<int>Q;
		Q.push(i);
		while(Q.size()){
			int at=Q.front();Q.pop();
			for(int j=0;j<g[at].size();j++){
				if(!~bfs[g[at][j]]){
					bfs[g[at][j]]=bfs[at]+1;
					Q.push(g[at][j]);
				}
			}
		}
		for(int j=0;j<a;j++){
			if(~bfs[j]&&bfs[j]<=r[i]){
				g2[i].push_back(j);
			}
		}
	}
	priority_queue<pair<int,int> >Q;
	for(int i=0;i<a;i++){
		ijk[i]=999999999;
		v[i]=0;
	}
	ijk[0]=0;
	Q.push(make_pair(0,0));
	while(Q.size()){
		int cost=-Q.top().first;
		int at=Q.top().second;Q.pop();
		if(v[at])continue;v[at]=1;
		for(int i=0;i<g2[at].size();i++){
			if(!v[g2[at][i]]&&ijk[g2[at][i]]>cost+c[at]){
				ijk[g2[at][i]]=cost+c[at];
				Q.push(make_pair(-ijk[g2[at][i]],g2[at][i]));
			}
		}
	}
	printf("%d\n",ijk[a-1]);
}

Measured memory_bytes: 69012
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n;
  cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
  cin>>a[i];
}
int j=a[0];
for(int i=1;i<n-1;i++){
  j^=a[i];
}
if(a[n-1]==j)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
// other libs
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first)
				continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	Union_Find(T max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y))
			return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
bool ifPrime(int n) {
	if (n == 1)
		return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)
			return false;
	}
	return true;
}
vector<int> primeFactorization(int n) {
	vector<int> re;
	int cnt = 2;
	while (n != 1) {
		if (n % cnt != 0) {
			cnt++;
			continue;
		}
		n /= cnt;
		re.push_back(cnt);
	}
	return re;
}
signed main(signed argc, char* argv[]) {
    int n;
    cin>>n;
    vector<P> vec(n);
    rep(i,n){
        int a;
        cin>>a;
        vec[i]={a,i+1};
    }
    sort(vec.begin(),vec.end());
    rep(i,n){
        cout<<vec[i].second;
        if(i+1!=n)cout<<" ";
        else cout<<endl;
    }
}

Measured memory_bytes: 2432
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    String w;
    Map<String, Integer> map = new HashMap<>();
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	for(int i = 0; i < w.length(); i++) {
	    String c = String.valueOf(w.charAt(i));
	    if(map.get(c) == null) {
		map.put(c, 1);
	    } else {
		map.put(c, map.get(c) + 1);
	    }
	}

	boolean flg = true;
	for(String key : map.keySet()) {
	    if(map.get(key) % 2 == 1) flg = false;
	}
	
	if(flg) out("Yes");
	else    out("No");
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	w = sc.next();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(double n)
    {
	System.out.println(n);
    }

    void out(long n)
    {
	System.out.println(n);
    }
    
    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int len = s.size();
    if (s[len - 1] == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
}

Measured memory_bytes: 3624
A = []

s = int(input())
A.append(s)

i = 0
while True:
    if A[i] % 2 == 0:
        a = A[i] // 2
    else:
        a = A[i] * 3 + 1
    if a in A:
        m = i + 2
        print(m)
        exit()
    A.append(a)
    i += 1


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl 	"\n"

typedef vector< ll > 	vi;
typedef vector< vi > 	vvi;
typedef pair< ll,ll > 	ii;
#define pb 		push_back
#define all(c) 		(c).begin(),(c).end()
#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 MOD 	1000000007
#define INF 	(int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

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

	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++)
		cin>>a[i];
	//a[n]=0;
	ll ans=0, b[n+1]={0};

	for(ll i=0; i<n; i++)
	{
		if( a[i] >= a[i+1])
			b[i]=1;
		else b[i]=0;
	}
	//for(ll i=0; i<n; i++)
	//	cout<<b[i]<<" ";
	ll t=-1;
	for(ll i=0; i<n; i++)
	{
		if(b[i])
			ans++;
		else ans=0;
		t= max(t, ans);
	}
	cout<<t;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    double a,b,c,degree,S;
    scanf("%lf %lf %lf",&a,&b,&degree);
    S = (0.5)*a*b*sin(M_PI*degree/180);
    c = sqrt(a*a+b*b-2*a*b*cos(M_PI*degree/180));
    printf("%.8lf\n",S);
    printf("%.8lf\n",a+b+c);
    printf("%.8lf\n",2*S/a);
}


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define li long int
#define ll long long int
#define vec(x) vector<x> 
#define st(x) set<x> 
#define mpp(x,y) map<x,y> 
#define pi(x,y) pair<x,y>
#define forf(i,x,y) for(ll i=x;i<y;i++)
#define forl(i,x) for(ll i=x-1;i>=0;i--)
#define rev(x) reverse(x.begin(),x.end())
#define mem(x,a) memset(x,a,sizeof(x))
#define mod 1000000007
#define nxt_per(x) next_permutation(x.begin(),x.end())
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define vp(x,y) vec(pi(x,y) )
#define all(x) x.begin(),x.end()

using namespace std;

int main()
{
	ll ans=0;
	int n;
	cin>>n;
	int arr[n];
	forf(i,0,n)
	{	cin>>arr[i];
		ans+=arr[i]-1;
	}
	cout<<ans;
	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 rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
constexpr auto INF = INT_MAX/2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

struct UnionFind {

	vi data;

	UnionFind(int n = 0) {
		data.assign(n, -1);
	}

	int find(int k) {
		if (data[k] < 0) return k;
		return data[k] = find(data[k]);
	}
	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return false;
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int k) { return -data[find(k)]; }

};

int main() {

	int n, m;
	cin >> n >> m;

	vi a(m), b(m);

	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--;b[i]--;
	}

	UnionFind uf(n);

	ll e = n * ((ll)n - 1) / 2;
	V<ll>ans(m);

	rep(i, m) {
		ans[m - 1 - i] = e;
		if (!uf.same(a[m - 1 - i], b[m - 1 - i])) {
			e -= (ll)uf.size(a[m - 1 - i]) * uf.size(b[m - 1 - i]);
			uf.unite(a[m - 1 - i], b[m - 1 - i]);
		}
	}

	rep(i, m)cout << ans[i] << endl;

}

Measured memory_bytes: 3328
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
a = [LIST() for _ in range(H)]

cnt = 0
move = []
for i in range(H):
	for j in range(W):
		if i == H-1 and j == W-1:
			print(cnt)
			for x in move:
				print(*x)
			exit()
		if i%2 == 0:
			if a[i][j]%2 == 1 and j == W-1:
				a[i][j] -= 1
				a[i+1][j] += 1
				cnt += 1
				move.append((i+1, j+1, i+2, j+1))
			elif a[i][j]%2 == 1:
				a[i][j] -= 1
				a[i][j+1] += 1
				cnt += 1
				move.append((i+1, j+1, i+1, j+2))
		else:
			if a[i][W-j-1]%2 == 1 and j == W-1:
				a[i][W-j-1] -= 1
				a[i+1][W-j-1] += 1
				cnt += 1
				move.append((i+1, W-j, i+2, W-j))
			elif a[i][W-j-1]%2 == 1:
				a[i][W-j-1] -= 1
				a[i][W-j-2] += 1
				cnt += 1
				move.append((i+1, W-j, i+1, W-j-1))


Measured memory_bytes: 29712
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

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

    vector<int> b(N); // すぬけくん_i が持っているお菓子の数を数える配列

    rep(i, K) {
        int d; cin >> d;
        rep (j, d) {
            int A; cin >> A;
            b[A - 1]++;
        }
    }

    int ans = 0;
    rep(i, N) if (b[i] == 0) ans++;

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


Measured memory_bytes: 3612
import java.util.Scanner;
import java.lang.Math; 

public class Main{
    public static void main(String args[] ) {

        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();

        int i=0;
        while(i>=0) {
            if((Math.floor(i*0.08)==A) && (Math.floor(i*0.1)==B)) {
                System.out.println(i);
                break;
            } else if((Math.floor(i*0.08)>A) && (Math.floor(i*0.1)>B)) {
                System.out.println("-1");
                break;
            }
            i++;
        }


        sc.close();
    }
}


Measured memory_bytes: 23876
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);

		//たこ焼き数
		int N = scan.nextInt();

		//たこ焼き美味しさ　di入力
		int[] d = new int[N];
		for (int i=0; i<N;i++) {
			d[i] = scan.nextInt();
		}

		//総和 初期化
		int total = 0;

		//総和 算出
		for(int i=0; i<N-1; i++) {
			for(int j= i+1; j<N; j++) {
				total = total + d[i] * d[j];
			}
		}

		System.out.println(total );

	}

}


Measured memory_bytes: 26976
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
typedef unsigned long long ull;
typedef long long ll;
typedef float ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
uniform_real_distribution<double> double_dist(0, 1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	char c;
	cin >> c;
	if (c == 'A')
		cout << "T";
	else if (c == 'T')
		cout << "A";
	else if (c == 'C')
		cout << "G";
	else if (c == 'G')
		cout << "C";
	return 0;
}


Measured memory_bytes: 256
#
# abc167 c
#
import sys
from io import StringIO
import unittest
from collections import deque


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 3 10
60 2 2 4
70 8 7 9
50 2 3 9"""
        output = """120"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 3 10
100 3 1 4
100 1 5 9
100 2 6 5"""
        output = """-1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2"""
        output = """1067"""
        self.assertIO(input, output)


def resolve_bit():
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]

    ans = float("inf")
    for bit in range(1 << N):
        S = [0]*(M+1)
        for i, ca in enumerate(CA):
            if (1 << i) & bit == 1 << i:
                S = list(map(sum, zip(S, ca)))
        for s in S[1:]:
            if s < X:
                break
        else:
            ans = min(ans, S[0])

    if ans == float("inf"):
        ans = -1

    print(ans)


def resolve():
    global N, M, X, CA
    N, M, X = map(int, input().split())
    CA = [list(map(int, input().split())) for _ in range(N)]

    b = deque()
    ans = dfs(0, b)
    if ans == float("inf"):
        ans = -1

    print(ans)


def dfs(n, B):
    if n == N:
        S = [0]*(M+1)
        for i, ca in enumerate(CA, 1):
            if i in B:
                S = list(map(sum, zip(S, ca)))
        if min(S[1:]) < X:
            return float("inf")
        else:
            return S[0]

    ans = float("inf")
    B.append(n+1)
    ans = min(ans, dfs(n+1, B))
    B.pop()
    ans = min(ans, dfs(n+1, B))

    return ans


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16312
s=chomp(readline())

n=length(s)
flag="Yes"
l=div(n,2)
for i in 1:l
    if s[i]!=s[n-i+1]
        flag="No"
    end
end
l=div(div(n-1,2),2)
for i in 1:l
    if s[i]!=s[div(n-1,2)-i+1]
        flag="No"
    end
end

for i in div(n+3,2):n
    ss=n-(i-div(n+3,2))
    if s[i]!=s[ss]
        flag="No"
    end
end


print(flag)       

Measured memory_bytes: 109324
#include <iostream>
#include <vector>

using namespace std;

int main() {
    while(true) {
        int N, R;
        cin >> N >> R;
        if(!N && !R) break;

        vector<int> cards(N);
        for(int i = 0; i < N; ++i) cards[i] = N-i;

        while(R--) {
            int P, C;
            cin >> P >> C;
            P--;
            vector<int> tmp;
            for(int i = 0; i < C; ++i) tmp.push_back(cards[P+i]);
            for(int i = 0; i < P; ++i) tmp.push_back(cards[i]);
            for(int i = P+C; i < N; ++i) tmp.push_back(cards[i]);
            cards = tmp;
        }

        cout << cards[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 0