akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define S 101
int graph[S][S];
int d[S];
int f[S];
int n;

void init(){
	int i, j;
	int u, k, v;
	scanf("%d", &n);
	for( i = 1; i <= n; i++ ){
		d[i] = -1;
		f[i] = -1;
		for( j = 1; j <= n; j++ ){
			graph[i][j] = 0;
		}
	}
	for( i = 1; i <= n; i++ ){
		scanf("%d", &u);
		scanf("%d", &k);
		for( j = 0; j < k; j++ ){
			scanf("%d", &v);
			graph[i][v] = 1;
		}
	}
	return;
}

void printGraph(){
	int i, j;
	for( i = 1; i <= n; i++ ){
		for( j = 1; j < n; j++ ){
			printf("%d ", graph[i][j]);
		}
		printf("%d\n", graph[i][n]);
	}
	return;
}

int dfs(int i, int c){
	int j;
	d[i] = ++c;
	for( j = 1; j <= n; j++ ){
		if( graph[i][j] == 1 && d[j] == -1 ){
			c = dfs(j, c);
		}
	}
	f[i] = ++c;
	return c;
}

void print(){
	int i;
	for( i = 1; i <= n; i++ ){
		printf("%d %d %d\n", i, d[i], f[i]);
	}
	return;
}

int main(){
	int i, c = 0;
	init();
	for( i = 1; i <= n; i++ ){
		if( d[i] == -1 ){ c = dfs(i, c); }
	}
	print();
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll _v):v(normS(_v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ModInt& operator++(int){ return *this=*this+1;}
	ModInt& operator--(int){ return *this=*this-1;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll p[]={a,1,0},q[]={b,0,1};
		while(*q){
			ll t=*p/ *q;
			rep(i,3) swap(p[i]-=t*q[i],q[i]);
		}
		if(p[0]<0) rep(i,3) p[i]=-p[i];
		x=p[1],y=p[2];
		return p[0];
	}
	ModInt inv() const {
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	ModInt pow(ll p) const {
		if(p<0) return inv().pow(-p);
		ModInt a = 1;
		ModInt x = *this;
		while(p){
			if(p&1) a *= x;
			x *= x;
			p >>= 1;
		}
		return a;
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	string s;
	cin >> s;
	V<mint> dp = {0,1};
	for(char c: s){
		V<mint> ndp = {0,0};
		int d = c-'0';
		rep(eq,2){
			rep(x,2){
				if(eq && d < x) continue;
				bool neq = eq && d==x;
				ndp[neq] += dp[eq] * (x+1);

			}
		}
		dp = ndp;
	}
	cout << dp[0] + dp[1] << endl;
}


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

int main() {
  int x[5], ans;
  
  for ( int i = 0; i < 5; i++ ) {
    cin >> x[i];
    if ( x[i] == 0 ) {
      ans = i + 1;
      
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  string s;
  int w;
  cin >> s >> w;
  for (int i = 0; i*w < s.size(); i++)
    cout << s[i*w];
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
*D, = [s.split() for s in open(0)]
D = D[0][0]
flag = 0
for i in range(len(D)):
    if (i + 1) % 2 == 0:
        if not D[i] in ["L", "U", "D"]:
            flag += 1
            break
    else:
        if not D[i] in ["R", "U", "D"]:
            flag += 1
            break
if flag:
    print("No")
else:
    print("Yes")
            

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);



ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //vll segtree(524287);
  //ll N=262144;
  ll n;
    cin>>n;
  FOR(i,0,1000000){
    ll a=1.08*i;
    if(a==n){
      cout<<i<<endl;
      return;
    }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  char a[11],b[11],c[11];
  scanf("%s%s%s",a,b,c);
  if(a[strlen(a)-1] == b[0] && b[strlen(b)-1] == c[0])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}

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

typedef long long int64;

int64 ex_gcd(int64 a,int64 b,int64&x,int64&y){
	if(!b){x=1;y=0;return a;}
	int64 ans = ex_gcd(b,a%b,x,y);
	int64 t = x; x = y; y = t - a/b*y;
	return ans;
}

int main(){
	int T;cin>>T;
	rep(it,T){
		int64 x,y;
		cin>>x>>y;

		int64 p,q;
		//px+qy = d
		int64 d = ex_gcd(x,y,p,q);
		q = -q;

		if(d <= 50000){
			//px-qy = -d
			for(;;){
				bool ok = 0;
				if(p<0){
					int64 d = (-p)/y;
					p += d * y;
					q += d * x;
					if(p<0) p+=y,q+=x;
					ok = 1;
				}
				if(p>y){
					int64 d = (p-y)/y;
					p -= d * y;
					q -= d * x;
					if(p>y) p-=y,q-=x;
					ok = 1;
				}
				if(q<0){
					int64 d = (-q)/x;
					p += d * y;
					q += d * x;
					if(q<0) p+=y,q+=x;
					ok = 1;
				}
				if(q>x){
					int64 d = (q-x)/x;
					p -= d * y;
					q -= d * x;
					if(q>x) p-=y,q-=x;
					ok = 1;
				}
				if(!ok)
					break;
			}
			cout<<3<<endl;
			cout<<0<<" "<<0<<endl;
			cout<<q<<" "<<p<<endl;
			cout<<x<<" "<<y<<endl;
		} else {
			cout<<4<<endl;
			cout<<0<<" "<<0<<endl;
			cout<<x<<" "<<y-1<<endl;
			cout<<x/d<<" "<<y/d<<endl;
			cout<<x-1<<" "<<y<<endl;
		}
	}
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip>
typedef long long int ll;
using namespace std;

ll n;
double a[30005];
ll mt;
double dp[3005][3005];

double go(ll p,ll lt)
{
	if (p<=0)
	return 1;
	else if (dp[p][lt]!=-1.0)
	return dp[p][lt];
	else
	{
		double x;
		if (lt<=0)
		x=a[p]*(go(p-1,lt));
		else
		{
			x=a[p]*(go(p-1,lt))+(1-a[p])*(go(p-1,lt-1));
		}
		dp[p][lt]=x;
		return x;
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n;
    mt=n/2;
    for (int i=1;i<=n;i++)
    cin>>a[i];
    fill_n(*dp, 3005*3005, -1.0);
    
    cout<<fixed<<setprecision(16)<<go(n,mt)<<endl;

}


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

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> h(n),dp(n);
	for(int i  = 0; i < n; i++) cin >> h[i];
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]));
	}
	cout << dp[n-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//


void solve(void)
{
  string str;cin>>str;
  stack<char> st;
  for (int i = 0; i < str.size(); i++)
  {
    char x = str[i];
    if(st.empty())
    {
      st.push(x);
    }
    else
    {
      if(st.top() != x)
      {
        st.pop();
      }
      else
      {
        st.push(x);
      }
    }
    
  }
  cout<<(int)str.size() - (int)st.size()<<endl;
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


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

namespace ProblemD
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            if (As.Contains(0))
                Console.WriteLine(As.Select(x => Math.Abs(x)).Sum());
            else
            {
                var negativeNumCount = As.Where(x => x < 0).Count();
                var modAs = As.Select(x => Math.Abs(x)).ToArray();
                var minusNum = negativeNumCount % 2 == 0 ? 0 : modAs.Min();
                Console.WriteLine(modAs.Sum() - 2 * minusNum);
            }
        }
    }
}


Measured memory_bytes: 31196
import math
A,B,H,M = map(int,input().split())
arg_H = (360*H)/12+(30*M)/60
if M ==0:
    arg_M = 360
else:
    arg_M = (360*M)/60
HM = abs(arg_H-arg_M)
arg_HM = min(HM, 360-HM)
CM2 = A**2+B**2-2*A*B*math.cos(math.radians(arg_HM))
CM = math.sqrt(CM2)
print(CM)

Measured memory_bytes: 9400
a , b , k = map(int,input().split())

if k % 2 == 0:
    for i in range(int(k / 2)):
        if a % 2 == 1:
            a -= 1
        a = a / 2
        b += a
        if b % 2 == 1:
            b -= 1
        b = b / 2
        a += b
else:
    for i in range(int((k - 1) / 2)):
        if a % 2 == 1:
            a -= 1
        a = a / 2
        b += a
        if b % 2 == 1:
            b -= 1
        b = b / 2
        a += b
    if a % 2 == 1:
        a -= 1
    a = a / 2
    b += a
    
print(int(a),end=" ")
print(int(b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
    long i,j,t,a,b,n,c,temp,m;
    t=1;
    // cin>>t;
    while(t--)
    {
       string s;
       cin>>s;
       for(i=0;i<s.length();i++)
       {
           if(s[i]=='i')
           {
               a=i;
               break;
           }
       }
        for(i=s.length()-1;i>=0;i--)
       {
           if(s[i]=='n')
           {
               b=i;
               break;
           }
       }
       cout<<s[0]<<s.length()-2<<s[s.length()-1];
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(){
  int num[100];
  int i=0;
  char s[100];
 
  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      num[i-2] += num[i-1];
      i = i-1;
    } else if ( s[0] == '-' ){
      num[i-2] -= num[i-1];
      i = i-1;
    } else if ( s[0] == '*' ){
      num[i-2] *= num[i-1];
      i = i-1;
    } else {
      num[i] = atoi(s);
      i = i+1;
    }
  }
 
  printf("%d\n",num[0]);
 
return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>
#include <stack>
#include <queue>
#include <list>
#include <numeric> //accumulate

using namespace std;

//???????????°??????TEST????????????????????¬???????????????????????????????????¢????????????
#define TEST //*******************************************************************************************************************************************

//?????????????????¨??§?????\????????????????????????????????°?????????????¨???????????????????dout???????????????????????§???????????¬??????????????????????????????????????????
#ifdef TEST
    #define dout cout
#else
    stringstream dummy; //???????????°??????dout?????????????????????????????????
    #define dout dummy.str(""); dummy.clear(stringstream::goodbit); dummy //dummy?????????????????????????????????????????¨?????¢?????¢???????????????
    //???????????¨??????????????????goodbit?????????????????????????????¨???????????´????????????????????????????????¨?????°?????????????????§???????????????????????????????????? http://d.hatena.ne.jp/linden/20060427/p1
#endif


int main(void) {
    int n, q;
    
    cin >> n;
    int S[n+1]; //S[n]???????????????????????????
    for(int i=0; i<n; i++) cin>>S[i];
    
    cin >> q;
    int T[n];
    for(int i=0; i<q; i++) cin>>T[i];
    
    
//    dout<<"S = ";
//    for(int i=0; i<n; i++) dout<<S[i]<<" ";
//    dout<<endl;
//    
//    dout<<"T = ";
//    for(int i=0; i<q; i++) dout<<T[i]<<" ";
//    dout<<endl;
    
    
    //search T from S
    int ans = 0;
    for (int i=0; i<q; i++) { //S[]????????????T[i]???key?????¢?´¢
        int key = T[i];
        S[n] = key; //S??????????°????????????¨??????key????????????

        int j = 0;
        while (S[j]!=key) {
            j++;
        }
        
        if(j!=n) ans++;
        
        //        for (int j=0; j<n; j++) {
//            if(T[i]==S[j]) {
//                ans++;
//                break;
//            }
//        }
    }
    
    
    //output
    cout << ans << endl;
    
    
    return 0;
}

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

int main() {
	unsigned long long sum = 0;
	long long int n;
	cin >> n;
	for(long long int i=1;i<=n;i++){
	    if(i%3!=0&&i%5!=0){
	        sum = sum + i;
	    }
	}
	cout << sum << endl;
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      int k = 0;
      while ((i & 1 << k) == (j & 1 << k)) {
        k++;
      }
      cout << k + 1 << ' ';
    }
    cout << '\n';
  }

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pi;
#define ll long long
int main(){
    int n;
    cin>> n;
    int arr[n];
    for(int i=0;i<n;i++)cin>> arr[i];
    sort(arr,arr+n);
    ll ans = arr[n-1];
    if(n==2)cout<< ans;
    else{
        int temp = n-2,i = n-2,cnt = 0;
        while(temp > 0){
            cnt++;
            ans += arr[i];
            temp--;
            if(cnt%2==0){
                cnt = 0;
                i--;
            }
        }
        cout<< ans;
    }
    
}

Measured memory_bytes: 4348
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int c[]={500,100,50,10,5,1};
int main(){
    int a=3;
    while(a){
        int h,m,s;
        cin>>h>>m>>s;
        int t=h*3600+m*60+s;
        cin>>h>>m>>s;
        int diff=h*3600+m*60+s-t;
        cout<<diff/3600<<" ";
        diff%=3600;
        cout<<diff/60<<" ";
        cout<<diff%60<<endl;
        a--;
    }
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
    #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif 
    IOS
    int n; cin>>n;
    if(n == 0)
    {
        cout<<"No";
        return 0;
    }
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j == n){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
  f1=fi(s,i)
  if f1==-1:
    continue
  s1=s[f1+1:]
  for j in range(10):
    f2=fi(s1,j)
    if f2==-1:
      continue
    s2=s1[f2+1:]
    for k in range(10):
      f3=fi(s2,k)
      if f3>=0:
        ans+=1
print(ans)

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

int main(){
  int N; cin >>N;
  
  for(int i=1;i<=N;++i){
    int x = i;
    if(x%3==0){ cout << " " << i; continue;}
    while(x>0){
      if(x%10==3){ cout << " " << i; break;}
      x /= 10;
    }
  }
  cout <<"\n";
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

    int a=0,b=0,c=0;
    bool f=0;
    REP(i,y/10000+1){
        int z=y-10000*i;
        REP(j,z/5000+1){
            if(z-5000*j==1000*(n-i-j)){
                a=i;b=j;c=n-i-j;
                f=1;
                break;
            }
        }
    }
    f? cout<<a<<" "<<b<<" "<<c<<endl:cout<<-1<<" "<<-1<<" "<<-1<<endl;

	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	long long a,b,c,s;
	cin>>a>>b>>c;
	for(long i=0;i<10;i++)
	{
		s=(a*c)-b;
		c=s;
		cout<<s<<endl;
	}
 
	return 0;
}

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

int main(){
  int i, n;
  cin >> n;
  vector<int> vec(n);
  
  for(int i=0; i < n; i++){
    cin >> vec.at(i);
  }
  for(int j = n-1; j >= 0; j--){
    if( j == 0 ) cout << vec.at(j);
    else cout << vec.at(j) << " ";
   
  }
  cout << endl;
  return 0;
}
  


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const int N=1e5+5;
ll dp[N],h[N],n;
ll f(int i){
	if(i==n-1)return 0;
	ll &r=dp[i];
	if(r!=-1)return r;
	r=f(i+1)+abs(h[i+1]-h[i]);
	if(i<n-2)r=min(r,f(i+2)+abs(h[i+2]-h[i]));
	return r;
}

int main(){FIN;
	cin>>n;mset(dp,-1);
	fore(x,0,n)cin>>h[x];
	cout<<f(0)<<"\n";
}

Measured memory_bytes: 4992
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#define ll long long
#define inf 20021225
#define N 3100
#define M 100010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct edge{int to,lt,f,c;}e[M];
int cnt=1,in[N],s,t,fr[N]; ll ans;
void add(int x,int y,int f,int c)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt; e[cnt].f=f; e[cnt].c=c;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt; e[cnt].f=0; e[cnt].c=-c;
}
queue<int> q; ll dis[N]; bool vis[N];
bool spfa()
{
	while(!q.empty())	q.pop();
	memset(dis,48,sizeof(dis));
	q.push(s); dis[s]=0;
	while(!q.empty())
	{
		int x=q.front(); q.pop(); vis[x]=0;
		for(int i=in[x];i;i=e[i].lt)
		{
			int y=e[i].to;
			if(e[i].f&&dis[y]>dis[x]+e[i].c)
			{
				dis[y]=dis[x]+e[i].c; fr[y]=i;
				if(!vis[y])	q.push(y),vis[y]=1;
			}
		}
	}
	return dis[t]!=dis[0];
}
void flow()
{
	int fl=inf; ll c=0;
	for(int i=t;i!=s;i=e[fr[i]^1].to)	fl=min(fl,e[fr[i]].f);
	for(int i=t;i!=s;i=e[fr[i]^1].to)	e[fr[i]].f-=fl,e[fr[i]^1].f+=fl;
	ans+=dis[t]*fl;
}
int main()
{
	int n=read(); s=N-2,t=s+1; int p=N-10;
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read(),f=read();
		add(s,i,f,0);
		add(i,p,f,-x-y);
		add(i,p+1,f,-x+y);
		add(i,p+2,f,x-y);
		add(i,p+3,f,x+y);
	}
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read(),f=read();
		add(i+n,t,f,0);
		add(p,i+n,f,x+y);
		add(p+1,i+n,f,x-y);
		add(p+2,i+n,f,-x+y);
		add(p+3,i+n,f,-x-y);
	}
	while(spfa())	flow();
	printf("%lld\n",-ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  ll n, m;
  cin >> n >> m;
  if(n*2>=m) cout << m/2 << endl;
  else cout << n + (m-(ll)2*n)/(ll)4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  long long cost=0;
  cin>>n>>m;
  priority_queue<int>a;
  for(int i=0;i<n;i++)
  {
    int d;
    cin>>d;
    a.push(d);
  }
  int i=0;
  while(i<m)
  {
    int t=a.top();
    a.pop();
    a.push(t/2);
    i++;
  }
  for(int i=0;i<n;i++)
  {
 	cost+=a.top();
    a.pop();
  }  
  cout<<cost<<endl;
  return 0;
}

Measured memory_bytes: 892
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
String po=sc.next().replace("11","").replace("22","").replace("33","").replace("44","").replace("55","").replace("66","").replace("77","").replace("88","").replace("99","").replace("00","");
  System.out.println((po.length()==4)?"Good":"Bad");
}
}

Measured memory_bytes: 21844
#!/usr/bin/env python
# coding: utf-8

import sys


def get_answer(param):
    yes_count = 0
    for i in [i for i in xrange(1, 11) if i not in param]:
        if param[0] + param[1] + i <= 20:
            yes_count += 1
    return ("NO", "YES")[yes_count >= 4]


def main():
    params = [map(int, line.split(" ")) for line in sys.stdin.readlines()]

    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7256
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))



n,m,r=mp()
l=lmp()
d = [[float("inf")]*(n+1) for i in range(n+1)] 
for i in range(m):
    x,y,z = map(int,input().split())
    d[x][y] = z
    d[y][x] = z
for i in range(n+1):
    d[i][i] = 0
for k in range(n+1):
        for i in range(n+1):
            for j in range(n+1):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])

lis=list(itertools.permutations(l))
ans=float("inf")
for k in range(len(lis)):
    c=0
    for i in range(r-1):
        c+=d[lis[k][i]][lis[k][i+1]]
    ans=min(ans,c)
print(ans)

Measured memory_bytes: 97368
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N;
	cin >> N;
	vector<int>a(N);
	vector<int>b(N);
	vector<int>diff(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		diff[i] = b[i] - a[i];
	}
	sort(diff.begin(), diff.end());

	ll mi = 0;
	ll ma = 0;
	for (int i = 0; i < N; i++) {
		if (diff[i] < 0)mi -= diff[i];
		else ma+=diff[i]/2;
	}

	if (mi <= ma)cout << "Yes" << endl;
	else cout << "No" << endl;









	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
lli n;
cin>>n;
lli ans=(n*(n-1))/2;
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long LL;
const int N=100500;
int read(int &n)
{
    char ch=' ';int q=0,w=1;
    for(;(ch!='-')&&((ch<'0')||(ch>'9'));ch=getchar());
    if(ch=='-')w=-1,ch=getchar();
    for(;ch>='0' && ch<='9';ch=getchar())q=q*10+ch-48;n=q*w;return n;
}
int m,n,ans;
int a[N];
int g[N];
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int main()
{
    int w;
    LL q;
    read(n);
    fo(i,1,n)q+=(LL)read(a[i]);
    if(n==1&&a[1]==1)return printf("Second\n"),0;
    if(n==1)return printf("First\n"),0;
    if(!(n&1))
    {
        if(q&1)printf("First\n");
        else printf("Second\n");
        return 0;
    }
    if(!(q&1))return printf("First\n"),0;
    for(bool I=0;1;I=!I)
    {
        g[n]=a[n];
        LL t=a[n]-1;
        fod(i,n-1,1)g[i]=gcd(g[i+1],a[i]),t+=(LL)a[i];
        bool OK=0;
        q=a[1];
        if(a[1]-1&&(1&(t/(ans=gcd(g[2],a[1]-1)))))OK=1,--a[1];
        else fo(i,2,n)if(a[i]-1)
        {
            w=gcd(q,a[i]-1);
            if(i<n)w=gcd(w,g[i+1]);
            if((1&(t/(ans=w))))
            {
                OK=1,--a[i];
                break;
            }
            q=gcd(q,a[i]);
        }else break;
        if(!OK)
        {
            if(I)printf("First\n");
            else printf("Second\n");
            return 0;
        }
        fo(i,1,n)a[i]/=ans;
    }
    return 0;
}

Measured memory_bytes: 896
#include <cstdio>

int main()
{
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<=0&&0<=b){
    puts("Zero");
  }
  else if(0<a||(b-a+1)%2==0){
    puts("Positive");
  }
  else{
    puts("Negative");
  }
  return 0;
}


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

int FindSumOfDigits(int n){ //各桁の和(10進数)
    int ans=0;
    while(n){
        ans+=n%10;
        n/=10;
    }
    return ans;
}

int main(){
    int N;
    cin >> N;
    int ans=1000000000;
    for(int i=1;i<N;i++){
        int a=i;
        int b=N-i;
        ans=min(ans,FindSumOfDigits(a)+FindSumOfDigits(b));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;



void chmax(ll &a,ll b) {
	if (a < b)a = b;
}

bool prime(int n) {
	if (n == 1) {
		return false;
	}
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	vector<int>pr(101010,0);
	vector<int>pr_like2017(101010,0);

	rep(i, 2, 101010) {
		if (prime(i))pr[i]++;
	}

	rep(i, 2, 101010) {
		if (pr[i] > 0) {
			if (pr[(i + 1) / 2] > 0) {
				pr_like2017[i]++;
			}
		}
	}

	rep(i, 1, 101010) {
		pr_like2017[i] += pr_like2017[i - 1];
	}

	int q;
	cin >> q;
	rep(i, 0, q) {
		int l, r;
		cin >> l >> r;
		cout << pr_like2017[r] - pr_like2017[l-1] << endl;
	}

	
	return 0;
}

Measured memory_bytes: 1408
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    b = []
    for i in range(m-1):
        b.append(a[i+1] - a[i])
    b.sort()
    if n < m:
        print(sum(b[:m-n]))
    else:
        print(0)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56800
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
 
#define OPTIMIZE ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define In inline
#define Re register
#define db double
#define ll long long
const int M=1e5+5;

int read(){
	int x=0,y=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') y=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*y;
}

int main(){
	int a=read(),b=read();
	int c1=a+b,c2=a-b,c3=a*b;
	printf("%d\n",max(c1,max(c2,c3)));
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    out(min(c, b/a));
    re0;
}

Measured memory_bytes: 256
// AOJ 2425: A Holiday of Miss Brute Force
// 2017.12.30 bal4u@uu

#include <stdio.h>
#include <string.h>
 
#define QMAX 10000
typedef struct { int t, x, y, s; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int x, int y, int s, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].x = x, que[i].y = y, que[i].s = s, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define INF 0x30303030
#define BASE 100

char map[202][202];
int dist[202][202][6];
int mv[2][6][2] = {{{1,0},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1}},
				   {{1,0},{1,1},{ 0,1},{-1,0},{ 0,-1},{1,-1}}};
char buf[30], *p;

int in()
{
	int n = 0;
	if (*p == '-') { p++; while (*p >= '0') n = 10*n + (*p++ & 0xf); n = -n; }
	else while (*p >= '0') n = 10*n + (*p++ & 0xf);
	p++;
	return n;
}

int dijkstra(int sx, int sy, int gx, int gy, int lx, int ly)
{
	int i, x, y, t, x2, y2, t2, d, e;

	memset(dist, INF, sizeof(dist));
	dist[sy][sx][0] = 0;
	qsize = 0;
	enq(sx, sy, 0, 0);
	while (qsize) {
		x = que[0].x, y = que[0].y, t = que[0].s, deq();
		if (x == gx && y == gy) return dist[y][x][t];

		d = (x-BASE)*(y-BASE)*t; if (d < 0) d = -d;	d %= 6;
		t2 = t+1; if (t2 == 6) t2 = 0;

		// ????????´????????????
		if (dist[y][x][t2] > dist[y][x][t]+1) {
			dist[y][x][t2] = dist[y][x][t]+1;
			enq(x, y, t2, dist[y][x][t2]);
		}

		// ?????????????§??????????
		for (i = 0; i < 6; i++) {
			x2 = x + mv[x&1][i][1], y2 = y + mv[x&1][i][0];
			e = dist[y][x][t] + (i!=d);
			if (-lx <= x2-BASE && x2-BASE <= lx &&
				-ly <= y2-BASE && y2-BASE <= ly && !map[y2][x2]) {
				if (dist[y2][x2][t2] > e) {
					dist[y2][x2][t2] = e;
					enq(x2, y2, t2, e);
				}
			}
		}
	}
	return INF;
}

int main()
{
	int sx, sy, gx, gy, n, lx, ly, x, y, ans;

	fgets(p=buf, 30, stdin);
	sx = BASE+in(), sy = BASE+in(), gx = BASE+in(), gy = BASE+in();
	fgets(p=buf, 10, stdin), n = in();
	while (n--) {
		fgets(p=buf, 15, stdin), x = BASE+in(), y = BASE+in();
		map[y][x] = 1;
	}
	fgets(p=buf, 15, stdin), lx = in(), ly = in();

	ans = dijkstra(sx, sy, gx, gy, lx, ly);
	if (ans == INF) puts("-1");
	else printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2920
# coding: utf-8
N = int(input())
S = input()
e, w = 0, 0
e = S.count("E")
ans = e
for i in range(N):
    if S[i] == "E":
        e -= 1
        ans = min(ans, e+w)
    else:
        w += 1
print(ans)

Measured memory_bytes: 3700
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();
		long C = A+B;
		long count = 0L;
		long ans = 0L;

		long aa = 0;
		long bb = 0;
		if (A == 0) {
			System.out.println(0);
		} else if (B == 0) {
			System.out.println(N);
		} else {

			/*
			while (count < N) {
				System.out.println(ans + " "+count);
				if (aa < A) {
					ans++;
					aa++;
				} else if (aa == A) {
					aa = 0;
					bb++;
				} else if (bb < B) {
					bb++;
				} else if (bb == B) {
					bb = 0;
					aa = 0;
				}
				count++;
			}	
			*/
			if (N <= A) {
				System.out.println(N);
			} else if (C >= N) {
				System.out.println(A);
			} else if (N%C==0){
				ans = A * (N/C);
				System.out.println(ans);
			} else {
				ans = A * (N/C);
				//System.out.println("test"+ans);
				if (N-(C*(N/C)) >= A) {
					ans += A;
				} else {
					ans += N-(C*(N/C));
				}
				System.out.println(ans);
			}
			
		}
	}
}

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

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

    static class A753 {
        private static final String YES = "YES";
        private static final String NO = "NO";

        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int x = in.ints();
            out.println(x == 7 || x == 5 || x == 3 ? YES : NO);
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n,l;
    cin >> n >> l;
    int r = l + n -1;
    int eat = 0;
    int sum = 0;
    if(r<=0) eat = r;
    else if(l>=0) eat = l;
    else eat = 0;
    rep(i,n){
        sum += (l+i);
    }
    cout << sum -eat << endl; 

    return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Ai = [int(x) for x in stdin.readline().rstrip().split()]

    foo = [0] + Ai + [0]
    bar = [abs(foo[i] - foo[i + 1]) for i in range(len(foo) - 1)]
    sumbar = sum(bar)

    spam = [0] + Ai + [0]
    for i in range(N):
        if foo[i] <= foo[i + 1] <= foo[i + 2] or foo[i + 2] <= foo[i + 1] <= foo[i]:
            print(sumbar)
        else:
            ans = sumbar - (bar[i] + bar[i + 1]) + abs(spam[i] - spam[i + 2])
            print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main() {
	string n;
	cin >> n;
	for (int i = 0; i < 3; i++) {
		if (n[i] == '1') {
			cout << 9;
		}
		if (n[i] == '9') {
			cout << 1;
		}
	}

	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>

using namespace std;

int n, h, w;
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> h >> w;

	int res = (n-h+1) * (n-w+1);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        
        for(int i=1; i<10; i++){
            if(N%i == 0 && N/i <10){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <functional>

using namespace std;

#define tp template
#define tn typename
#define cl class
#define us using

us str=string;
us ll=long long;
us ul=unsigned long long;
us sz=size_t;
tp<cl T,sz N>us ary=array<T,N>;
tp<sz N>using ari=array<ll,N>;

#define rep(i, n) for(ll i = 0,i##_len=(n); i < i##_len; i++)
#define loop(i, n, m) for(ll i = (n),i##_len<=(m); i < i##_len; i++)
#define all(x) (x).begin(),(x).end()

tp<tn a,tn f>void setary(a b,a e,f l){ll c=0;for(a i=b;i!=e;i++){*i=l(c);c++;}}

vector<ll> p;
void pi(ll max){
	p.resize(max+1,1);
	p[0]=0;p[1]=0;
	rep(n,max){
		if(p[n]){
			rep(m,max/n)
			p[m*n]=0;
			p[n]=1;
		}
	}
}

int main(){
	pi(55555);
	ll n;
	cin >> n;
	rep(i,n-1)
	rep(m,55555)
	if(p[m]&&m%5==1){
		p[m]=0;
		cout<<m<<" ";
		break;
	}
	rep(m,55555)
	if(p[m]&&m%5==1){
		p[m]=0;
		cout<<m<<" ";
		break;
	}
	cout<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {
    int n, i, j, k;
    int count;//素数の個数
    int l[100000];//素数の数を格納
    
    while (scanf("%d", &n) != EOF) {
        count = 0;
        //偶数で素数を持つのは2のみ
        if (n >= 2){
            l[count++] = 2;
            //printf("l[%d] = %d\n",count - 1,l[count - 1]);//
        }
        
        //2より大きい偶数は素数を持たないので奇数のみ検査
        if (n >= 3) {
            l[count++] = 3;
            //printf("l[%d] = %d\n",count - 1,l[count - 1]);//
            
            for (i = 5; i <= n; i+=2) {
                k = 0;
                //エラトステネスのふるい
                for (j = 1; pow(l[j],2) <= i; j++) {
                    if (i % l[j] == 0) {
                        k = 1;
                        break;
                    }
                }
                
                if (k == 0){
                    l[count++] = i;
                    //printf("l[%d] = %d\n",count - 1,l[count - 1]);//
                }
            }
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 912
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int INF = 1e8;
  
P ans;
  
int n,m;
char t[105][10005];
  
int func(int a,int b){
  return max(a,b)-min(a,b);
}
  
int main(){
  while(scanf("%d %d",&n,&m)!=EOF){
    for(int i=0;i<m;i++){
      scanf("%s",t[i]);
    }
    int w=0,e=0;
    int W=0,E=0;
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
        if(t[i][j]=='W')W++;
        else E++;        
      }
    }
     
    ans=P(W,0);
    //cout<<W<<' '<<E<<endl;
    for(int i=0;i<n;i++){      
      for(int j=0;j<m;j++){
        if(t[j][i]=='W'){
          W--;
          w++;
        }else{
          E--;
          e++;
        }
      }
      //cout<<i+1<<' '<<e<<' '<<W<<endl;
      ans=min(ans,P(e+W,i+1));
    }
    cout<<ans.second<<' '<<ans.second+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 4220
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;
    if (x + y < 10) {
        cout << x + y << "\n";
    } else {
        cout << "error\n";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
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 ll INF=1LL<<60;

int n;
vector<int> dp(100010);

int main(){
    cin>>n;
    
    for(int i=1;i<n;i++){
        for(int j=i;j<n;j++){
            for(int k=j;k<n;k++){
                int num=i*i+j*j+k*k+i*j+j*k+k*i;
                if(num>n) break;
                if(num<=n){
                    if(i==j && j==k) dp[num]++;
                    else if(i!=j && j!=k && k!=i) dp[num]+=6;
                    else dp[num]+=3;
                }
            }
        }
    }
    Exit:
        ;
    rep(i,n) cout<<dp[i+1]<<"\n";
    return 0;
}

Measured memory_bytes: 3676