akhauriyash/Code-Regression huggingface dataset:
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
vector<ll> tree[100010];
ll dp[100010] = {};
ll val[100010] = {};
ll res[100010] = {};
void dfs(ll cur, ll par){
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs(e, cur);
        dp[cur] += dp[e];
    }
    dp[cur] += val[cur];

    return;
}

void dfs2(ll cur, ll par){
    if(cur == 0){
        res[cur] = 0;
    }else{
        res[cur] = res[par] - dp[cur];
    }
    for(auto &e: tree[cur]){
        if(e == par) continue;
        dfs2(e, cur);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll u[100010], v[100010];
    rep(i,0,N-1){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
        tree[u[i]].push_back(v[i]);
        tree[v[i]].push_back(u[i]);
    }
    ll a[100010], b[100010];
    rep(i,0,N) cin >> a[i];
    rep(i,0,N) cin >> b[i];
    rep(i,0,N) val[i] = b[i] - a[i];
    // printa(val, N);
    dfs(0, -1);
    dfs2(0, -1);
    // printa(res, N);
    // printa(dp, N);
    ll min_val = INF;
    rep(i,0,N){
        min_val = min(min_val, res[i]);
    }
    ll ans = 0;
    rep(i,0,N){
        ans += res[i] - min_val;
    }

    print(ans);
    

}


Measured memory_bytes: 18416
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

void solve(int N){
  if(popcount(N) == 1){
    cout << "No" << endl;
    return;
  }

  vector<pair<int,int>> ans;

  FOR(i,1,(N+1)/2){
    int j = i*2;
    int k = j+1;

    ans.push_back({j+N,k});
    ans.push_back({k,1});
    ans.push_back({1,j});
    ans.push_back({j,k+N});
  }

  ans.push_back({1+N,2+N});

  if(N%2==0){
    FORE(i,2,N-1){
      int j = (N+1)^i;
      if(i!=j and j<=N-1){
        ans.push_back({N,i});
        ans.push_back({2*N,j});
        break;
      }
    }
  }
  
  cout << "Yes" << endl;
  for(auto &p : ans){
    cout << p.fst << " " << p.snd << endl;
  }
  return;
}

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

  int N;
  while(cin >> N){
    solve(N);
  }
  
  return 0;
}


Measured memory_bytes: 3952
#!python
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    T = [0]
    s = 0
    for i in range(N):
        s += A[i]
        T.append(s)

    T.sort()

    _a = None
    n = 0
    c = 0
    for a in T:
        if _a == a:
            n += 1
            c += n
        else:
            n = 0
        _a = a
    print(c)
    return 0


if __name__ == '__main__':
    main()


Measured memory_bytes: 25724
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int a[110];
int n, ans = 0x3f3f3f3f;

int main() {
    read(n);
    for (int i = 1; i <= n; ++i)    read(a[i]);
    for (int c = -100; c <= 100; ++c) {
        int s = 0;
        for (int i = 1; i <= n; ++i) {
            s += (a[i] - c) * (a[i] - c);
        }
        ans = std::min(ans, s);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).trim().split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();
  var primeCounts = new Int32Array(50001);

  for(var i = 1; i < 5133; i++){
    var pni = primeNumbers[i];
    for(var k = 1; k <= i; k++){
      var sum = pni + primeNumbers[k];
      if(sum > 50000)
        break;
        primeCounts[sum]++;
    }
  }
  var i = 0;
  while(c = +input[i++]){
    console.log(primeCounts[c]);
  }
  
}
   
function calcPrimeNumbers(){
  var max = 50021;
  var primeNumbers = new Int8Array(max + 1);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int32Array(5134 + 1);
  var c = 0;
  for(var i = 1; i <= max; i++){
    if(!primeNumbers[i]){
      primeNums[++c] = i;
    }
  }
     
  return primeNums;
}

Measured memory_bytes: 13652
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0] == 'A'){
        int length = s.length();
        int c_count = 0;
        int c_index = 0;;
        bool c_find = false;
        int count = 0;
        for(int i = 1; i < length; i++){
            if(s[i] == 'C'){
                c_find = true;
                c_count++;
                c_index = i;
            }
            if(s[i] >= 'a' && s[i] <= 'z'){
                count++;
            }
        }
        if(c_find == true && c_index >= 2 && c_index < length-1 && c_count == 1 && count == length-2) cout << "AC" << endl;
        else cout << "WA" << endl;
    }else{
        cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin >> s;
  if(s[0] == '9'){
    cout << 1;
  }else{
    cout << 9;
  }
  if(s[1] == '9'){
    cout << 1;
  }else{
    cout << 9;
  }
  if(s[2] == '9'){
    cout << 1;
  }else{
    cout << 9;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fir first
#define sec second
#define pb push_back
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
	int S[26] = {0};
	string s;
	cin >> s;
	rep(i,4){
		S[s[i] - 'A']++;
	}
	int ans = 0;
	rep(i,26){
		if(S[i] == 2)ans++;
	}
	if(ans == 2)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x,t;
  while(cin >> x >> t){
    TSTART();
    
    cout << max(0,x-t) << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
	puta((h-a)*(w-b));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;


map<char, int> mymap;
int main(int argc, char const* argv[])
{
    //0テ」ツ?ェテ」ツつ嘉・ツキツヲテ」ツ??テ」ツ?ェテ」ツつ嘉・ツ渉ウ
    mymap['a'] = 0;
    mymap['b'] = 0;
    mymap['c'] = 0;
    mymap['d'] = 0;
    mymap['e'] = 0;
    mymap['f'] = 0;
    mymap['g'] = 0;
    mymap['h'] = 1;
    mymap['i'] = 1;
    mymap['j'] = 1;
    mymap['k'] = 1;
    mymap['l'] = 1;
    mymap['m'] = 1;
    mymap['n'] = 1;
    mymap['o'] = 1;
    mymap['p'] = 1;
    mymap['q'] = 0;
    mymap['r'] = 0;
    mymap['s'] = 0;
    mymap['t'] = 0;
    mymap['u'] = 1;
    mymap['v'] = 0;
    mymap['w'] = 0;
    mymap['x'] = 0;
    mymap['y'] = 1;
    mymap['z'] = 0;
    string s;
    while ( cin >> s && s != "#" ) 
    {
        int count = 0;
        char pre, next;        
        next = s[0];
        for (int i = 0; i < s.length() - 1; i++) 
        {
            pre = next;
            next = s[i+1];
            if ( (mymap[pre] + mymap[next]) % 2 == 1)
            {
                count++;
            }
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 1188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	public static void main(String[] args){
		try(final Scanner sc = new Scanner(System.in)){
			int a_count = 0, b_count = 0, c_count = 0;
			for(final char c : sc.next().toCharArray()){
				switch (c) {
				case 'a': a_count++; break;
				case 'b': b_count++; break;
				case 'c': c_count++; break;
				}
			}
			
			final int sum = a_count + b_count + c_count;
			final int max_count = Math.max(a_count, Math.max(b_count, c_count));
			final int min_count = Math.min(a_count, Math.min(b_count, c_count));
			final int mid_count = sum - max_count - min_count;
			
			if(mid_count == 0){
				if(max_count > 1){
					System.out.println("NO");
				}else{
					System.out.println("YES");
				}
			}else if(mid_count == min_count){
				final int pairs = min_count;
				final int min_place = pairs - 1;
				final int max_place = pairs + 1;
				
				if(max_count < min_place){
					System.out.println("NO");
				}else if(max_count > max_place){
					System.out.println("NO");
				}else{
					System.out.println("YES");
				}
			}else{
				final int pairs = min_count;
				final int single = mid_count - min_count;
				
				if(pairs == 0){
					// b の時 aba はまずい baba もまずい
					if(single >= 2){
						System.out.println("NO");
					}else if(max_count >= 2){
						System.out.println("NO");
					}else{
						System.out.println("YES");
					}
				}else if(single >= 2){
					System.out.println("NO");
				}else{
					final int min_place = pairs;
					final int max_place = pairs + 1;
					if(max_count < min_place){
						System.out.println("NO");
					}else if(max_count > max_place){
						System.out.println("NO");
					}else{
						System.out.println("YES");
					}
				}
			}
		}
	}
	
	public static class Scanner implements AutoCloseable {
		private BufferedReader br;
		private StringTokenizer tok;

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

		private void getLine() {
			try {
				while (!hasNext()) {tok = new StringTokenizer(br.readLine());}
			} catch(IOException e){ /* ignore */ }
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() {
			getLine(); return tok.nextToken();
		}

		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n){
			int[] ret = new int[n];
			for(int i = 0; i < n; i++){ ret[i] = nextInt(); }
			return ret;
		}
		public long[] nextLongArray(int n){
			long[] ret = new long[n];
			for(int i = 0; i < n; i++){ ret[i] = nextLong(); }
			return ret;
		}
		public double[] nextDoubleArray(int n){
			double[] ret = new double[n];
			for(int i = 0; i < n; i++){ ret[i] = nextDouble(); }
			return ret;
		}

		public void close() {
			try{ br.close(); } catch (IOException e){ /*ignore*/ }
		}
	}
}


Measured memory_bytes: 23124
// Bismillahir Rahmanir Rahim  //
// Tanbir Ahmed  << RibNat >>  //
// University of Barisal       //



#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     fast            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     in1(X)          scanf("%lli",&(X))
#define     ins(S)          scanf("%s",(S))
#define     out(X)          printf("%lli",(X))
#define     outs(S)         printf("%s",(S))
#define     Pnl             printf("\n")
#define     End             return 0
#define     ll              long long int
#define     Pair            pair<ll,ll>
#define     F               first
#define     S               second
#define     all(v)          v.begin(),v.end()
#define     mem(a,v)        memset(a,v,sizeof(a))
#define     Max             1000000000000000014
#define     Min             -1000000000000000014
#define     mod             1000000007
#define     range           10007

#define     pb              push_back
#define     Vector          vector<ll>
#define     mp              make_pair
#define     PI              3.1415926535897
#define     min_heap        priority_queue <ll, vector<ll>, greater<ll> >
#define     ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>  //*(x.find_by_order(k)),x.order_of_key(k)

/*************** #Template FUNCTIONS# **************/

// ll pc;void PrintCase(){printf("Case %lli: ",++pc);}
// ll GCD(ll a,ll b){if(a<0) a*=-1;if(b<0) b*=-1;if(a<b)swap(a,b);if(b==1) return 1;if(!b) return a;if(!(a%b)) return b;else return GCD(b,a%b);}
//  ll LCM(ll a,ll b){ll x=GCD(a,b);return (a/x)*b;}
// ll bigmod(ll n,ll p){if(p==0) return 1;if(p==1)return (n+mod)%mod;if(p%2)return (bigmod(n,p-1)*n+mod)%mod;else{ll x=bigmod(n,p/2);return (x*x+mod)%mod;}}
 ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
// ll modinverse(ll n){return bigmod(n,mod-2)%mod;}
// ll Check(ll n,ll i){return (n&(1LL<<i));}
// ll Set(ll n,ll i){return (n|(1LL<<i));}
// ll status[(ll)range/64+5];Vector primes;void sieve(){for(ll i=3;i<=sqrt(range);i+=2){if(Check(status[i/64],i%64)==0){for(ll j=i*i;j<range;j+=2*i){status[j/64]=Set(status[j/64],j%64);}}}primes.pb(2);for(ll i=3;i<range;i+=2)if(Check(status[i/64],i%64)==0)primes.pb(i);}

// ll dx[] = {-2, -1, 1, 2,  2,  1, -1, -2};
// ll dy[] = { 1,  2, 2, 1, -1, -2, -2, -1};

// ll X[]= {0,0,1,-1,1,1,-1,-1};
// ll Y[]= {1,-1,0,0,1,-1,1,-1};

/********************** START **********************/






int main(){
    // ll t;
    // cin>>t;
    // while(t--){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    //ans=0;
    if(k<a){
        cout<<k<<endl;
    }
    else if(k<=(a+b)){
        cout<<a<<endl;
    }
    else if(k>(a+b)){
        ll x=k-(a+b);

        cout<<a-x<<endl;
    }

//    }
}






/*******      ALHAMDULILLAH     *********/  
/*******      Happy Coding      *********/


Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}


int main(){
  int H,W;
  cin>>H>>W;
  char field[H][W];
  rep(i,H){
    rep(j,W){
      cin>>field[i][j];
    }
  }
  
  int L[H][W];
  int R[H][W];
  int U[H][W];
  int B[H][W];
  
  rep(i,H){
    rep(j,W){
      if(field[i][j]=='#'){
        L[i][j]=0;
        continue;
      }
      if(j==0) L[i][j]=1;
      else if(i>=0||i<H||j>=0||j<W){
        L[i][j]=L[i][j-1]+1;
      }
    }
  }
    per(i,H){
    per(j,W){
     
      if(field[i][j]=='#') {
        R[i][j]=0;
        continue;
      }
      if(j==W-1) R[i][j]=1;
      else if(i>=0||i<H||j>=0||j<W){
        R[i][j]=R[i][j+1]+1;
      }
    }
  }
    rep(i,H){
    rep(j,W){
      
      if(field[i][j]=='#'){
        U[i][j]=0;
        continue;
      }
      if(i==0) U[i][j]=1;
      else if(i>=0||i<H||j>=0||j<W){
        U[i][j]=U[i-1][j]+1;
      }
    }
  }
    per(i,H){
    per(j,W){
      
      if(field[i][j]=='#'){
        B[i][j]=0;
        continue;
      }
      if(i==H-1) B[i][j]=1;
      else if(i>=0||i<H||j>=0||j<W){
        B[i][j]=B[i+1][j]+1;
      }
    }
  }
  
  
  int ans=0;
  rep(i,H){
    rep(j,W){
      if(field[i][j]=='.'){
        int ans1=L[i][j]+R[i][j]+U[i][j]+B[i][j]-3;
        ans=max(ans1,ans);
      }
    }
  }
  
  cout<<ans<<endl;
}
  
    

Measured memory_bytes: 66688
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 233;
LL nums[MAXN];
set<LL> suf[MAXN];

int find_k(LL val) {
  int k = 0;
  while ((1LL<<k) <= val) {
    k++;
  }
  return k-1;
}

void insert(set<LL>& cur, LL val) {
  for (auto it = cur.rbegin(); it != cur.rend(); it++) {
    int k = find_k(*it);
    if ((1LL<<k) & val) val ^= *it;
  }
  if (val != 0) cur.insert(val);
}

LL rem(const set<LL>& cur, LL val) {
  for (auto it = cur.rbegin(); it != cur.rend(); it++) {
    int k = find_k(*it);
    if ((1LL<<k) & val) val ^= *it;
  }
  return val;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int t; cin >> t;
  while (t--) {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> nums[i];
      suf[i].clear();
    }
    suf[n].clear();
    string s; cin >> s;
    for (int i = n-1; i >= 0; i--) {
      suf[i] = suf[i+1];
      if(s[i] == '0') insert(suf[i], nums[i]);
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        LL r = rem(suf[i+1], nums[i]);
        if (r != 0) {
          flag = false;
          break;
        }
      }
    }
    if (flag) cout << "0\n";
    else cout << "1\n";
  }






/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int n, k;
    cin >> n >> k;
    if (n % k == 0) cout << "0" << endl;
    else cout << "1" << endl;
    return 0;
}

Measured memory_bytes: 3556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
    	int T = ni();
    	int[] N = new int[T];
    	int[] D = new int[T];

    	for (int i=0; i<T; i++) {
    		N[i] = ni();
    		D[i] = ni();
    	}

    	for (int i=0; i<T; i++) {
    		if (N[i] % 2 == 0) {
    			out.println((N[i] - 1) * 127 + (127 ^ D[i]));
    		} else {
    			out.println((N[i] - 1) * 127 + D[i]);
    		}
    	}
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}


Measured memory_bytes: 9040
S = input()
if S[0] == "A":
  count = 0
  for i in S[2:-1]:
    if i == "C":
      count += 1
  if count == 1:
    c = 0
    for i in S:
      if i.isupper():
        c += 1
    if c == 2:
      print("AC")
      exit()
print("WA")

Measured memory_bytes: 9108
#include <stdio.h>
int main(){
  int t,n,i;
  for(i=0;i<4;i++){
    scanf("%d %d",&t,&n);
    if(t==1){
      printf("%d\n",6000*n);
    }
    else if(t==2){
      printf("%d\n",4000*n);
    }
    else if(t==3){
      printf("%d\n",3000*n);
    }
    else if(t==4){
      printf("%d\n",2000*n);
    }
  }
  return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
  	cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 2e5+5;

void solve(){
    LL n, x, m;
    cin >> n >> x >> m;
    LL res = 0;

    LL slow = x, fast = x;
    do{
        slow = slow*slow%m;
        fast = fast*fast%m;
        fast = fast*fast%m;
    }while(slow != fast);

    fast = x;
    int L = 0;
    while(slow != fast){
        res += fast;
        L++;
        if(L == n){
            cout << res << "\n";
            return;
        }
        slow = slow*slow%m;
        fast = fast*fast%m;
    }
    n -= L;

    vi cyc;
    do{
        cyc.push_back(slow);
        slow = slow*slow%m;
    }while(slow != fast);

    LL cyclen = sz(cyc);
    for(int i = 0; i < cyclen; ++i){
        res += (n/cyclen)*cyc[i];
    }
    n %= cyclen;
    for(int i = 0; i < n; ++i){
        res += cyc[i];
    }
    cout << res << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 3860
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

ll k,a,b;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>k>>a>>b;
	ll ans=0;
	{
		Umax(ans,k+1);
	}
	{
		k-=a-1;
		ll f=0;
		if(k%2){
			k--;
			f=1;
		}
		Umax(ans,f+k/2*(b-a)+a);
	}
	Tone(ans)
	
	return 0;
}


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

const static double pi = 4*atan(1.0);
int main(){
	long long n,sum=0;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
		sum += v[i];
	}
	sort(begin(v),end(v));
	cout << v[0] << " " << v[n-1] << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1260
N = int(input())
table = list(map(int,input().split()))

MAX = 2000
check = [False]*(MAX+1)

def recursive(index,tmp_sum):
    global N

    if index == N:
        check[tmp_sum] = True
        return

    recursive(index+1,tmp_sum)
    if tmp_sum + table[index] <= MAX:
        recursive(index+1,tmp_sum+table[index])

recursive(0,0)

num_query = int(input())
for num in list(map(int,input().split())):
    if check[num]:
        print("yes")
    else:
        print("no")


Measured memory_bytes: 5640
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int a, b;
        scanf("%d%d", &a, &b);
        if (a > b) {
                printf("%d\n", a - 1);
        } else {
                printf("%d\n", a);
        }
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r: i32 = read();
    let D: i32 = read();
    let mut x: i32 = read();
    for _ in 0..10 {
        x = x * r - D;
        println!("{}", x);
    }
}


Measured memory_bytes: 4352
// Math = ♥
// Sometimes it is people that no one imagines anything of who do things that no one can imagine
// After all this time? Always

#include <bits/stdc++.h>                        // uncomment before submission
//#include <ext/pb_ds/assoc_container.hpp>		// uncomment before submission
//#include <ext/pb_ds/tree_policy.hpp>			// uncomment before submission
//using namespace __gnu_pbds;					// uncomment before submission
using namespace std;
//<---------------------------------------------------Template----------------------------------------------------------->
#define int long long
#define ll long long
#define ld long double
int INF = 1e15 + 7;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;                  // Vector of long long
typedef vector<vi> vvi;                 // Vector of vi
typedef vector<ii> vii;                 // Vector of pairs
typedef vector<vii> vvii;               // Vector of Vector of pairs
typedef vector<bool> vb;                // Vector of bool
#define pq priority_queue               // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                        // For pairs
#define ss second                       // For pairs
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
//<----------------------------------------------------------------------------------------------------------------------->

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

    vector<char> op;
    vi num;

    int x;
    cin >> x, num.pb(x);
    for (int i = 0; i < n - 1; i++)
    {
        char ch;
        cin >> ch >> x;
        op.pb(ch), num.pb(x);
    }

    vvi dp(n, vector<int>(3));
    dp[0][0] = num[0];
    dp[0][1] = -INF;
    dp[0][2] = -INF;

    for (int i = 1; i < n; i++)
    {
        if (op[i - 1] == '+')
        {
            dp[i][1] = dp[i - 1][1] - num[i];
            dp[i][2] = dp[i - 1][2] + num[i];
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + num[i];
        } else
        {
            dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) - num[i];
            dp[i][2] = max(dp[i - 1][1], dp[i - 1][2]) + num[i];
            dp[i][0] = -INF;
        }
        dp[i][0] = max(dp[i][0], max(dp[i][1], dp[i][2]));
        dp[i][1] = max(dp[i][1], dp[i][2]);
    }

    int a[] = {dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]};
    sort(a, a + 3);

    cout << a[2] << endl;
    return 0;
}


Measured memory_bytes: 6644
import java.util.Scanner;


public class Main {

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

		int n = 1;
		while ((n = sc.nextInt()) != 0) {
			long[][] a = new long[2][5000];
			for (int j = 0 ; j < n ; j++) {
				a[0][j] = sc.nextLong();
			}

			long max = Long.MIN_VALUE;
			for (int i = 0 ; i < n ; i++) {
				for (int j = 0 ; j < n-i ; j++) {
					long l = a[1][j] += a[0][i+j];
					max = Math.max(max, l);
				}
			}
			System.out.println(max);

		}


	}
}

Measured memory_bytes: 26528
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

int main(){
  ll N;
  cin >> N;
  ll c[N], d[N];
  vector<vector<ll> > edge(N, vector<ll>(N, 0));
  rep(i, N-1){
    ll a, b;
    scanf("%lld %lld", &a, &b);
    edge[a-1][b-1] = 1;
    edge[b-1][a-1] = 1;
    edge[a-1][a-1]++;
    edge[b-1][b-1]++;
  }
  rep(i, N) cin >> c[i];
  sort(c, c+N);

  vector<ll> ends;
  rep(i, N) if(edge[i][i] == 1) ends.push_back(i);
  rep(i, N){
    ll a = ends[i];
    d[a] = c[i];
    if(edge[a][a] == 0) continue;
    edge[a][a] = 0;
    ll b = 0;
    while(!edge[a][b]) b++;
    rep(b, N) if(edge[a][b]) break;
    edge[a][b] = 0;
    edge[b][a] = 0;
    edge[b][b]--;
    if(edge[b][b] == 1) ends.push_back(b);
  }
  ll ans = 0;
  rep(i, N-1) ans += c[i];
  printf("%lld\n", ans);
  rep(i, N-1) printf("%lld ", d[i]);
  printf("%lld\n", d[N-1]);
  return 0;
}


Measured memory_bytes: 782336
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"strconv"
)

// const abcd = "abcdefghijklmnopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var dr = [...]int{0, 1, 1, 1, 0, -1, -1, -1, 0}
var dc = [...]int{1, 1, 0, -1, -1, -1, 0, 1, 0}

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	H := nextInt()
	W := nextInt()
	a := make([]string, H)
	for i := 0; i < H; i++ {
		a[i] = nextString()
	}
	dh := make([]int, H)
	dw := make([]int, W)
	for i := 0; i < H; i++ {
		b := false
		for j := 0; j < W; j++ {
			if a[i][j] == '#' {
				b = true
				break
			}
		}
		if b == false {
			dh[i] = -1
		}
	}
	for i := 0; i < W; i++ {
		b := false
		for j := 0; j < H; j++ {
			if a[j][i] == '#' {
				b = true
				break
			}
		}
		if b == false {
			dw[i] = -1
		}
	}
	var out bytes.Buffer
	for i := 0; i < H; i++ {
		if dh[i] == -1 {
			continue
		}
		for j := 0; j < W; j++ {
			if dw[j] == -1 {
				continue
			}
			out.WriteString(string(a[i][j]))
		}
		out.WriteString("\n")
	}
	fmt.Println(out.String())
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func printInts(out []int, str string) {
	var bb bytes.Buffer
	for i := range out {
		bb.WriteString(strconv.Itoa(out[i]))
		bb.WriteString(str)
	}
	fmt.Println(bb.String())
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main(){
	int N;
	string S;
	cin>>N>>S;
	
	int pos=0;
	string ans="";
	for(int i=0 ; i<S.size() ; i++){
		if(S.substr(i,1)=="(")pos+=1;
		else if(S.substr(i,1)==")")pos-=1;
		if(pos<0){
			ans+="(";
			pos=0;
		}
	}
	ans+=S;
	if(pos>0){
		while(pos>0){
			ans+=")";
			pos-=1;
	}
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long N=sc.nextLong();
		long M=sc.nextLong();
		long D=sc.nextLong();
      	double kakuritu=0;
		if(D==0) {
			kakuritu=1.0/N*(M-1);
		}
		else {
			kakuritu=(2*(double)(N-D))/(N*N)*(M-1);
		}
      pl(kakuritu);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 999999999;

int H, W;
vector<vector<char>> maze;
vector<vector<int>> cost;

int bfs(int y, int x) {
   int dy[4] = {1, 0, -1, 0};
   int dx[4] = {0, 1, 0, -1};

   queue<pair<int, int>> que;
   que.push(make_pair(y, x));

   while(!que.empty()) {
       pair<int, int> p = que.front();
       que.pop();
       for (int i = 0; i < 4; ++i) {
           int nowY = p.first + dy[i];
           int nowX = p.second + dx[i];
           if (1 <= nowY && nowY <= H && 1 <= nowX && nowX <= W && maze[nowY][nowX] != '#' && cost[nowY][nowX] == -1 ) {
               cost[nowY][nowX] = cost[p.first][p.second] + 1;
               que.push(make_pair(nowY, nowX));
               if (nowY == H && nowX == W) return cost[nowY][nowX];
           }
       }
   }
   return -1;
}

int main() {
    cin >> H >> W;
    maze = vector<vector<char>>(H+1, vector<char>(W+1));
    cost = vector<vector<int>>(H+1, vector<int>(W+1, -1));

    int nSharp = 0;
    for (int i = 1; i <= H; ++i) {
        for (int j = 1; j <= W; ++j) {
            char inp; cin >> inp;
            maze[i][j] = inp;
            if (inp == '#') nSharp++;
        }
    }
    cost[1][1] = 0;

    int checkedBfs = bfs(1, 1);
    if (checkedBfs == -1) {
        cout << -1 << endl;
    } else {
       cout << H * W - nSharp - (checkedBfs+1) << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    cout << ((n >= 3200) ? s : "red") << endl;
}

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

#define LL long long
#define hell 1000000007
#define PI acos(-1.0)



int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout << fixed << showpoint;
cout << setprecision(11);


LL x;cin>>x;
LL ans = 0;

if(360%x==0){
    ans = 360/x;
}
else{
    int k = 1;
    while(k<=360){
        if((x*k)%360==0){
            ans = k;break;
            
        }
        k++;
    }
}

cout<<ans;

return 0;
} 

Measured memory_bytes: 3636
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);

	void solve(){
		long a=gInt(),b=gInt(),c=gInt();
		long k=gLong();
		System.out.println(k%2==0?a-b:b-a);
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}
class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}

	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}

}

Measured memory_bytes: 23892
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int[] a=new int [n];
		int[] array=new int [n];
		for (int i=0;i<n;++i) {
			a[i]=Integer.parseInt(scan.next());
		}
		
		for (int i=0;i<n;++i) {
			array[a[i]-1]=i+1;
			
		}
		
		for(int i:array) {
			System.out.println(i);
		}
}		
}
//end

Measured memory_bytes: 54180
#include<stdio.h>
#define N 101

void Print();

int n,A[N][N];

int main()
{
  int v,u,k,i,j;

  scanf("%d",&n);

  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)A[i][j] = 0;
    scanf("%d%d",&u,&k);
    for(j=1;j<=k;j++)
    {
      scanf("%d",&v);
      A[u][v] = 1;
    }
  }

  Print();

  return 0;
}

void Print()
{
  int i,j;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=n;j++)
    {
      if(j == n)printf("%d\n",A[i][j]);
      else printf("%d ",A[i][j]);
    }
  }
}



Measured memory_bytes: 2112
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
 if 500*i>x: break
 for j in range(b+1):
  if 500*i+100*j > x: break
  if x-500*i-100*j <= 50*c:
   count += 1

print(count)

Measured memory_bytes: 3060
import sys
from collections import deque

input = sys.stdin.readline


def main():
    S = input().split()

    stack = deque()
    for s in S:
        if s in ["+", "-", "*"]:
            b = stack.pop()
            a = stack.pop()
            c = str(eval(a + s + b))
            stack.append(c)
        else:
            stack.append(s)
    ans = stack.pop()
    print(ans)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5968