akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n; cin >> n;
	string s; cin >> s;
	deque<char> dq;
	rep(i,n) dq.push_back(s[i]);
	int nl,nr;
	nl = nr = 0;
	rep(i,n){
		if(s[i]=='(') nl++;
		if(s[i]==')') nr++;
		if(nr>nl){
			dq.push_front('(');
			nr--;
		}
	}
	nl = nr = 0;
	for(int i=n-1; i>=0; i--){
		if(s[i]=='(') nl++;
		if(s[i]==')') nr++;
		if(nr<nl){
			dq.push_back(')');
			nl--;
		}
	}
	
	for(auto a: dq) cout << a;
	cout << endl;
}




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;
int main(){
	int a, b;
	cin >> a>>b;
	if (a < 10 && b < 10)
		cout << a * b << endl;
	else
		cout << "-1" << endl;
	}		

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	vector<int> a(m);
	int cnt = 0;
	for(int i = 0; i < m; i++){
		cin>>a[i];
		if(a[i]&1)cnt++;
	}
	if(cnt > 2){
		cout<<"Impossible"<<'\n';
		exit(0);
	}
	if(m == 1){
		if(a[0] == 1){
			cout<<"1\n1\n1\n";
		}else{
			cout<<a[0]<<'\n';
			cout<<2<<'\n';
			cout<<a[0] - 1<<" "<<1<<'\n';
		}
	}else if(m == 2){
		sort(a.begin(), a.end());
		for(auto x : a){
			cout<<x<<" ";
		}
		cout<<'\n';
		if(a[0] == 1){
			cout<<1<<'\n';
			cout<<a[1] + 1<<'\n';
		}else{
			cout<<2<<'\n';
			cout<<a[0] - 1<<" "<<a[1] + 1<<'\n';
		}
	}else{
		vector<int> od, ev;
		for(auto x : a){
			if(x&1)od.push_back(x);
			else ev.push_back(x);
		}
		vector<int> ans;
		if(od.size())ans.push_back(od[0]);
		for(auto x : ev){
			ans.push_back(x);
		}
		if(od.size() > 1)ans.push_back(od[1]);
		for(auto x : ans){
			cout<<x<<" ";
		}
		cout<<'\n';
		ans[0] += 1;
		ans.back() -= 1;
		if(!ans.back())ans.pop_back();
		cout<<ans.size()<<'\n';
		for(auto x : ans){
			cout<<x<<" ";
		}
		cout<<'\n';
	}

	return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    const N = parseInt(arg.split("\n")[0]);
    const d = arg.split("\n").slice(1, N+1).map(n=>parseInt(n)).sort((a,b)=>b-a);
    
    const set = new Set(d);
    
    console.log(parseInt(set.size));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
n = int(input())
a,b = map(int,input().split())
p = [int(x) for x in input().split()]
low = 0
middle = 0
high = 0
for i in p:
    if(i<=a):
        low+=1
    elif(i<=b):
        middle+=1
    else:
        high+=1

l = [low,middle,high]
print(min(l))

Measured memory_bytes: 3064
#include<iostream>
#include<string>

using namespace std;


int main(){

	string search;
	int N;
	string ring;
	string a;
	int cnt = 0;
	bool f;

	cin >> search;
	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> ring;
		for (int i = 0; i < search.size()-1; i++){
			ring += ring[i];
		}
		f = false;
		for (int i = 0; i < ring.size()-search.size()+1; i++){
			a = "";
			for (int j = 0; j < search.size(); j++){
				/*cout << i<<","<<j<<","<<search << "," << ring << "," << a << endl;*/
				a += ring[i + j];
			}
			if (a == search) f = true;
		}
		if (f) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1208
<?php
while (true) {
    list($a, $operator, $b) = explode(' ', trim(fgets(STDIN)));
    switch ($operator) {
        case '+':
            $result = $a + $b;
            break;
        case '-':
            $result = $a - $b;
            break;
        case '*':
            $result = $a * $b;
            break;
        case '/':
            $result = floor($a / $b);
            break;
        case '?':
            exit;
    }
    echo $result, PHP_EOL;
}

Measured memory_bytes: 15272
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	if (0 < atoi(s.substr(0, 2).c_str()) && atoi(s.substr(0, 2).c_str()) <= 12) {
		if (0 < atoi(s.substr(2, 2).c_str()) && atoi(s.substr(2, 2).c_str()) <= 12) {
			cout << "AMBIGUOUS" << endl;
		}
		else {
			cout << "MMYY" << endl;
		}
	}
	else {
		if (0 < atoi(s.substr(2, 2).c_str()) && atoi(s.substr(2, 2).c_str()) <= 12) {
			cout << "YYMM" << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a,b;
    cin >> a >> b;
  	int o;
  	if(a > b)
    {
      o = a + a - 1;
    }else if(a == b)
    {
      o = a + b;
    }
  	else
    {
      o = b + b - 1;
    }
  	cout << o << endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define MOD 1000000007
#define ull unsigned long long
#define all(x) (x).begin(), (x).end()
#define read(a, n) for(ll i = 0;i<n;i++) cin>>a[i];
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define FileIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
const int INF = 1e9 + 5;

void solve() {
	string s, t;
	cin>>s>>t;
	
	int n = s.size();
	int m = t.size();
	
	int dp[m+1][n+1];
	memset(dp, 0, sizeof(dp));

	for(int i = 1;i<=m;i++) {
		//int f = 1;
		for(int j = 1;j<=n;j++) {
			if(t[i-1] == s[j-1]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				//f = 0;
			}
			else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	
	string ans = "";
	
	int i = m, j = n;
	
	while(i > 0 && j > 0){
		if(t[i-1] == s[j-1]) {
			ans = t[i-1] + ans;
			i--;
			j--;
		}
		else {
			if(dp[i-1][j] > dp[i][j-1]) {
				i--;
			}
			else j--;
		}
	}
	//debug1(dp[m][n]);
	cout<<ans<<"\n";
}

int main()
{
	fastio;
	
	int T = 1;
	//cin>>T;
	//int tc = 1; 
	while(T--) {
		//cout<<"Case #"<<tc<<": ";
		solve();
		//tc++;
	}	
	return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    ll A,B; cin >> A >> B;

    ll A_sum=0, B_sum=0;
    REPR(digit,45){
        ll beki_low = 1LL<<digit;
        ll beki_high = 1LL<<(digit+1);

        if(digit!=0){
            A_sum += (max(0LL, A % beki_high - beki_low)%2) << digit;
            B_sum += (max(0LL, (B+1) % beki_high - beki_low)%2) << digit;

        }else {
            A_sum += (A/2)%2;
            B_sum += ((B+1)/2)%2;
        }
    }
    cout << (A_sum^B_sum) << endl;
    return 0;
}

Measured memory_bytes: 3616
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        long[] arr = new long[n + 1];
        long[][] dp = new long[n + 1][n + 1];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextLong();
        }

        for (int l = n - 1; l >= 0; l--) {
            for (int r = l; r < n; r++) {
                if (l == r) {
                    dp[l][r] = 0;
                } else {
                    dp[l][r] = Long.MAX_VALUE;
                    long sum = 0;
                    for (int p = l; p <= r; p++) {
                        sum += arr[p];
                    }
                    for (int k = l; k <= r; k++) {
                        dp[l][r] = Math.min(dp[l][r], dp[l][k] + dp[k + 1][r] + sum);
                    }
                }
            }
        }
        //System.out.println(Arrays.deepToString(dp));
        System.out.println(dp[0][n - 1]);
    }
}

Measured memory_bytes: 25428
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int a,b,c;
        cin >> a >> b >> c;
        
        if(a==b && a!=c){
            cout << "Yes" << '\n';
        }
        else if(b==c && a!=c){
            cout << "Yes" << '\n';
        }
        else if(c==a && a!=b){
            cout << "Yes" << '\n';
        }
        else{
            cout << "No" << '\n';
        }
        
        

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//macro
#define in(i,l,r) (l<i&&i<r)
#define linr(i,l,r) (l<=i&&i<=r)
#define lin(i,l,r) (l<=i&&i<r)
#define inr(i,l,r) (l<i&&i<=r)
#define f(i,L,R) for (int i = L; i < R; i++)
#define fe(i,L,R) for (int i = L; i <= R; i++)
#define ff(i,L,R) for (int i = L; i > R; i--)
#define ffe(i,L,R) for (int i = L; i >= R; i--)
#define all(c) (c).begin(),(c).end()
#define by(x) [](const auto& a, const auto& b){return a.x < b.x;}
#define io ios_base::sync_with_stdio(false);cin.tie(0);
#define mod 1000000007
#define pi acos(-1)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define ins insert
//typedef
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vii vector<pair<int,int>>
#define vvii vector<vector<pair<int,int>>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define pq priority_queue
#define um unordered_map
#define us unordered_set
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
vii fx = {{0,1}, {0,-1}, {1,0}, {-1,0}};
//vii fx = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
//operator
template<typename T,typename U>
pair<T,U> operator+(const pair<T,U> &l,const pair<T,U> &r){   
    return {l.first+r.first,l.second+r.second};
}
template<typename T,typename U>
pair<T,U> operator-(const pair<T,U> &l,const pair<T,U> &r){
    return {l.first-r.first,l.second-r.second};
}
template<typename T,typename U>
void operator+=(pair<T,U> &l,const pair<T,U> &r){
    l={l.first+r.first,l.second+r.second};
}
template<typename T,typename U>
void operator-=(pair<T,U> &l,const pair<T,U> &r){
    l={l.first-r.first,l.second-r.second};
}
struct cmp{
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};
/*
- array bounds
- int overflow
- negative modulo
- special cases (n=1)
*/

int main(){
	io;
	int n; cin >> n;
	vvi dp(n,vi(3));
	for(int &i: dp[0]) cin >> i;
	for(int i=1;i<n;i++){
		for(int &in: dp[i]) cin >> in;
		dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
	}
	cout << *max_element(all(dp[n-1]));
}

Measured memory_bytes: 5760
def solve(S):
    ans = 0
    tans = 0
    for s in S:
        if s in "ACGT":
            tans += 1
            ans = max(ans, tans)
        else:
            tans = 0
    return ans

if __name__ == "__main__":
    S = input()
    print(solve(S))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,q;
    string s;
    cin>>n>>q>>s;
    vector<int> a(n);
    repi(i,1,n){
        a[i]=a[i-1];
        if(s[i-1]=='A'&&s[i]=='C') a[i]++;
    }
    int l,r;
    rep(i,q){
        cin>>l>>r;
        cout<<a[r-1]-a[l-1]<<endl;
    }
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
#define maxn 100005
#define MOD 1000000007
#define INF 1000000000000000000
#define lim 20

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<pii, ll>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


ll s(ll n) {
    return (n*(n+1))/2;
}
void solve(){
    ll n;
    cin >> n;
    cout << s(n) - 3*s(n/3) - 5*s(n/5) + 15*s(n/15);
}

int main()
{
    fast();
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
const int maxn=1e7+7;
int isp[maxn];
ll ex(int x){
     ll ans=1;
     for(int i=2;i*i<=x;i++){
         int cnt=0;
         while(x%i==0){
              x/=i;
              cnt++;
         }
         ans*=(cnt+1);
         if(x==1) break;
     }
     if(x!=1) ans*=2;
     return ans;
}
void init(ll n){
     for(int i=2;i<=n;i++){
        for(int j=1;j*i<=n;j++){
            isp[i*j]++;
        }
     }
}
int main (){

    ll n,ans=0;
    cin>>n;
    for(int i=1;i<=n;i++) isp[i]=1;
    init(n);
   // for(int i=2;i<=n;i++) isp[i]=ex(i);
    for(ll i=1;i<=n;i++){
        ans+=i*isp[i];
      //  printf ("%lld %d\n",i,isp[i]);
    }
    printf ("%lld\n",ans);
}


Measured memory_bytes: 42276
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>

using namespace std;

// https://atcoder.jp/contests/abc075/tasks/abc075_c

bool closedGraph(const unordered_map<int, vector<int>>& nodes, unordered_set<int>* visit, int startNode, int currentNode, int prevNode) {
  if (visit->find(currentNode) != visit->end()) {
    return currentNode == startNode;
  }
  visit->insert(currentNode);

  bool res = false;
  const auto iter = nodes.find(currentNode);
  for (const auto& node : iter->second) {
    if (node == prevNode) {
      continue;
    }
    res |= closedGraph(nodes, visit, startNode, node, currentNode);
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<int, vector<int>> nodes;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    nodes[a].emplace_back(b);
    nodes[b].emplace_back(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    unordered_set<int> visit;
    if (!closedGraph(nodes, &visit, i, i, -1)) ++ans;
  }
  if (ans == n) --ans;
  cout << ans << endl;
  return 0;
}

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

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(is_palindrome(s) && is_palindrome(s.substr(0,(n-1)/2)) && is_palindrome(s.substr((n+1)/2))){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

long long gcd(long long a, long long b){
	while(1){
		if(a<b) swap(a,b);
		if(!b) break;
		a %= b;
	}
	return a;
}

signed main (){	
	ll NN,XX;
	cin >> NN >> XX;
	ll x[NN];
	ll temp;
	rep(i,NN){
		cin >> x[i];
		x[i] = x[i] - XX;
		if(x[i]<0) x[i] = -1 * x[i];
		if(i==0) temp = x[i];
		else temp = gcd(x[i],temp);
	}
	cout << temp << endl;
	return 0;
}

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

int main() {
    int t, p;
    cin >> t >> p;
    while (!(t == 0 && p == 0)) {
            vector<int> v;
    v.push_back(t);
    v.push_back(p);
    sort(v.begin(), v.end());
    cout << v[0] << " " << v[1] << endl;

    cin >> t >> p;
    }

    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, x, t; cin >> n >> x >> t;
    print(((n + x - 1)/ x) * t)
    
    return 0;
}

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

using namespace std;

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

  int n, k;
  cin >> n >> k;

  int res = 1;
  for (int i = 0; i < n; ++i) {
    res = min(res + k, res*2);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int a[maxn], pos[maxn];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        pos[a[i]] = i;
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        if (a[i] != i){
            swap(a[i], a[pos[i]]);
            ++cnt;
        }
    }
    if (cnt > 1) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 256
//package com.company;

import java.io.*;
import java.util.*;


public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int[] deg = new int[4];
            for (int i = 0; i < 6; i++) {
                int a = sc.nextInt() - 1;
                deg[a]++;
            }
            for (int i = 0; i < 4; i++) {
                if (deg[i] == 3) {
                    pw.println("NO");
                    return;
                }
            }
            pw.println("YES");

        }

    }

    private static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("23.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("froggy.out"));


//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));
        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}

Measured memory_bytes: 22100
#include<stdio.h>

int main(){
	int a,b,c,x=0;
	scanf("%d %d %d",&a,&b,&c);
	while(a<=b){
		if(c%a==0)x+=1;
		a+=1;
	}
	printf("%d\n",x);
	return 0;
}



Measured memory_bytes: 2052
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    const string s="Sunny",c="Cloudy",r="Rainy";
    string inp;cin>>inp;
    cout<<(inp==s?c:inp==c?r:s)<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?')break;
        else if(op=='+')cout<<a+b<<endl;
        else if(op=='-')cout<<a-b<<endl;
        else if(op=='*')cout<<a*b<<endl;
        else if(op=='/')cout<<a/b<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
io = STDIN
N,_=io.gets.split.map(&:to_i)
a=io.gets.split.map(&:to_i)
#      1 2 3 4 5 6 7 8 9
$ar=[0,2,5,5,4,5,6,3,7,6]  #各数字の本数
#          - -     - -
$dp=Array.new(N+10)
$dp[0]=0
#                    1 1 1 1 1 1 1 1 1 1
#0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
#
(0..N).each do |i|
  a.each do |num|  #num  3 7 8 4
                   #m    5 3 7 4
    m=$ar[num] #m:本数
    # p ["num,m,i,$dp[i]*10+num,$dp[i+m]",num,m,i,$dp[i]*10+num,$dp[i+m]]
    next if  $dp[i]==nil
    if $dp[i+m]==nil || $dp[i]*10+num > $dp[i+m]
      $dp[i+m]=$dp[i]*10+num
    end
  end
end
p $dp[N]


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

int main(){
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int ans = h2*60+m2-h1*60-m1-k;
  if(ans<0)cout << 0;
  else cout << ans;
  
  return 0;
}


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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var dx = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int sum = dx[1];
            for(int i = 0; i < n; i++)
            {
                sum = sum + 1 + (dx[0] - 1) / (int.Parse(Console.ReadLine()));
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int t = 0; string s; cin >> s;
  rep(i, s.size()){
    t += s[i] - '0';
  }
  if(t % 9 == 0) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  long a,b;cin>>a>>b;
  if(a==1||b==1)cout<<1<<endl,exit(0);
  cout<<(a*b+1)/2<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007


int main(void)
{
	CIN;
	ll tc,l,k=0,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n;
	ll mx=1e16;
	for(ll i=1;i<=sqrt(n);i++)
	{
		if(n%i==0){
			z=(i*i+n-2*i)/i;
			mx=min(mx,z);
		}
	}
	cout<<mx;
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

ul N, M,  T;
std::string S;
ul gcd(ul m, ul n) {
  if ((0 == m) || (0 == n)) return 0;
  while (m != n) {
    if (m > n)
      m = m - n;
    else
      n = n - m;
  }
  return m;
}  // gcd

ul lcm(ul m, ul n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);  // lcm = m * n / gcd(m,n)
}  // lcm


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> S;
  ul str_size = S.size();
  ul set_count = 0; 
  ul tmp_count = 0;
  ul moves_sum=0;
  while(tmp_count !=str_size) {
    if(S[tmp_count]=='W'){
      moves_sum += tmp_count - set_count;
      ++set_count;
    }
    ++tmp_count;
  }
   
  cout <<  moves_sum << endl;
 
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
const int nax = 1005;
char sl[nax][nax];

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main() {
    int h, w;
    scanf("%d%d", &h, &w);
    for(int row = 0; row < h; ++row) {
        scanf("%s", sl[row]);
    }
    vector<vector<int>> dp(h, vector<int>(w));
    dp[0][0] = 1;
    for(int row = 0; row < h; ++row) {
        for(int col = 0; col < w; ++col) {
            for(int r2 : {row, row + 1}) {
                int c2 = col;
                if(r2 == row) {
                    c2 = col + 1;
                }
                if(r2 < h && c2 < w && sl[r2][c2] == '.') {
                    add_self(dp[r2][c2], dp[row][col]);
                }
            }
        }
    }
    printf("%d\n", dp[h-1][w-1]);
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1
using namespace std;
const int INF = 1e18;
const int MOD = 1000000007;

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int a;
    double b;
    cin >> a >> b;
    b = b * 100 + 0.00001;
    int c = b;

    cout << (a * c) / 100 << endl;
}

signed main()
{
    solve();
    return 0;
}

Measured memory_bytes: 3752
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a>b)
			{System.out.println("a > b");
			}
		else if(a<b)
			{System.out.println("a < b");
			}
		else
		{System.out.println("a == b");
		
		}
	}
}

Measured memory_bytes: 26356
#include <stdio.h>
#include <string.h>

int w, h;
int island[50][50];

void dfs(int a, int b)
{
	int dx, dy;
	
	island[a][b] = 0;
	
	for (dy = -1; dy < 2; dy++){
		for (dx = -1; dx < 2; dx++){
			if (dx == 0 && dy == 0){
				continue;
			}
			if (0 <= a + dy && a + dy < h && 0 <= b + dx && b + dx < w && island[a + dy][b + dx] == 1){
				dfs(a + dy, b + dx);
			}
		}
	}
	return;
}

int main(void)
{
	int i, j;
	int count;
	
	while (1){
		scanf("%d%d", &w, &h);
		
		if (w + h == 0){
			break;
		}
		
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				scanf("%d", &island[i][j]);
			}
		}
		
		count = 0;
		for (i = 0; i < h; i++){
			for (j = 0; j < w; j++){
				if (island[i][j]){
					dfs(i, j);
					count++;
				}
			}
		}
		
		printf("%d\n", count);
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>

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

    std::set<std::string> s;
    for (int i = 0; i < N; i++) {
        std::string S;
        std::cin >> S;

        s.insert(S);
    }

    std::cout << s.size() << "\n";
}

Measured memory_bytes: 19260
#include <stdio.h>

#define N_MAX 20
#define M_MAX 20

int main(){

    int N, M;
    int A[N_MAX][M_MAX] = {0};
    int B[M_MAX] = {0};
    int C;

    int i, j, k;
    int sum = 0;
    int cnt = 0;

    // 入力
    scanf("%d %d %d", &N, &M, &C);
  	//printf("%d %d %d\n", N, M, C);
    for(i=0 ; i<M ; i++){
        scanf("%d", &B[i]);
        //printf("%d ", B[i]);
    }
    //printf("\n");
    for(i=0 ; i<N ; i++){
        for(j=0 ; j<M ; j++){
            scanf("%d", &A[i][j]);
            //printf("%d ", A[i][j]);
        }
    //printf("\n");
    }

    for(i=0 ; i<N ; i++){
        sum = 0;
        for(j=0 ; j<M ; j++){
            sum += (A[i][j]*B[j]);
        }
        sum += C;
        if(sum > 0){
            cnt++;
        }
    }

    printf("%d", cnt);
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[3005][3005];

int main() {
  ll mod = 998244353;
  int N, S;
  cin>>N>>S;
  int A[N];
  for(int i=0;i<N;++i) cin>>A[i];
  DP[0][0] = 1;
  DP[0][A[0]] = 1;
  for(int i=1;i<N;++i) {
    DP[i-1][0]++;
    DP[i-1][0] %= mod;
    for(int j=0;j<=S;++j) {
      if(j-A[i]>=0) {
        DP[i][j] += DP[i-1][j-A[i]];
        DP[i][j] %= mod;
      }
      DP[i][j] += DP[i-1][j];
      DP[i][j] %= mod;
    }
  }
  /**
  for(int i=0;i<N;++i) {
    for(int j=0;j<=S;++j) {
      cout<<DP[i][j]<<" ";
    }
    cout<<endl;
  }
  **/
  ll ans = 0;
  for(int i=0;i<N;++i) {
    ans += DP[i][S];
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 73888
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;

#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

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

const int N = 100010;

int n, m;
vector<int> adj[N];
int par[N], vis[N];

void bfs(int s = 1) {
  vis[s] = 1;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v: adj[u]) {
      if (vis[v]) continue;
      par[v] = u;
      q.push(v);
      vis[v] = 1;
    }
  }
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bfs();
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  for (int i = 2; i <= n; ++i) printf("%d\n", par[i]);
}


Measured memory_bytes: 10960
#include <queue>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=5e3+2;

template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}

int head[N],dis[N],vis[N],QAQ[N],cnt,n,m,p;
struct Edge {int nxt,w,to;} G[N<<1]; 
inline void add(int u,int v,int w) {
	G[++cnt].nxt=head[u],G[cnt].to=v,G[cnt].w=w,head[u]=cnt;
}
inline void Spfa() {
	memset(dis,127,sizeof(dis));
    int inf=-(1e9+7);
	deque<int> q;q.push_back(1),dis[1]=0,vis[1]=true;
	while(!q.empty()) {
		int u=q.front();q.pop_front();++QAQ[u],vis[u]=false;
        if(QAQ[u]>=n) dis[u]=inf;
		for(int i=head[u];i;i=G[i].nxt) {
			int v=G[i].to;
			if(dis[u]+G[i].w<dis[v]&&QAQ[v]<n) {
				dis[v]=dis[u]+G[i].w;     
			    if(vis[v]==false)
				    v<q.front()?q.push_front(v):q.push_back(v),vis[v]=true; 
		    }
		}
	}
}

int main() {
    // freopen("G.in","r",stdin);
    // freopen("G.out","w",stdout);
    IN(n),IN(m),IN(p);
    for(int i=1,a,b,c;i<=m;++i)
        IN(a),IN(b),IN(c),add(a,b,-(c-p));
    Spfa();
    if(dis[n]<-5e8) puts("-1");
    else printf("%d\n",(dis[n]<0)?-dis[n]:0);
    return 0;
}

Measured memory_bytes: 384
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
cnt = 0
bus = 1
air = T[0]
for i in range(N):
  cnt += 1
  if cnt == C + 1 or T[i] - air > K:
    bus += 1
    cnt = 1
    air = T[i]
  
print(bus)

Measured memory_bytes: 7384
N = gets.to_i
A = gets.split.map(&:to_i)
sum = 0
prev = 0
A.each do |a|
  sum += (prev - a).abs
  prev = a
end
sum += A[-1].abs

N.times do |i|
  prev_pos = if i == 0
    0
  else
    A[i - 1]
  end
  next_pos = if i == N - 1
    0
  else
    A[i + 1]
  end 
  diff = (prev_pos - A[i]).abs + (A[i] - next_pos).abs - (prev_pos - next_pos).abs
  puts sum - diff
end

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

using ll = long long;

ll N, A, r, a[55];

int main(){
    scanf("%lld%lld", &N, &A);
    r = N;
    for(int i = 2; i <= 50; i++){
        fill(a, a + i, 0);
        for(int j = 0, c = 1; ; j = (j + 1) % i, c++){
            a[j]++;
            ll t = 1;
            for(int k = 0; k < i; k++) t = t * a[k];
            if(t >= N){
                r = min(r, A * (i - 1) + c);
                break;
            }
        }
    }
    printf("%lld\n", r);
}

Measured memory_bytes: 384
def main():
    from collections import Counter
    import sys
    input = sys.stdin.readline

    N = int(input())
    s = [input().rstrip() for _ in range(N)]

    ctr = Counter(s)

    ans = len(ctr.keys())

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 38776
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define endl "\n"
typedef long long ll;

const int BIG_NUM = 1e9;
//8+
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int d, t, s;
    cin >> d >> t >> s;
    double c1 = (double) d / s;
 
    if( c1 <= t) {
    	cout << "Yes";
    } else {
    	cout << "No";
    }
    return 0;
}

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

int main() {
  	int a,b,c;
  	cin >> a >> b;
  /* a=3 b=4 とする、aとbが奇数なら答えも奇数、aを2で割った余りが１ならば奇数*/
	c = a * b % 2;
  	if (c == 0) {
      cout << "Even" << endl;
    }
  	else {
      cout << "Odd" << endl;
    }
}

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

using namespace std;

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

	int cx=0,cy=0,ct=0;
	bool flag=1;
	while(n--){
		int x,y,t; cin >> t >> x >> y;
		int dist=abs(cx-x)+abs(cy-y);
		if(!(dist <= t-ct && ((dist&1)==((t-ct)&1)))){
			flag=0;
		}

		cx=x,cy=y,ct=t;
	}

	if(flag){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int x,y;
    int prize=0;
    scanf("%d %d",&x,&y);
    if(x==1){
        prize+=300000;
    }else if(x==2){
        prize+=200000;
    }else if(x==3){
        prize+=100000;
    }

    if(y==1){
        if(x==1){
            prize+=700000;
        }else{
            prize+=300000;
        }
    }else if(y==2){
        prize+=200000;
    }else if(y==3){
        prize+=100000;
    }
    printf("%d\n",prize);
    return 0;
}    

Measured memory_bytes: 128
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let (h, _) = {
        let line = read_vec::<i64>();
        (line[0], line[1])
    };
    let sum = read_vec::<i64>().iter().fold(0i64, |acc, &x| acc + x);
    let result = if (h - sum) > 0 { "No" } else { "Yes" };
    println!("{}", result);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace().
        map(|x| x.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 6396
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan2, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = [int(i) for i in input()]
    if sum(N)%9 == 0:
        print("Yes")
    else:
        print(("No"))



if  __name__=='__main__':
    main()


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

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

	int H, W;
	scanf("%d %d", &H, &W);

	int N;
	scanf("%d", &N);

	int counter = 0;
	vector<int> A(N);
	vector<vector<int>> C(H, vector<int>(W));

	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
		for (int j = 0; j < A[i]; j++) {
			C[counter / W][counter % W] = i + 1;
			// printf("C[%d][%d] = %d\n", counter / W, counter % W, i + 1);
			counter++;
		}
	}
	for (int i = 0; i < H; i += 2) {
		reverse(C[i].begin(), C[i].end());
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			printf("%d ", C[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct task {
    int a;
    int b;
    bool operator<(const task& right) const {
        return b < right.b; 
    }
};
int main() {
    int n;
    cin >> n;
    vector<task> v;
    for (int i=0; i<n; i++) {
        task t;
        cin >> t.a >> t.b;
        v.push_back(t);
    }
    sort(v.begin(), v.end());
    int sumA = 0;
    for (int i=0; i<n; i++) {
        sumA += v[i].a;
        if (sumA > v[i].b) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 5372
n,a,b = map(int,input().split())
n_all = 0
for i1 in range(n+1):
    s_i1 = str(i1)
    s_sum = 0
    for i2 in s_i1:
        s_sum += int(i2)
    if a <= s_sum <= b:
        n_all += i1
print(n_all)

Measured memory_bytes: 3060
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    ll N_{};
    vector<ll> A_{};
    vector<ll> B_{};
    vector<ll> C_{};
    vector<vector<ll>> dp_{};
    explicit C1(vector<ll> A,vector<ll> B, vector<ll> C) : N_(A.size()), A_(move(A)), B_(move(B)), C_(move(C)) {
        dp_.resize(N_, vector<ll>(3, 0));
    }
    ll resolve() {
        for(ll i=0; i < N_; ++i) {
            if (i==0) {
                dp_[i][0] = A_[0];
                dp_[i][1] = B_[0];
                dp_[i][2] = C_[0];
            } else {
                dp_[i][0] = max(dp_[i-1][1], dp_[i-1][2]) + A_[i];
                dp_[i][1] = max(dp_[i-1][2], dp_[i-1][0]) + B_[i];
                dp_[i][2] = max(dp_[i-1][0], dp_[i-1][1]) + C_[i];
            }
        }

        return max(
                dp_[N_-1][0],
                max(
                        dp_[N_-1][1],
                        dp_[N_-1][2]
                )
        );
    }
};

int main() {
    ll N;
    cin >> N ;
    vector<ll> A{};
    vector<ll> B{};
    vector<ll> C{};
    for (int i=0; i < N; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        A.emplace_back(a);
        B.emplace_back(b);
        C.emplace_back(c);
    }
    C1 c{move(A),move(B), move(C)};
    cout << c.resolve() << endl;
    return 0;
}


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

int main(void){
	string s;
	string t;
	int cnt=0;
	int i=0, j=0, k=0;
	int len;
	cin >> s;
	t=s;
	len = s.size();
	
	reverse(s.begin(), s.end());

	if(len==1){
		cout << 0 << endl;
		return 0;
	}

	while(k!=len || j!=len){
		if(t[k] == s[j]){
			k++;j++;
			continue;
		}
		else if((t[k] != s[j]) && (t[k] =='x')){
			k++; cnt++;
			continue;
		}
		else if((t[k] != s[j]) && (s[j] =='x')){
			j++; cnt++;
			continue;
		}
		else{
			cout <<  "-1" << endl;
			return 0;
		}
	}
	cout << cnt/2 << endl;
	

	return 0;
}

Measured memory_bytes: 512
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]

x = xyh[0][0]
y = xyh[0][1]
h = xyh[0][2]

xyh.sort(key = lambda k: k[2],reverse = True)

for cx in range(0,101):
  for cy in range(0,101):
    H = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
    for x,y,h in xyh:
      if h != max(H - abs(x - cx) - abs(y - cy),0):
        break
    else:
      print(cx,cy,H)
      break



Measured memory_bytes: 3064
#                         author:  kagemeka 
#                         created: 2019-11-09 21:20:16(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    n = int(sys.stdin.readline().rstrip())
    if n % 2 == 0:
        ans = n // 2 - 1
    else:
        ans = n // 2
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 1e5 + 10, mod = 1e9 + 7;
vector<int> g[mxn];
int n, s;
int dp[mxn][2];
bool c[mxn][2];

// dp[u][col] = number of ways to color the subtree rooted at 'u'
// 				if u is colored with color 'col'

int f(int u, int col, int par)
{
	if(c[u][col])
		return dp[u][col];
	// Base case : leaf node
	if(g[u].size() == 0)
		dp[u][col] = 1;

	else if(col)
	{
		dp[u][col] = 1;
		for(int v : g[u])
		{
			if(v != par)
				dp[u][col] = (dp[u][col] * f(v, 0, u)) % mod;
		}
	}
	
	else
	{
		dp[u][col] = 1;
		for(int v : g[u])
		{
			if(v != par)
			{
				int ans = (f(v, 0, u) + f(v, 1, u)) % mod;
				dp[u][col] = (dp[u][col] * ans) % mod;
			}
		}
	}
	c[u][col] = 1;
	return dp[u][col];
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	FOR(i, 1, n)
		g[i].clear();

	memset(c, 0, sizeof(c));

	FOR(i, 1, n - 1)
	{
		int u,v;	cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}

	int ans = (f(1, 0, -1) + f(1, 1, -1)) % mod;
	cout << ans;

	return 0;
}


Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

int func (int N, int X) {
  if (N != -1) {
    return (ll)(N / X) + 1;
  } else {
    return 0;
  }
}

void solve(long long a, long long b, long long x){
  cout << func(b, x) - func(a-1, x) << endl;
}

signed main(){
  long long a;
  scanf("%lld",&a);
  long long b;
  scanf("%lld",&b);
  long long x;
  scanf("%lld",&x);
  solve(a, b, x);
}


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

int main()
{
  double t,x;
  cin >> t >> x;
  double tmp = t/x;
  printf("%.16f",tmp);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      String s = sc.next();
      String t = sc.next();

      char ss;
      char tt;

      int ans=0;

      for(int i=0;i<3;i++){
        ss = s.charAt(i);
        tt = t.charAt(i);

        if(ss==tt){
          ans++;
        }

      }

      System.out.println(ans);

    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <string>

using namespace std;
int cnt = 0;
string s;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cin >> s;
    int l = (s.size()/2)-1, r = l+1;
    for(int i = 0; i < s.size()/2; i++){
        if(s[i] != s[s.size()-1-i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
'use strict'
// import bigInt from 'big-integer'

const main = (input) => {
    input = input.trim()
    const nums = input.split("")
    const plusNum = nums.length - 1
    let answer = 0

    for (let bit = 0; bit < (1 << plusNum); bit++) {
        let tmpStrs = [nums[0]]
        for (let i = 0; i < plusNum; i++) {
            const num = nums[i + 1]
            if (bit & (1 << i)) {
                tmpStrs.push(num)
            } else {
                tmpStrs[tmpStrs.length - 1] += num
            }
        }
        answer += tmpStrs.reduce((acc, cur) => acc + parseInt(cur, 10), 0)
    }

    console.log(answer)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7628