akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

#define vcitr vector<int>::iterator
#define vcsitr vector<string>::iterator
#define mapcitr map<char, int>::iterator
#define mapsitr map<string, int>::iterator

typedef long long ll;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }

int main() {
	vci a(4), b(4);
	bool use[10] = { 0 };
	
	while (cin>>a[0]) {
		for_(i, 1, 4) cin>>a[i];
		for_(i, 0, 4) cin>>b[i];
		memset(use, 0, sizeof(use));
		for_(i, 0, 4) use[ a[i] ] = 1;
		
		int hit = 0, blow = 0;
		for_(i, 0, 4) {
			if (a[i] == b[i]) hit++;
			else if (use[ b[i] ]) blow++;
		}
		cout << hit << " " << blow << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1192
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define in inline
#define reg register
//#define int long long
#define MAX 20030813
using namespace std;
namespace qwq{
	in void read(int &o) {
		o=0;
		int w=1;
		char c=getchar();
		while(c<'0'||c>'9') {
			if(c=='-')w*=-1;
			c=getchar();
		}
		while(c>='0'&&c<='9') {
			o=(o<<3)+(o<<1)+(c^48);c=getchar();
		}
		o*=w;
	}
	void write(int x){
	   	if(x<0)putchar('-'),x=-x;
    	if(x>9)write(x/10);
		putchar(x%10+48);
	}
	void Write(int x) {
		write(x);putchar(' ');
	}
	in int max(int x,int y){return x>y?x:y;}
	in int min(int x,int y){return x<y?x:y;}
}
using namespace qwq;
class Student{
public:
	int id,n;
	bool operator<(const Student&s)const{return n<s.n;}
}a[MAX];
int N,M,ans; 
signed main()
{
	read(N);
	for(reg int i=1;i<=N;++i)
	{
		read(a[i].n),a[i].id=i;
	}
	sort(a+1,a+N+1);
	for(reg int i=1;i<=N;++i)Write(a[i].id);
	return 0;
}




Measured memory_bytes: 1536
A,B,C,D = map(int,input().split())
if A%D ==0:
    cnt_t = A//D
else:
    cnt_t = A//D+1
if C%B==0:
    cnt_a=C//B
else:
    cnt_a =C//B+1

if cnt_t <cnt_a:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n, a, b;
int main()
{
	cin >> n >> a >> b;
	cout << min(n*a, b) << endl;
	return 0;
}

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

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

        long long amari = N % K;
        if (amari == 0) {
                cout << amari << endl;
        }
        else {
                long long tmp = abs(amari - K);
                if (tmp < N) {
                        cout << tmp << endl;
                }
                else {
                        cout << N << endl;
                }

        }

}


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

using Edge = pair<int, long long>;
using Graph = vector<vector<Edge> >;

// K  から各点 v への距離 dist[ v ]
void rec(const Graph &G, int v, int p, long long sum, vector<long long> &dist) {
    dist[v] = sum;
    for (auto e : G[v]) {
        if (e.first == p) continue;
        rec(G, e.first, v, sum+e.second, dist);
    }
}

int main() {
    // input
    // N個の頂点 
    int N; cin >> N;
    Graph G(N);
    // 頂点a,b 距離c
    for (int i = 0; i < N-1; ++i) {
        int a, b; long long c; cin >> a >> b >> c;
        --a, --b;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    // x1,y1, 中継地点K
    int Q, K; cin >> Q >> K; --K;
    //  x->K->y の距離
    vector<long long> dist(N, 0);

    // K  から各点 v への距離 dist[ v ]
    rec(G, K, -1, 0, dist);

    // K から x への最短経路長と　K から y への最短経路長をたす
    for (int q = 0; q < Q; ++q) {
        int x, y; cin >> x >> y; --x, --y;
        cout << dist[x] + dist[y] << endl;
    }
}   

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int lower = max(A,C);
  int upper = min(B,D);
  
  cout << max(0, upper -lower) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

LL a, b, c, d;

inline void work() {
    cin >> a >> b >> c >> d;
    cout << max({a * c, a * d, b * c, b * d}) << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b; cin >> a>> b;
  cout << 6-a-b << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=2e5+5;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)


signed main()
{
    int n,m;
    cin>>n;
    vi arr(n);
    vi A(n);
    vi B(n);    
    //for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i++)
    {
        cin>>A[i]>>B[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    if (n&1)
    {
        cout<<(B[n/2]-A[n/2]+1)<<"\n";

    }
    else 
    { 
        cout<<B[n/2]+B[n/2-1]-A[n/2]-A[n/2-1]+1<<"\n";
    }



}

    
    

Measured memory_bytes: 8000
import java.util.*;

public class Main {

	public static int changeTable(char a) {
		switch (a) {
			case 'R':
				return 0;
			case 'G':
				return 1;
			case 'B':
				return 2;
		}
		return -1;
	}

	public static char changeTable(int a) {
		switch (a) {
			case 0:
				return 'R';
			case 1:
				return 'G';
			case 2:
				return 'B';
		}
		return '\0';
	}

	public static int restrgb(int t, int s) {
		int tmp = s + t;
		switch (tmp) {
			case 1:
				return 2;
			case 2:
				return 1;
			case 3:
				return 0;
		}
		return -1;
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();
		long ans = 0;
		// index[rgb][i]: rgbそれぞれについてインデックス番号i以上での個数
		int index[][] = new int[3][n + 1];
		for (int i = n - 1; i >= 0; --i) {
			int rgb = changeTable(s.charAt(i));
			for (int j = 0; j < 3; ++j) {
				index[j][i] = index[j][i + 1];
			}
			index[rgb][i]++;
		}
		for (int i = 0; i < n; ++i) {
			char ti = s.charAt(i);
			int rgbi = changeTable(ti);
			for (int j = i + 1; j < n; ++j) {
				char tj = s.charAt(j);
				int rgbj = changeTable(tj);
				if (ti == tj)
					continue;
				int k = restrgb(rgbi, rgbj);
				char rest = changeTable(k);
				int tmp = 2 * j - i;
				if (tmp < n) {
					if (s.charAt(tmp) == rest)
						ans--;
				}
				ans += (long) index[k][j + 1];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 37064
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 5010;
const int MOD = 998244353;

int n;
string s;
int ans;

void solve(int l, int r)
{
    vector<int> x;
    int c = 0;
    for (int i = l; i <= r; i++)
    {
        if (s[i] == '1') c++;
        else
        {
            x.push_back(c);
            c = 0;
        }
    }
    x.push_back(c);
    vector<int> dp0(x.size()), dpY(x.size()), dpN(x.size());
    dpN[0] = x[0];
    dpY[0] = 0;
    dp0[0] = 0;
    for (int i = 1; i < x.size(); i++)
    {
        dp0[i] = std::max({dpY[i - 1] + x[i], dpN[i - 1], dp0[i - 1]});
        dpY[i] = dp0[i - 1];
        if (x[i] > 1) dpY[i] = std::max({dpY[i], dpY[i - 1] + x[i] - 1, dpN[i - 1]});
        dpN[i] = dp0[i - 1] + x[i];
        if (x[i] > 1) dpN[i] = std::max({dpN[i], dpY[i - 1] + x[i] - 1, dpN[i - 1] + x[i] - 1});
    }
    //cout << dp0[x.size() - 1] << "\n";
    ans += dp0[x.size() - 1];
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s;
    n = s.size();
    s += "00";
    n += 2;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '1')
        {
            int j = i;
            while (s[j + 1] == '1' || s[j + 2] == '1') j++;
            solve(i, j);
            i = j;
        }
    }
    cout << ans;
}


Measured memory_bytes: 1172
S = list(input())
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "R" or S[i] == "U" or S[i] == "D":
            pass
        else:
            print("No")
            exit(0)
    else:
        if S[i] == "L" or S[i] == "U" or S[i] == "D":
            pass
        else:
            print("No")
            exit(0)
print("Yes")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef string str;
typedef vector<str> vst;
typedef vector<ll> vll;
// ll gcd(ll a, ll b){if (b==0){return a;}return gcd(b, a%b);}
// for (ll i=0;i<n;i++) {
// sort(.begin(),.end());
int main(){
  ll n,ans=0;
  cin>>n;
  vll x(n),y(n);
  for (ll i=0;i<n;i++) cin>>x[i]>>y[i];
  
  ll count,countM1=0;
  for (ll i=0;i<n;i++) {
    for (ll j=0;j<n;j++) {
      if (i==j) continue;
      ll p=x[i]-x[j],q=y[i]-y[j];
      count=0;
      for (ll h=0;h<n;h++) {
        for (ll w=0;w<n;w++) {
          if (h==w) continue;
          if (p==x[h]-x[w] && q==y[h]-y[w]) {
            count++;
          }
        }
      }
      if (countM1<count) {
        countM1=count;
      }
    }
  }
  cout<<n-countM1<<endl;
}

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

int main()
{
    int a[3][3];
    int n;
    bool a_dash[3][3];
    int b[10];
    for( int i = 0; i < 3; i++ )
    {
        for( int j = 0; j < 3; j++ )
        {
            cin >> a[i][j];
            a_dash[i][j] = false;
        }
    }
    cin >> n;
    for( int i = 0; i < n; i++ )
    {
        cin >> b[i];
    }

    for( int i = 0; i < 3; i++ )
    {
        for( int j = 0; j < 3; j++ )
        {
            for( int k = 0; k < n; k++ )
            {
                if( a[i][j] == b[k] )
                {
                    a_dash[i][j] = true;
                }
            }
        }
    }

    for( int i = 0; i < 3; i++ )
    {
        if( a_dash[i][0] && a_dash[i][1] && a_dash[i][2] )
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    for( int i = 0; i < 3; i++ )
    {
        if( a_dash[0][i] && a_dash[1][i] && a_dash[2][i] )
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    if( a_dash[0][0] && a_dash[1][1] && a_dash[2][2] )
    {
        cout << "Yes" << endl;
        return 0;
    }

    if( a_dash[0][2] && a_dash[1][1] && a_dash[2][0] )
    {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}



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

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

int main(){
    ll a,b;
    cin>>a>>b;
    ll c = gcd(a,b);
    ll ans =1;
    
    ll d=0;
    ll num = c;
    
    for (ll i = 2; i*i <= c; i++) {
        while (num%i == 0) {
            d=1;
            num /= i;
        }
        if(d==1) ans++;
        if(num==1) break;
        d=0;
    }
    if(num!=1) ans++;
    cout << ans << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a[55];
signed main(){
	int n,k;
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	int ans=0;
	for(int i=0;i<k;i++)ans+=a[i];
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

ll fc(vector<tuple<ll, ll, ll>> &vt, bool af, bool bf, bool cf, int m){
  vector<ll> sum(vt.size());
  rep(i, vt.size()){
    ll add = 0;
    auto [a, b, c] = vt.at(i);
    if(af == true) add += a;
    else add -= a;
    if(bf == true) add += b;
    else add -= b;
    if(cf == true) add += c;
    else add -= c;
    sum.at(i) = add;
  }
  sort(sum.rbegin(), sum.rend());
  ll res = 0;
  rep(i, m){
    res += sum.at(i);
  }
  return res;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<tuple<ll, ll, ll>> vt(n);
  rep(i, n){
    ll a, b, c;
    cin >> a >> b >> c;
    vt.at(i) = {a, b, c};
  }

  ll ans = 0;
  rep(bit, 1 << 3){
    bool af = ((bit & 1) == 0);
    bool bf = ((bit & 2) == 0);
    bool cf = ((bit & 4) == 0);
    ans = max(ans, fc(vt, af, bf, cf, m));
  }
  cout << ans << endl;
  return 0;
}

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

int cnt = 0, N;

bool chk(ll n)
{
    int a[10] = {};
    while (n) {
        int lst = n % 10;
        a[lst]++;
        n /= 10;
    }

    if (a[3] && a[5] && a[7]) return true;
    return false;
}

void dfs(ll n)
{
    if (n > N) return;
    if (chk(n)) cnt++;
    dfs(n*10 + 3);
    dfs(n*10 + 5);
    dfs(n*10 + 7);
}

int main()
{
    cin >> N;
    dfs(0);
    cout << cnt << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b[10000000],c=0,d=0;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>c;
    if(c%2==0) b[d]=c,d++;
  }
  c=0;
  int i=0,r=0;
  for(int i=0;i<d;i++){
    while(true){
      if(b[i]%2==1) break;
      b[i]/=2;
      c++;
    }
  }
  cout<<c<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>


int main()
{
    int h, w, H, W, ans;

    std::cin >> H >> W >> h >> w;

    ans = h * W;
    ans += w * H - h * w;
    ans = W * H - ans;

    std::cout << ans;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
	int main(){
      char a[10];
      scanf("%c%c%c",&a[0],&a[1],&a[2]);
    	if(a[0]==a[1]|a[1]==a[2]|a[2]==a[0])
      		printf("No\n");
    	else
      		printf("Yes\n");
}

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


int main() {
  int N;
  cin >> N;
  vector<long long> V(N);
  for(int i = 0; i < N; i++){
  	cin >> V.at(i);
  }
  long long C = 1000000007;
  long long Sum = 0;
  vector<long long> W(N-1);
  W.at(0) = V.at(0);
  for(int i = 1; i < N-1; i++){
    W.at(i) = W.at(i-1) + V.at(i);
  }
  for(int i = 0; i < N-1; i++){
  	Sum += ((W.at(i)%C) * V.at(i+1)) % C;
  }
  cout << Sum % C<< endl;
}

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

#define ll long long
// k! * sum C(H, i) * C(W, k - i) * (i + 1) * ((k - i) + 1)
const int N = 2e7 + 10;
const int mod = 1e9 + 7;
int fact[N], invfact[N];
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

inline int C(int n, int k){
	if(n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}

void pre(){
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

int main(){
	pre();
	int h, w, k;
	cin >> h >> w >> k;
	int sm = 0, ans = 0;
	for(int t = 1; t <= k; t++){
		int coeff = mul(C(h + w - t, k - t), mul(fact[t], fact[k - t]));
		ans = add(ans, mul(coeff, 
			add(C(h + w, t), add(mul(h + w, C(h + w - 1, t - 1)), mul(h, mul(w, C(h + w - 2, t - 2)))))));
	}
	printf("%d\n", ans);
}

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


int main(){
	const long long DIV=1000000007LL;
	long long n,k;	cin>>n>>k;
	vector<int> a(n,0);

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

	long long ans=0;

	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]) ans+=k;

			if(ans>=DIV)ans%=DIV;
		}
	}
	ans%=DIV;

	if(k>1){
		for(int i=0;i<n;i++){
			long long x=0;
			for(int j=0;j<n;j++){
				if(i==j)continue;
				else if(a[i]>a[j]) x++;
			}

			long long y= (k*(k-1)/2);
			if(y>=DIV)y%=DIV;

			y*=x;
			if(y>=DIV)y%=DIV;

			ans+=y;
			if(ans>=DIV) ans%=DIV;

		}
	}


	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
n,y = map(int,input().split())
huku = y//10000
higuchi = y // 5000
flag = False
for i in range(huku+1):
    for j in range(higuchi+1):
        nokori = y - (10000*i + 5000*j)
        if nokori < 0:
            break
        l = nokori // 1000
        #print(i,j,l)
        if i+j+l == n:
            if 10000*i + 5000*j + 1000*l==y:
                flag = True
                ans1 = i
                ans2 = j
                ans3 = l
                #print(i,j,l)

if flag ==True:
    print(ans1,ans2,ans3)
else:
    print("-1 -1 -1")

Measured memory_bytes: 42204
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
class problem
{
    static void Main()
    {
        var a = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        int n = a[0], k = a[1];
        string s = Console.ReadLine();
        string kq = s.Substring( 0, k >= 1 ? k - 1 : 0 ) + s[k - 1].ToString().ToLower() + s.Substring( k, n - k );
        Console.WriteLine( kq );

    }


}


Measured memory_bytes: 13268
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a>c){
        if(c>b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    if(a<c){
        if(c<b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
 int H, W, sum = 0, sum2 = 0;
 int i,j;
  
 cin >> H >> W;
 vector<string>s(H);
 for (i = 0;i < H;++i)cin >> s[i];
 
  
 for (i = 0;i < H-sum;++i) {
 int count = 0; 
 for (j = 0;j < W;++j)if (s[i][j] == '.')++count;
 if (count == W) {
   s.erase(s.begin()+i);
   --i;
   ++sum;
  }
 }
 
 for (j = 0;j < W-sum2;++j) {
 int count2 = 0;
 for (i = 0;i < H-sum;++i)if (s[i][j] == '.')++count2;
 if (count2 == H-sum) {
  for (i = 0;i < H-sum;++i)s[i].erase(s[i].begin() + j); 
   --j;
   sum2++;
  }
 }
 
  
 for (int i = 0;i < s.size();++i)cout << s[i] << endl;
 
 return 0;
    
}


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

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vec;
typedef std::vector<ld> vecld;
typedef std::vector< std::vector<ll> > vecvec;
typedef std::pair<ll, ll> pr;
typedef std::vector< pr > vpr;

#define tin ll t;cin>>t;while(t--)
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define sz(a) (ll)((a).size())
#define pb push_back
#define trvect(c,i) for(vector<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trset(c,i) for(set<ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define trmap(c,i) for(map<ll,ll>::iterator i = (c).begin(); i != (c).end(); i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define present(c,x) ((c).find(x) != (c).end())
#define ff first
#define ss second
#define mp make_pair
#define sq(a) (a)*(a)
#define cube(a) (a)*(a)*(a)
#define cnti(x) (__builtin_popcount(x)) //number of set bits in x
#define mod 1000000007
#define N 100005

ll qpow (ll n, ll m) {
	ll ret = 1;
	while (m) {
		if (m & 1) ret = ret * n % mod;
		n = n * n % mod;
		m >>= 1;
	}
	return ret;
}
ll inv (ll a) {
	return qpow(a, mod - 2);
}

// -------------------------------------------------------------------------------- //



int main(){
    
    ll r;
    cin>>r;
    double c = 2*3.14*r;
    cout<<fixed;
    cout<<setprecision(20)<<c<<"\n";
}


Measured memory_bytes: 3784
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      (int)1e9+7
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	
	pii now=make_pair(0,0);
	int nowt=0;
	REP(i,n){
		int t,x,y;
		cin>>t>>x>>y;
		
		int dx=abs(x-now.first);
		int dy=abs(y-now.second);
		if(t-nowt<dx+dy||(t-nowt-dx-dy)%2){
			cout<<"No"<<endl;
			return 0;
		}
		
		now=make_pair(x,y);
		nowt=t;
	}
	
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
S=[input() for i in range(n)]
C = collections.Counter(S[0])
for i in range(2,n):
  C1 = collections.Counter(S[i])
  C = C & C1
s=[]
for ci,i in C.items():
  s+=[ci]*i
s.sort()
print(*s,sep="")

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

int main()
{
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    vector<long long> factorial(h+w,1);
    vector<long long> factinv(h+w);
    int i;
    for(i = 1; i < h+w; i++)
    {
        factorial.at(i) = factorial.at(i-1)*i%1000000007;
    }
    for(i = 0; i < h+w; i++)
    {
        factinv.at(i) = 1;
        long long left = 1000000005;
        long long cut = 1;
        long long x = factorial.at(i);
        while(left > 0)
        {
            if(left%(cut*2) != 0 || left == cut)
            {
                factinv.at(i) = (factinv.at(i)*x)%1000000007;
                left -= cut;
            }
            cut *= 2;
            x = (x*x)%1000000007;
        }
    }
    long long ans = 0;
    long long add;
    for(i = b; i < w; i++)
    {
        add = factorial.at(h-a-1+i)*factinv.at(i)%1000000007*factinv.at(h-a-1)%1000000007;
        add = add*factorial.at(w+a-2-i)%1000000007*factinv.at(a-1)%1000000007*factinv.at(w-i-1)%1000000007;
        ans = (ans + add)%1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

ll A[100][100];
ll B[100][100];
ll C[100][100];

int main()
{
	int n, m, l;

	cin >> n >> m >> l;
	rep(i, n) rep(j, m) cin >> A[i][j];
	rep(i, m) rep(j, l) cin >> B[i][j];

	rep(i, n) rep(j, l) {
		ll sum = 0;

		rep(k, m) sum += A[i][k] * B[k][j];
		C[i][j] = sum;
	}

	rep(i, n) {
		cout << C[i][0];
		repc(j, 1, l - 1) cout << ' ' << C[i][j];
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 3308
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%d",&i)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>s
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<int,int> :: reverse_iterator mi
#define 	yes 	    cout<<"YES"<<endl
#define 	no 	        cout<<"NO"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          iNT_MAX
#define     lmx         LLONG_MAX
#define     mn          iNT_MiN
#define     lmn         LLONG_MiN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  // freopen ("(input).txt" , "r",  stdin) ;
  // string st,stt ;
  // int low=0,high=0;
  // int l,r;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>n  ; vect v ,a  ; sett ; set_it ; mapp m,mp; pairr p; map_it;
    loop(i,n)
    {
        cin>>x;
        m[x]++;
    }
    for(mi=m.rbegin();mi!=m.rend();mi++)
    {
        temp=mi->ss;
        if(temp>3)
        {
            sum=mi->ff;
            break;
        }
        else if(cnt==0&&temp>1)
        {
            d=mi->ff;
            cnt++;
        }
        else if(cnt==1&&temp>1)
        {
            f=mi->ff;
            break;
        }
    }
    cout<<max({sum*sum,f*d,d*sum})<<endl;


}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


Measured memory_bytes: 9644
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/19 7:53 下午
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ans = 0;
        int tmp = 0;
        for(int i = 0;i<n;i++){
            int x,y;
            x = scanner.nextInt();
            y = scanner.nextInt();
            if(x == y){
                tmp++;
                ans = Math.max(ans,tmp);
            }else{
                tmp = 0;
            }
        }
        if(ans >= 3){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35992
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	t=1;
	ll arr[4]={0,0,0,0};
	string dis[4]={"AC x ","WA x ","TLE x ","RE x "};
	while(t--){
		ll n;
		cin>>n;
		while(n--){
			string s;
			cin>>s;
			if(s=="AC")
				arr[0]++;
			else if(s=="WA")
				arr[1]++;
			else if(s=="TLE")
				arr[2]++;
			else if(s=="RE")
				arr[3]++;
		}
		for(int i=0;i<4;i++)
			cout<<dis[i]<<arr[i]<<"\n";
		
		
		
	}





}


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

using namespace std;

using ll = long long;
using vvll = vector<vector<ll>>;
using vll = vector<ll>;
using vpll = vector<pair<ll, ll>>;

vpll wv;
vvll dp;

ll knap(ll c, ll w)
{
   if (dp[c][w] != 0)
   {
      return dp[c][w];
   }
   else if (c == 0)
   {
      if (wv[c].first <= w)
         dp[c][w] = wv[c].second;
      else
         dp[c][w] = 0;
      return dp[c][w];
   }
   else
   {
      if (w >= wv[c].first)
         dp[c][w] = max(knap(c - 1, w - wv[c].first) + wv[c].second, knap(c - 1, w));
      else
         dp[c][w] = knap(c - 1, w);   
      return dp[c][w];
   }
}

int main()
{
   ll n, w;
   cin >> n >> w;
   wv = vpll(n, pair<ll, ll>());
   for (ll i = 0; i < n; i++)
   {
      cin >> wv[i].first >> wv[i].second;
   }
   dp = vvll(n, vll(w + 1, 0));
   ll r = knap(n - 1, w);
   cout << r;
   return 0;
}

Measured memory_bytes: 79488
program main
  implicit none
  integer i, N, tit
  character(100) S, T
  character(200) ans
  read(*, *) N
  read(*, *) S, T
  !read(*, *) (L(i), i = 1,N)
  tit = 1
  do i = 1,N
    ans(tit:tit) = S(i:i)
    tit = tit + 1
    ans(tit:tit) = T(i:i)
    tit = tit + 1
  end do
  write(*, *) ans(1:tit-1)
end program main


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int ara[100002];

int main()
{
    int n,k,q,a;
    scanf("%d %d %d",&n,&k,&q);
    while(q--)
    {
        scanf("%d",&a);
        if(a==1)
        {
            ara[a+1]-=1;
        }
        else
        {
            ara[1]-=1;
            ara[a]++;
            ara[a+1]-=1;
        }
    }
    for(int i=1; i<=n; i++)
    {
        ara[i]+=ara[i-1];
        if(ara[i]+k<=0)printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>


void output_each_case() {
  int x;
  for (int i = 1; i <= 10000; i ++) {
    std::cin >> x;
    if (x == 0) break;
    std::cout << "Case " << i << ": " << x << std::endl;
  }
}


int main() {

  output_each_case();

  return 0;
}



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

N, M = map(int, input().split())
H = list(map(int, input().split()))
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

c = 0
for n in range(N):
    ok = True
    for np in graph[n]:
        if H[np] >= H[n]:
            ok = False
            break
    if ok:
        c += 1
print(c)

Measured memory_bytes: 89256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, m, t=0;
	cin >> n;
	string a[n];
	for (int i=0;i<n;i++) {
		cin >> a[i];
	}
	cin >> m;
	string b[m];
	for (int i=0;i<m;i++){
		cin >> b[i];
		for(int j=0;j<n;j++){
			if(a[j]==b[i]){
				if(t%2==0){
					cout << "Opened by " << a[j] << endl;
					t++;
					break;
				}else if(t%2==1){
					cout << "Closed by " << a[j] << endl;
					t++;
					break;
				}
			}else if(j==n-1){
				cout << "Unknown " << b[i] << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 3240
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> Int -> [Int] -> Int
solve n x as = minimum (take n costRot)
  where
  costRot = unfoldr f (0, as)
    where f (k,ps) = Just (sum qs + k*x, (k+1, qs))
            where qs = zipWith min (ys++xs) ps
                  (xs, ys) = splitAt k as

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n,bs_x]:remLines1 = remLines0
      n = readBInt bs_n
      x = readBInt bs_x
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve n x as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 1532
from collections import Counter
N, M = map(int, input().split())

point = 0
answer_problems = set()
wrong_count = Counter()
for _ in range(M):
    p, s = input().split()
    
    if p in answer_problems:
        continue
    
    if s == 'AC':
        point += wrong_count[p]
        answer_problems.add(p)
    else:
        wrong_count[p] += 1

print(len(answer_problems), point)

Measured memory_bytes: 57816
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N)]

for i in range(N):
    for j in range(W + 1):
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
        if j >= wv[i][0]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i][0]] + wv[i][1])
print(dp[N - 1][W])

Measured memory_bytes: 151424
n = int(input())
arr = list(map(int, input().split()))
prod = 1
ans = 0
for i in arr:
    if (i == 0):
        ans+=1
    
if(ans == 1):
    prod = 0

else:
    for i in range(n):
        if(arr[i] == 0):
            prod = 0
            break
        else:
            prod *= arr[i]
            if(prod > 10**18):
                prod = -1
                break
print(prod)

Measured memory_bytes: 21700
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;

template<typename T> vector<T> tensor(int n, T v){ return vector<T>(n, v); }
template<typename... Ts> auto tensor(int n, Ts... ts) {
    return vector<decltype(tensor(ts...))>(n, tensor(ts...));
}

int main() {
    string S;
    cin >> S;
    int N = S.length();

    static auto dp = tensor(N+1,4,mint{0});
    dp[0][0] = 1;

    for(int i=0; i<N; i++)
    for(int s=0; s<4; s++) {
        if("ABC$"[s] == S[i] || S[i] == '?') {
            if(s<3) dp[i+1][s+1] += dp[i][s];
        }

        if(S[i] == '?') {
            dp[i+1][s] += dp[i][s] * mint(3);
        } else {
            dp[i+1][s] += dp[i][s];
        }
    }
    cout << dp[N][3] << endl;
}

Measured memory_bytes: 7424
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.BitSet;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DRecording solver = new DRecording();
        solver.solve(1, in, out);
        out.close();
    }

    static class DRecording {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int c = sc.nextInt();
            BitSet[] rep = new BitSet[c];
            for (int i = 0; i < c; i++) {
                rep[i] = new BitSet(200005);
            }
            for (int i = 0; i < n; i++) {
                int s = sc.nextInt();
                int t = sc.nextInt();
                int ch = sc.nextInt() - 1;
                rep[ch].set(s, t + 1);
            }
            int ans = 0;
            for (int i = 1; i < 100001; i++) {
                int act = 0;
                for (int j = 0; j < c; j++) {
                    if (rep[j].get(i)) {
                        act++;
                    }
                }
                ans = Math.max(ans, act);
            }
            out.println(ans);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 44948
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int n;
    cin >> n;
    int ans;
    if (n % 1000 == 0) ans = 0;
    else ans = 1000 - (n % 1000);
    cout << ans << endl;
}


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

using namespace std;
using pii = pair <int, int>;
using ppi = pair <pii, pii>;

#define f first
#define s second

int main() {
    int h, w; cin >> h >> w;
    int a[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }

    vector <ppi> ans;
    for (int i = 0; i < h; i++) {
        vector <int> odd;
        for (int j = 0; j < w; j++) {
            if (a[i][j] & 1) odd.push_back(j);
        }

        int sz = odd.size();
        for (int j = 0; j + 1 < sz; j += 2) {
            int c1 = odd[j], c2 = odd[j + 1];
            while (c1 != c2) {
                ans.push_back({pii(i, c1), pii(i, c1 + 1)});
                c1++;
            }
        }

        if (sz & 1) {
            int c1 = odd[sz - 1], c2 = w - 1;
            while (c1 != c2) {
                ans.push_back({pii(i, c1), pii(i, c1 + 1)});
                c1++;
            }

            if (i < h - 1) {
                ans.push_back({pii(i, w - 1), pii(i + 1, w - 1)});
                a[i + 1][w - 1]++;
            }
        }
    }

    cout << ans.size() << endl;
    for (auto step : ans) {
        cout << step.f.f + 1 << " " << step.f.s + 1 << " " << step.s.f + 1 << " " << 
        step.s.s + 1 << endl;
    }
}

Measured memory_bytes: 6344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // A11 A12 A13
        // A21 A22 A23
        // A31 A32 A33
        // N b1 b2 ... bn
        // ビンゴカード A が N 個の数列 bn で 1 ビンゴできるなら Yes そうでなければ No
        Scanner sc = new Scanner(System.in);
        int[] bingoNum = {sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt()};
        boolean[] hitArray = {false, false, false, false, false, false, false, false, false};
        int numNum = sc.nextInt();
        for(int i = 0; i < numNum; i++) {
            int tempNum = sc.nextInt();
            for (int j = 0; j < 9; j++) {
                if (bingoNum[j] == tempNum) {
                    hitArray[j] = true;
                }
            }
        }
        boolean resR1 = hitArray[0] & hitArray[1] & hitArray[2];
        boolean resR2 = hitArray[3] & hitArray[4] & hitArray[5];
        boolean resR3 = hitArray[6] & hitArray[7] & hitArray[8];
        boolean resR4 = hitArray[0] & hitArray[3] & hitArray[6];
        boolean resR5 = hitArray[1] & hitArray[4] & hitArray[7];
        boolean resR6 = hitArray[2] & hitArray[5] & hitArray[8];
        boolean resR7 = hitArray[0] & hitArray[4] & hitArray[8];
        boolean resR8 = hitArray[2] & hitArray[4] & hitArray[6];
        if(resR1 || resR2 || resR3 || resR4 || resR5 || resR6 || resR7 || resR8){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;
long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}

 unsigned long long gcd(const unsigned long long a, const unsigned long long b){
 	return (b==0) ? a : gcd(b,a%b);
 }
int main(){
	int N,M;
	cin >> N>>M;
	AdjList adj = getadj(N,M);
	rep(i,N)
		cout << adj[i].size() << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define in long long
using namespace std;
in sumofdigit(in x)
{
    in sum=0;
    in temp;
    while(x){
        temp=x%10;
        sum+=temp;
        x/= 10;
    }
    return sum;
}
int main()
{
    in a;
    scanf("%lld",&a);
    in sum=sumofdigit(a);
    //cout<<a<<endl;
    if(a%sum==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<random>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<stdlib.h>
#include<unordered_map>
#include<time.h>
#define rep(i,a,n) for (int (i)=(a);(i)<(n);(i)++)
#define int long long
using namespace std;
typedef long long ll;
typedef long double ld;
const int inf = 999999999999999999;
using namespace std;
int gcm(int a, int b) {
	if (a > b) swap(a, b);
	if (a == 0) return b;
	return gcm(b%a, a);
}
int n, a[100000], k, ma = 0, g;
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ma = max(a[i], ma);
		if (i == 0) g = a[i];
		else g=gcm(g, a[i]);
	}
	if (k%g == 0 && ma >= k) cout << "POSSIBLE\n";
	else cout << "IMPOSSIBLE\n";
	getchar(); getchar();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    string ans = "No";
    if (s[0]==s[2]) ans = "Yes";
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
int main(){
  int n, c=0;
  cin >> n;
  int a[n][2], vec[n];
  rep(i, n){
    rep(j,2){
      cin >> a[i][j];
      
    }
    if(a[i][0]==a[i][1]){
      vec[i]=1;
    }
  }
  rep(i,n){
    if(vec[i]==1){
      c++;
    }
    else c=0;
    if(c==3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

  

Measured memory_bytes: 3644