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

typedef long long LL;

#define __m int mid=(l+r)>>1;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1

#define rep(i,a,b) for(register int i = (a); i< (b); i++)
#define per(i,a,b) for(register int i = (a); i> (b); i--)
#define mem(a) memset(a,0,sizeof(a));
#define pb push_back
#define read2(a,b) read(a)&&read(b)

#ifdef LOCAL
    #define bug(x) cout<<#x<<" : "<<x<<endl;
#else
    #define bug(x) ;
#endif

template<class T>
inline bool read(T &num)  
{
       char in;bool IsN=false;
       while(in=getchar(),in!='-'&&(in<'0'||in>'9'))if(in==EOF)return false;
       in=='-'?(IsN=true,num=0):num=in-'0';
       while(in=getchar(),in>='0'&&in<='9')num=num*10+in-'0';
       return IsN?num=-num:num,true;
}

const int maxn = 3e5+7;
const int inf  = 2e9+7;
const int mod  = 1e9+7;

int fa[maxn],num[maxn],pos[maxn];
void init(){
    rep(i,0,maxn)
        fa[i]=i;
}
int find(int x){
    return fa[x]=(fa[x]==x)?x:find(fa[x]);
}
void merge(int x,int y){
    int fx=find(x),fy=find(y);
    if(fx==fy)
        return ;
    fa[fx]=fy;
}
int main(){
#ifdef LOCAL
    //freopen("sample.in","r",stdin);
#endif
    ios::sync_with_stdio(false);
    int n,m;
    read2(n,m);
    rep(i,1,n+1){
        int k;
        read(k);
        pos[k]=i;
        num[i]=k;
    }
    init();
    while(m--){
        int a,b;
        read2(a,b);
        merge(a,b);
    }
    rep(i,1,n+1){
        if(find(i)==find(pos[i])){
            swap(pos[i],pos[num[i]]);
            swap(num[i],num[pos[num[i]]]);
        }
    }
    int ans = 0;
    rep(i,1,n+1)if(num[i]==i)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL mod = 1e9+7;
string  s[1000];
LL dp[1000][1000] = {0};

void add(LL& a, LL b){
    a += b;
    if(a >= mod)    a -= mod;
}
int main(){
    LL H, W;
    cin >> H >> W;
    for(int i = 0;i < H;i++)    cin >> s[i];
    dp[0][0] = 1;
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(i+1 < H && s[i+1][j] == '.') add(dp[i+1][j], dp[i][j]);
            if(j+1 < W && s[i][j+1] == '.') add(dp[i][j+1], dp[i][j]);
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 9088
<?php
fscanf(STDIN, "%d", $n);
$x = array_fill(1, $n, -1);
while ($n-- > 1) {
	fscanf(STDIN, "%d %d %d", $u, $v, $w);
	$d[$u][$v] = $d[$v][$u] = $w % 2;
}
$x[1] = 0;
$t = [1];
while ($t) {
	$u = array_pop($t);
	foreach ($d[$u] as $v => $w) {
		if ($x[$v] < 0) {
			$x[$v] = $x[$u] ^ $w;
			$t[] = $v;
		}
	}
}
echo implode("\n", $x);

Measured memory_bytes: 51960
#include <stdio.h>

int gcd(int x, int y) {
    if(x % y) {
        gcd(y,x % y);
    } else {
        return y;
    }
}

int main(void) {
    int a, b;
    scanf("%d %d",&a, &b) ;
    printf("%d\n",gcd(a,b));
    return 0;
}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 1005;
const int   M   = 2e5 + 5;

typedef pair<int,int>   ii;

bool ans[M];
bool vis[N];

vector<ii>  fr[N];
vector<ii>  to[N];

void dfs(int u,int forbid)  {
    if(!vis[u]) {
        vis[u] = 1;

        for(ii  e : fr[u])  if (e.X != forbid)
            dfs(e.X,forbid);
    }
}

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

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

    for(int i = 0 ; i < m ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;
        
        fr[x].pb(y,i);
        to[y].pb(x,i);
    }
    for(int u = 1 ; u <= n ; ++u)   {
        fill(vis + 1,vis + 1 + n,0);    for(ii  e : fr[u])  ans[e.Y] |= vis[e.X],   dfs(e.X,u);     reverse(all(fr[u]));
        fill(vis + 1,vis + 1 + n,0);    for(ii  e : fr[u])  ans[e.Y] |= vis[e.X],   dfs(e.X,u);
    }
    for(int u = 1 ; u <= n ; ++u)   {
        fill(vis + 1,vis + 1 + n,0);

        dfs(u,0);

        for(ii  e : to[u])
            ans[e.Y] ^= vis[e.X];
    }
    for(int i = 0 ; i < m ; ++i)    {
        if (ans[i]) cout << "diff\n";
        else        cout << "same\n";
    }
}

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
int main() {
  int _t4;
  int _t2;
  int _t7;
  int _t5;
  int _t11;
  int _t10;
  int _t9;
  string _t8;
  string _t1;
  int A;
  int H;
  scanf("%d", &_t4);
  _t2 = H = _t4;
  scanf("%d", &_t7);
  _t5 = A = _t7;
  _t11 = H + A;
  _t10 = _t11 - 1;
  _t9 = _t10 / A;
  _t8 = to_string(_t9);
  printf("%s", _t8.c_str());
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
#define eps (1e-8)
#define pi acos(-1)
using namespace std;
typedef long long LL;
const LL mod = (1e9 + 7);

int n;
map<int, int> mps;

int main()
{
    scanf("%d", &n);
    for(int i = 1, a;i <= n;i++)
        scanf("%d", &a), mps[a]++;
    scanf("%d", &n);
    bool ff = 0;
    for(int i = 1, a;i <= n;i++)
    {
        scanf("%d", &a);
        mps[a]--;
        if(mps[a] < 0)
            ff = 1;
    }
    if(ff)
        puts("NO");
    else
        puts("YES");
    return 0;
}



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

int main() {
    int a, b, c, i;
     cin >> a >> b >> c;
     i = 0;
    
    for ( i = 0; a <= b; a++ ) {
        if ( c % a == 0) i++;
    }

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 3096
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Map<Integer, int[]> map = new TreeMap<Integer, int[]>();

        for (int i = 0; i < M; i++) {
            int[] arr = new int[2];
            arr[0] = sc.nextInt();  //P
            arr[1] = i;             //入力番号
            map.put(sc.nextInt(), arr);  // Y, [P, 入力番号]
        }

        String[] ans = new String[M];
        int[] seq = new int[N+1];
        for(int[] arr: map.values()){
            seq[arr[0]]++;
            ans[arr[1]] = String.format("%06d%06d", arr[0], seq[arr[0]]);
        }

        for (int i = 0; i < M; i++) {
            out.println(ans[i]);
        }
    }
}


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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007
#define println(x) cout << "[" << #x << ":" << x << "]\n"; 
#define print(x) cout << "[" << #x << ":" << x << "] "; 

void dfs(int node, vector<int> adj[], int dp[], bool vis[]){
	vis[node] = true;
	for(int i=0; i<(int)adj[node].size(); i++){
		if(!vis[adj[node][i]])
			dfs(adj[node][i], adj, dp, vis);
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]);
	}
}

int getLongestPath(vector<int> adj[], int n){
	int dp[n+1];
	memset(dp, 0, sizeof(dp));

	bool vis[n+1];
	memset(vis, false, sizeof(vis));

	for(int i=1; i<=n; i++){
		if(!vis[i])
			dfs(i, adj, dp, vis);
	}

	int ans = 0;

	for(int i=1; i<=n; i++)
		ans = max(ans, dp[i]);

	return ans;
}

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int n, m;
	cin >> n >> m;
	vector<int> adj[n+1];
	for(int i=0; i<m; i++){
		int x, y; cin >> x >> y;
		adj[x].pb(y); 
	}
	int ans = getLongestPath(adj, n);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 12908
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
int main()
{
	int n, m, x[100000], ans = 0, sx[100000];
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> x[i];
	}
	sort(x, x + m);

	for (int i = 0; i < m - 1; i++) {
		sx[i] = x[i + 1] - x[i];
	}
	sort(sx, sx + m - 1);

	for (int i = 0; i < m - n; i++) {
		ans = ans + sx[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  ll ans = 1;
  rep(i, 1, N + 1) {
    ans = (ans * i) % MOD;
  }
  print(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 123;
const ld EPS = 1e-12;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

int n, a[MAXN], d, cnt[MAXN];

void solve(){
	cin >> n;

	for(int i = 1; i <= n; ++i){
		cin >> a[i];
		d = max(a[i], d);
		cnt[a[i]]++;
	}

	for(int j = d, last = -1; j >= 0; --j){
		int i = max(d - j, j);
		if(!cnt[i]){
			cout << "Impossible";
			return;
		}
		cnt[i]--;
	}

	for(int i = 1; i <= (d + 1) / 2; ++i){
		if(cnt[i] > 0){
			cout << "Impossible";
			return;
		}
	}
	
	cout << "Possible";
}

int main(){

	faster();
 
	int T = 1;
	// cin >> T;
	
	while(T--){
		solve();
	}
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

#include <deque>

using namespace std;

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

	int N;
	cin >> N;

	bool reverse_check = false;
	deque<int> result;

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;

		if (reverse_check)
		{
			result.push_front(a);
		}
		else
		{
			result.push_back(a);
		}

		reverse_check = !reverse_check;
	}

	if (reverse_check)
	{
		reverse(result.begin(), result.end());
	}
	
	for (int i : result)
	{
		cout << i << " ";
	}

	return 0;
}

Measured memory_bytes: 3072
N, Y = map(int, input().split())
res = -1, -1, -1

for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if 10000 * x + y * 5000 + z * 1000 == Y:
            res = x, y, z

print(*res)



Measured memory_bytes: 9108
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[][] A = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = sc.nextInt();
			}
		}

		int[] b = new int[m];
		for (int i = 0; i < m; i++) {
			b[i] = sc.nextInt();
		}
		
		sc.close();
		
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			
			int ans = 0;
			for (int j = 0; j < m; j++) {
				ans += A[i][j] * b[j];
			}
			c[i] = ans;
			
		}

		for (int ans : c) {
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 40108
def main():
    h, w = map(int, input().split())
    grid = ["#"*(w+2)]+["#"+input()+"#" for _ in [0]*h]+["#"*(w+2)]
    grid = [[i == "." for i in j] for j in grid]
    ans_list = []
    for i in range(1, h+1):
        for j in range(1, w+1):
            if grid[i][j]:
                ans_list.append((i, j))
    m = 0
    for i, j in ans_list:
        q = [(i, j)]
        dist = [[-1]*(w+2) for _ in [0]*(h+2)]
        cnt = 0
        dist[i][j] = 0
        while q:
            qq = []
            cnt += 1
            while q:
                x, y = q.pop()
                for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                    if dist[x+dx][y+dy] == -1:
                        if grid[x+dx][y+dy]:
                            dist[x+dx][y+dy] = cnt
                            qq.append((x+dx, y+dy))
            q = qq
        m = max(m, max([max([l for l in k]) for k in dist]))
    print(m)


main()

Measured memory_bytes: 3188
/*
Problem : https://atcoder.jp/contests/abc127/tasks/abc127_d
Algorithm : priority_queue + greedy
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n,m;
int a[MAXN],b[MAXN],c[MAXN];
priority_queue<int,vector<int>,greater<int> > q;

struct Node{
	int b,c;
	friend bool operator < (const Node &x,const Node &y){
		return x.c > y.c;
	}
} p[MAXN];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= n;i++){
	    scanf("%d",&a[i]);
	    q.push(a[i]);
	}
	for(int i = 1;i <= m;i++)
	    scanf("%d%d",&p[i].b,&p[i].c);
	sort(p + 1,p + 1 + m);
	for(int i = 1;i <= m;i++){
		int b = p[i].b;
		int c = p[i].c;
		if(c <= q.top())
		    break;
		while(b--){
			if(q.top() < p[i].c){
				q.pop();
				q.push(p[i].c); 
			}else
			    break;
		}
	}
	ll ans = 0;
	while(!q.empty()){
		ans += (ll)q.top();
		q.pop();
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n)
	vector<pair<int,int>> a(n);
	fo(i,n)
	{
		cin>>a[i].F;
		a[i].S=i;
	}
	sort(all(a));
	fo(i,n)
		cout<<a[i].S+1<<' ';
	cout<<'\n';
	printclock;
}

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

vector<vector<pair<int, int>>> G;
vector<int> ans;

void dfs(int current, int parent, int color) {
  int cnt = 1;
  for (auto next : G.at(current)) {
    if (next.first == parent) continue;
    if (cnt == color) cnt++;
    ans.at(next.second) = cnt;
    dfs(next.first, current, cnt);
    cnt++;
  }
}

int main() {
  int N; cin >> N;
  G.resize(N);
  ans.resize(N-1);
  for (int i = 0; i < N-1; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    G.at(a).push_back(make_pair(b, i));
    G.at(b).push_back(make_pair(a, i));
  }
  dfs(0, -1, -1);
  int k = 0;
  for (int i = 0; i < N; i++) {
    int tmp = G.at(i).size();
    k = max(k, tmp);
  }
  cout << k << endl;
  for (int i = 0; i < N-1; i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 8320
n = int(input())
s = ''
for i in range(n):
    x = i+1
    if x%3==0:
        s += ' '+str(i+1)
        continue
    
    while x:
        if x%10==3:
            s += ' '+str(i+1)
            break
        x = x//10
print(s)



Measured memory_bytes: 5632
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> K(M);
    vector<vector<int>> S(M);
    vector<int> P(M);
    for (int m = 0; m < M; ++m) {
        cin >> K[m];
        for (int k = 0; k < K[m]; ++k) {
            int s;
            cin >> s;
            S[m].push_back(s);
        }
    }
    for (int m = 0; m < M; ++m) {
        cin >> P[m];
    }
    
    int Res = 0;
    for (int i = 0; i < (1<<N); ++i) {
        bool bAllOn = true;
        vector<int> viOn(N);
        for (int n = 0; n < N; ++n) {
            viOn[n] = (i >> n) & 1;
        }
        for (int m = 0; m < M; ++m) {
            int Sum = 0;
            for (int k = 0; k < K[m]; ++k) {
                Sum += viOn[S[m][k]-1];
            }
            if (Sum % 2 != P[m]) {
                bAllOn = false;
                break;
            }
        }
        if (bAllOn) {
            ++Res;
        }
    }
    cout << Res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

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

  int black = 0, white = 0;
  for(int i = 0; i < n; ++i){
    if(s[i] == '#') black++;
    else white++;
  }

  int ans = black;
  black = 0;
  for(int i = 0; i < n; ++i){
    ans = min(ans, white + black);
    if(s[i] == '#') black++;
    else white--;    
  }

  cout << ans << endl;

	return 0;
}



Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: usize, m: usize, q: usize,
        a: [[usize; 4]; q],
    }
    let mut v: Vec<usize> = Vec::new();
    let ret = dfs(n, m, &mut v, &a);
    println!("{}", ret);
}

fn score(v: &Vec<usize>, a: &Vec<Vec<usize>>) -> usize {
    let mut ret = 0;
    for abcd in a.iter() {
        if v[abcd[1] - 1] - v[abcd[0] - 1] == abcd[2] {
            ret += abcd[3];
        }
    }
    ret
}

fn dfs(n: usize, m: usize, v: &mut Vec<usize>, a: &Vec<Vec<usize>>) -> usize {
    if v.len() == n {
        return score(v, a);
    }

    let prev = if v.is_empty() { 1 } else { v[v.len() - 1] };
    let mut ma = 0;
    for i in prev..=m {
        v.push(i);
        let res = dfs(n, m, v, a);
        if res > ma {
            ma = res;
        }
        v.pop();
    }
    ma
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int H,W;
    cin>>H>>W;
    vector<vc> s(H,vc(W));
    rep(i,H) {
        rep(j,W) {
            cin>>s[i][j];
        }
    }
    bool ok=true,miniok=false;
    rep(i,H) {
        rep(j,W) {
            if(s[i][j]=='#') {
                miniok=false;
                if(i-1<0) continue;
                else if(s[i-1][j]=='#') miniok=true;
                if(i+1>=H) continue;
                else if(s[i+1][j]=='#') miniok=true;
                if(j-1<0) continue;
                else if(s[i][j-1]=='#') miniok=true;
                if(j+1>=W) continue;
                else if(s[i][j+1]=='#') miniok=true;
                if(miniok==0) {
                    ok=false;
                    break;
                }
            }
        }
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
string s;
int n, pos[100002];
int done[100002];
int nr = 2;
void dfs(int sz, int root)
{
    done[sz+1] = 1;
    if(sz == 0)
        return;
    while(!pos[sz])
    {
        cout << root << " " << nr << '\n';
        done[1] = 1;
        --sz;
        ++nr;
    }
    cout << root << " " << nr << '\n';
    ++nr;
    dfs(sz-1, nr-1);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(permutation.begin(), permutation.end(), rng);
    cin>>s;
    n = s.size();
    if(s[n-1] == '1')
    {
        cout << -1;
        return 0;
    }
    if(s[0] == '0')
    {
        cout << -1;
        return 0;
    }
    for(int i = 0; i < n; ++i)
        pos[i+1] = (s[i] == '1');
    for(int i = 1; i < n; ++i)
        if(pos[i] != pos[n-i])
        {
            cout << -1;
            return 0;
        }
    for(int i = n-1; i >= 1; --i)
    {
        if(pos[i] && !done[i])
        {
            cout << 1 << " " << nr << '\n';
            int root = nr;
            ++nr;
            dfs(i-1, root);
        }
    }
    while(nr <= n)
        cout << 1 << " " << nr << '\n', ++nr;
    return 0;
}


Measured memory_bytes: 8656
import os
import sys
from io import BytesIO, IOBase


def main():
    s=input()

    if s.upper()==s:
        print("A")
    else:
        print("a")
    



# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 62648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    UnionFind tree(N);

    for(int i = 0; i < Q; i++) {
        int p, x, y;
        cin >> p >> x >> y;
        if(p==0){
            tree.unite(x, y); // xの木とyの木を併合する
        }else{
            if(tree.same(x, y)){
                cout << 1 << endl;
            }else{
                cout << 0 << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)

class UnionFind{
public:
	vector<int> par;
	vector<long long> g1,g2;
	//0-indexed
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
		g1.resize(n,0);
		g2.resize(n,0);
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		g1[y] += g1[x];
		g2[y] += g2[x];
		par[x] = y;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int H,W;
	ll ans=0;
	cin >> H >> W;
	string s[H];
	FOR(i,0,H){
		cin >> s[i];
	}
	UnionFind uf;
	uf.init(H*W);
	// (x,y) -> W*x+y
	FOR(i,0,H){
		FOR(j,0,W){
			if(s[i][j]=='#'){
				uf.g1[W*i+j]=1;
			}else{
				uf.g2[W*i+j]=1;
			}
		}
	}
	FOR(i,0,H){
		FOR(j,0,W){
			int now = W*i+j;
			int to = W*(i-1)+j;
			if(i>0)if(s[i][j]!=s[i-1][j]){
				uf.unite(now,to);
				uf.root(to);
				uf.root(now);
			}
			to = W*(i+1)+j;
			if(i<H-1)if(s[i][j]!=s[i+1][j]){
				uf.unite(now,to);
				uf.root(to);
				uf.root(now);

			}
			to = W*i+j-1;
			if(j>0)if(s[i][j]!=s[i][j-1]){
				uf.unite(now,to);
				uf.root(to);
				uf.root(now);
			}
			to = W*i+j+1;
			if(j<W-1)if(s[i][j]!=s[i][j+1]){
				uf.unite(now,to);
				uf.root(to);
				uf.root(now);
			}
		}
	}
	set<int> se;
	FOR(i,0,H){
		FOR(j,0,W){
			int ro = uf.root(i*W+j);
			if(se.count( ro )==0){
				ans += uf.g1[ro]*uf.g2[ro];
				se.insert(ro);
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 9728
import java.util.Scanner;

public class Main {
	static int compute_maxprofit(int n,int[] R){
	      int max_profit = R[1] - R[0];
	      int min_profit = R[0];
	      for(int i = 1; i < n; i++) 
	      {
			if(max_profit < R[i] - min_profit)
				max_profit = R[i] - min_profit;
		if(min_profit > R[i]) {min_profit = R[i];}
		  }
	      
	      return max_profit;
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		int[] R = new int[num] ;
		for(int h = 0;h<num;h++) 
		{
			R[h] = in.nextInt();
		}
		System.out.println(compute_maxprofit(R.length,R));
in.close();
	}

}



Measured memory_bytes: 101056
#include <iostream>
using namespace std;
#define NIL -1

int F[50];

int fibonacci(int n) {
  if (n == 0 || n == 1) {
    return F[n] = 1;
  }
  if (F[n] != NIL) return F[n];
  return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

int main() {
  int n; cin >> n;
  for (int i = 0;  i < 50; ++i) F[i] = NIL;
  cout << fibonacci(n) << endl;
}



Measured memory_bytes: 3092
/*input
TAKOYAKI
*/
#include <bits/stdc++.h>
using namespace std;

#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define sort_f(x)  sort(x.begin(),x.end());
#define sort_r(x)  sort(x.rbegin(),x.rend());

lli MOD  = 1000000007;
lli inf = 1e15;

void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

#define N 200003

long  divisors(long x) {
    long limit = x;
    long numberOfDivisors = 0;

    if (x == 1) return 1;

    for (long i = 1; i < limit; ++i) {
        if (x % i == 0) {
            limit = x / i;
            if (limit != i) {
                numberOfDivisors++;
            }
            numberOfDivisors++;
        }
        if(numberOfDivisors>=4)
        {
            break;
        }
    }

    return numberOfDivisors;
}
 bool isPrime(long n)
{
   
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (long i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
#define max_a 100001
bool visit[max_a]={false};
vector<long> a[max_a];
long sum=0;
long cost[max_a];
void dfs(long node)
{
    visit[node]=true;
    
    for(int i=0;i<(int)a[node].size();i++)
    {
        if(visit[a[node][i]]==false)
        {
            sum+=cost[a[node][i]];
            dfs(a[node][i]);
            
        }
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s="YAKI";
    string s1;
    cin>>s1;
    string s2=s1.substr(0,4);
    if(s2==s)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
    cout<<"No"<<endl;
    }

   
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>

using namespace std;

int a[500][500];
int main()
{
    int H, W;
    string str;
    while(cin >> H >> W && H && W)
    {
        int M=0;
        int m=0;
        for(int i=0;i<H;i++)
        {
            int count=1;
            cin >> str;
            for(int j=str.size()-1;j>=0;j--)
            {
                if(str[j] == '*') count = 0;
                a[i][j] = count;
                ++count;
            }
        }
        /*
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
            {
                cout << a[i][j];
            }
            cout << endl;
        }
        */
        for(int i=0;i<H;i++)
        {
            for(int j=0;j<W;j++)
            {
                if(a[i][j] != 0){
                    m = a[i][j];
                    for(int k=1;i+k-1<H && a[i+k-1][j] != 0;k++)
                    {
                        //printf("(%d,%d) = %d, (M,m) = (%d,%d)\n",i+k-1,j,a[i+k][j],M,m);
                        m = min(m, a[i+k-1][j]);
                        M = max(M, k*m);
                    }
                }
            }
        }
        cout << M << endl;
    }
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   string s; cin >> s;
   set<char> st{'A', 'T', 'C', 'G'};
   int ans = 0, sum = 0;
   for (int i = 0; i < s.size(); i++) {
      if (st.find(s[i]) != st.end()) {
         ++sum;
      } else {
         chmax(ans, sum);
         sum = 0;
      }
   }
   chmax(ans, sum);
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=parseMap(split(readline()))
    ans=0
    for i in a
        num=i
        while num%2==0
            num=div(num,2)
            ans+=1
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 123160
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int cnt[100005], ac[100005];

signed main()
{
	IO_OP;

	int n, m;
	cin >> n>> m;
	for(int i=0;i<m;i++) {
		int t;
		string s;
		cin >> t >> s;
		if(ac[t]) continue;
		if(s == "AC") {
			ac[t] = 1;
		}
		else {
			cnt[t]++;
		}
	}
	int a = 0, b = 0;
	for(int i=1;i<=n;i++) {
		a += ac[i];
		if(ac[i]) b += cnt[i];
	}
	cout << a << " " << b << endl;
	
}





Measured memory_bytes: 1024
import Data.List
import qualified Data.Vector as V

main = getLine>>=print.solve

solve l = go 0 l
  where
  len = length l
  go _ [] = 1
  go i ('0':l) = go (i+1) l
  go i ('1':l) = 2 *% go (i+1) l +% pow3 V.! (len-i-1)

mo = 1000000007
infixl 6 *%
infixl 5 +%
a +% b = (a + b) `mod` mo
a *% b = (a * b) `mod` mo
pow3 = V.fromListN 100000 $ 1 : iterate (*%3) 3

Measured memory_bytes: 12668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 40;
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
const ll MOD = 1e9 + 7;

int main(){
    string s; cin >>s;
    int N = s.size();
    int x, y;
    FOR(i,0,N){
        if(s[i]=='A'){
            x=i;
            break;
        }
    }
    FOR(i,0,N){
        if(s[N-i-1]=='Z'){
            y=N-i-1;
            break;
        }
    }
    cout << y-x+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int k,q;
int d[5010],e[5010];
signed main(){
    cin>>k>>q;
    rep(i,k)cin>>d[i];
    while(q--){
        int n,x,m;
        cin>>n>>x>>m;
        rep(i,k)e[i]=d[i]%m;
        int ans=n-1;
        int foo=x;
        rep(i,k){
            int cnt=(n-1)/k+(i<(n-1)%k);
            if(e[i]==0){
                ans-=cnt;
            }
            foo+=e[i]*cnt;
        }
        ans-=foo/m-x/m;
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    while(true){
        int x, y;
        cin >> x >> y;
        
        if (x == 0 && y == 0) break;
        else if (x > y){
            cout << y << " " <<  x << endl; 
        } else {
            cout << x << " " <<  y << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <cstring>
using namespace std;
int main(){
    int n,m=0,k=0,l=0,p=0,j=0,x=0,sum=0;
    cin >>n;
    if (n/500>0){
        m=n/500*1000;
        n=n%500;
    }
    if(n/100>0){
        k=n/100*100;
        n=n%100;
    }
    if(n/50>0){
        l=n/50*50;
        n=n%50;
    }
    if(n/10>0){
        p=n/10*10;
        n=n%10;
    }
    if(n/5>0){
        j=n/5*5;
        n=n%5;
    }
    if(x/1>0){
        x=n/1;
        n=n%1;
    }
    sum=m+k+l+p+j+x;
    cout<<sum;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll a,b,c; cin >> a >> b >> c;
    ll res = b;
    res+= min(c,a+b+1);
    out(res);
}


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

using namespace std;

string S, T;

int main(void) {

	cin >> S >> T;
	int N = S.size();
	if (S == T.substr(0, N)) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 3624
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 1e9;

int main()
{
    _SAD()
    ll x,y,ans=1e10;
    cin>>x>>y;
    if(y>=x)
    {
        ans=min(ans,y-x);
    }
    if(-y>=x)
    {
        ans=min(ans,-y-x+1);
    }
    if(y>=-x)
    {
        ans=min(ans,y+x+1);
    }
    if(-y>=-x)
    {
        ans=min(ans,-y+x+2);
    }
    cout<<ans<<nl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,x = 4.times.map{gets.to_i}
count = 0
(0..a).each do |h|
  (0..b).each do |i|
    (0..c).each do |j|
      count += 1 if h * 500 + i * 100 + j * 50 == x
    end
  end
end
puts count

Measured memory_bytes: 1788
#include<stdio.h>

int isprime(int);
main()
{
  int i, n, p, count=0;
  scanf("%d",&p);
  
  for(i=0; i<p; i++){
    scanf("%d",&n);
    if(isPrime(n) == 1) count++;
  }
  printf("%d\n",count);
  return 0;
}
int isPrime(int n)
{
  int i;
  
  if(n < 2)return 0;
  else if(n == 2) return 1;
  if(n % 2 == 0) return 0;
  for(i=3; i<=n/i; i+=2){
    if(n % i == 0)
      return 0;
  }
    return 1;
}

Measured memory_bytes: 596
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))
ans = 0
for i in range(0,n,2):
    if not even(lst1[i]):
        ans += 1
print(ans)

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

using namespace std;

int a, b, c, Max;

int main() {
    cin >> a >> b >> c;
    Max = max(a, max(b, c));
    if(a + b + c - Max == Max) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
/* kadai2_2
   reo012 */

#include <stdio.h>

int main(void){
  int n, a;
  // 二つの整数(一列のマス数、白マス数)n,aを受け取り
  scanf("%d", &n);
  scanf("%d", &a);
  // 黒く塗るマス数を計算し、出力
  printf("%d\n", n*n-a);
  
  return 0;
}


Measured memory_bytes: 128
c1,c2,c3=map(int,input().split())
c4,c5,c6=map(int,input().split())
c7,c8,c9=map(int,input().split())
k=c2-c1
failflag=0
if (c5-c4)!=k or (c8-c7)!=k:
  failflag=1
k=c3-c2
if (c6-c5)!=k or (c9-c8)!=k:
  failflag=1
k=c4-c1
if (c5-c2)!=k or (c6-c3)!=k:
  failflag=1
k=c7-c4
if (c8-c5)!=k or (c9-c6)!=k:
  failflag=1
if failflag==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 38496
/**
 * Author: Deb Natkh Maxim (debnatkh@gmail.com)
 */

#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define getbit(x, i) (((x) >> (i)) & 1)
using namespace std;
typedef pair<int, int> pii; 

const int MAXN = 1e5;
int arr[MAXN];

signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	int ans = 1;
	int cur = 1;
	for (int i = n - 2; i >= 0; i--) {
		if (arr[i] >= arr[i + 1]) {
			cur++;
		} else {
			ans = max(ans, cur);
			cur = 1;
		}
	}
	ans = max(ans, cur);
	cout << --ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int a[22][22];
int b[22];

int main(){
   int n,m,c;
   cin>>n>>m>>c;
   for(int i=0;i<m;i++)cin>>b[i];
   for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
         cin>>a[i][j];
      }
   }
   int ans=0;
   int y;
   for(int i=0;i<n;i++){
      y=c;
      for(int j=0;j<m;j++){
         y+=a[i][j]*b[j];
      }
      if(y>0)ans++;

   }
   cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	while(1){
	int H, W;
	scanf("%d %d", &H, &W);
	if(H == 0 && W == 0) break;
	for (int i = 0; i < H; i++) {
		for (int i = 0; i < W; i++) {
			printf("#");
		}
		printf("\n");
	}
	printf("\n");
}
    return 0;
}


Measured memory_bytes: 2080
#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 floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[200000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll ans=min(a,k)-min(c,max(k-a-b,0ll));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int h1 = scanner.nextInt();
        int w1 = scanner.nextInt();
        int remain = (h - h1) * (w - w1);
        System.out.println(remain);
    }
}


Measured memory_bytes: 23124
import java.io.InputStream;
import java.io.OutputStream;
import java.util.*;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
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.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main{
	//WRWWRWRR     wwwrrrrwwwwrrr
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt();
		while(n%2==0){
			out.println(-1);
			return;
		}
		int v  = 0;
		Set<Integer> set = new HashSet<>();
		int cnt = 0;
		while(!set.contains((v*10+7)%n)){
			cnt++;
			set.add((v*10+7)%n);
			v = (v*10+7)%n;
			if(v==0) {
				out.println(cnt);
				return;
			}
		}
		out.println(-1);


	}
//	public static void main(String[] args){
//		Scanner scanner = new Scanner(new InputStreamReader(System.in));
//		int n  = Integer.parseInt(scanner.nextLine());
//		String s = scanner.nextLine();
//		LinkedList<Integer> q = new LinkedList<>();
//		for(int i=0;i<n;i++){
//			if(s.charAt(i)=='W'){
//				q.add(i);
//			}
//		}
//		int res = 0;
//		for(int i=n-1;i>=0;i--){
//			if(q.size()==0) break;
//			if(s.charAt(i)=='R'){
//				int v = q.poll();
//				if(v>i) break;
//				res++;
//			}
//		}
//		System.out.println(res);
//
//	}
	public static void main(String[] args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main solver = new Main();
//        int num = in.nextInt();
//        while(num-->0){
//            solver.solve(1, in, out);
//        }
        solver.solve(1, in, out);
        out.close();
    }
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

	}
}


Measured memory_bytes: 100068