akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
    int T; cin>>T;
    rep(_,0,T){
        int A,B,C,D; cin>>A>>B>>C>>D;
        if(D<B){
            cout<<"No"<<endl;
            continue;
        }
        int Y=__gcd(B,D);
        int Z=A-max(0ll,(A-C-1)/Y*Y);
        if(Z<B) cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
struct node
{
    int a,b;
}a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1;i <= n;++i){
        scanf("%d",&a[i].b);
        a[i].a=i;
    }
    map<int,int>mp;
    ll ans = 0;
    for(int i = 1;i <= n;++i){
        ans+=mp[a[i].a-a[i].b];
        mp[a[i].a+a[i].b]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 22244
#include <bits/stdc++.h>
int from_roman(const std::string &s){
    static const std::map<char, int> m = {
        { 'I', 1 },
        { 'V', 5 },
        { 'X', 10 },
        { 'L', 50 },
        { 'C', 100 },
        { 'D', 500 },
        { 'M', 1000 }
    };
    static const auto get = [&](char c) {
        return m.find(c)->second;
    };
    int n=0;
    for(int i = 0; i < (int)s.size(); ++i){
        if(i == n-1 || get(s[i]) >= get(s[i+1])) n += get(s[i]);
        else n -= get(s[i]);
    }
    return n;
}

// int to_roman(int n){
//     std::vector<std::pair<std::string, std::string>> res;
//     while(n){
//         int d = n % 10;

//     }
// }

using namespace std;
int main(){
    string n;
    while(cin >> n){
        cout << from_roman(n) << endl;
    }
}

Measured memory_bytes: 3184
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

*/

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define debug(x) cout<<#x<<": "<<x<<endl
#define For(i, st, en) for(ll i=st; i<en; i++)
#define rfor(i, st, en) for(ll i=st; i>=en; i--)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define printv(x) For(i, 0, x.size()){cout<<x[i]<<" ";} cout<<endl;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector< vector<int> > vvi;
typedef vector< pair<int, int> > vpi;
#define MAXN 300005
#define MOD 1000000007
#define INF 1000000000000000007


signed main(){
	fast
	int n, k;
	cin>>n>>k;
	vi v;
	int temp;
	For(i, 0, n){
		cin>>temp;
		v.pb(temp);
	}
	vpi vals(n+1, {0,0});
	For(i, 0, n){
		For(j, 0, n){
			if(j<i){
				if(v[j]<v[i]){
					(vals[i].F)++;
					(vals[i].F)%=MOD;
				}
			}else if(j>i){
				if(v[j]<v[i]){
					(vals[i].S)++;
					(vals[i].S)%=MOD;
				}
			}
		}
	}
	int ans=0;
	For(i, 0, n){
		// cout<<vals[i].F<<" "<<vals[i].S<<endl;
		int b = vals[i].S;
		int t = (b + vals[i].F)%MOD;
		int vv2 = ((k*(k-1))/2)%MOD;
		vv2 = (vv2%MOD * t%MOD)%MOD;
		ans = (ans%MOD + ((b*k)%MOD+vv2)%MOD)%MOD;
	}
	if(ans<0) ans+=MOD;
	cout<<ans<<endl;
    return 0;
}
    



Measured memory_bytes: 384
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
b = [(int(input())) for _ in range(N)]

bingo1 = [0, 0, 0]
bingo2 = [0, 0, 0]
bingo3 = [0, 0, 0]

# 穴を開ける工程
for i in range(3):
  for j in range(N):
    if A[i][0] == b[j]:
      bingo1[i] = 1
    if A[i][1] == b[j]:
      bingo2[i] = 1
    if A[i][2] == b[j]:
      bingo3[i] = 1
      

# ビンゴ判定
if bingo1[0] == bingo1[1] == bingo1[2] == 1:
    print("Yes")
elif bingo2[0] == bingo2[1] == bingo2[2] == 1:
    print("Yes")
elif bingo3[0] == bingo3[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[0] == bingo3[0] == 1:
    print("Yes")
elif bingo1[1] == bingo2[1] == bingo3[1] == 1:
    print("Yes")
elif bingo1[2] == bingo2[2] == bingo3[2] == 1:
    print("Yes")
elif bingo1[0] == bingo2[1] == bingo3[2] == 1:
    print("Yes")
elif bingo1[2] == bingo2[1] == bingo3[0] == 1:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3064
// SeeAlso: https://atcoder.jp/contests/abc089/tasks/abc089_c

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    int m,a,r,c,h;
    ll d[5];
    REP(i, 5) {
        d[i] = 0;
    }
    REP(i, n) {
        string s;
        cin >> s;

        if(s[0]=='M')d[0]++;
        if(s[0]=='A')d[1]++;
        if(s[0]=='R')d[2]++;
        if(s[0]=='C')d[3]++;        
        if(s[0]=='H')d[4]++;
    }
    
    ll ans = 0;
    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans += d[i] * d[j] * d[k];
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine((A + B) % 2 == 0 ? ((A + B) / 2).ToString() : "IMPOSSIBLE");
	}
	int A,B;
	public Sol(){
		var d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans = 0;
  rep(i,n){
    if(a[i] == i+1){
      if(i == n) swap(a[i-1],a[i]);
      else swap(a[i],a[i+1]);
      ans ++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<bitset>
using namespace std;

int main(void)
{
	string ABCD;
	cin >> ABCD;

	string ret;
	for(int i=1<<3; i>0; i--){
		bitset<3> op(i);

		int sum = ABCD[0] - '0';
		string str = string(1, ABCD[0]);
		for(int j=0; j<3; j++){
			if(op[j] == true){
				sum += ABCD[j+1] - '0';
				str += "+";
			}
			else{
				sum -= ABCD[j+1] - '0';
				str += "-";
			}

			str += string(1, ABCD[j+1]);
		}

		if(sum == 7){
			ret = str;
			break;
		}
	}

	ret += "=7";
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
import 'dart:io';

void main() {
  int n = int.parse(stdin.readLineSync());
  bool yes = false;
  for (int a = 0; a < n; a++) {
    for (int b = 0; b < n; b++) {
      int sum = 4 * a + 7 * b;
      if (sum == n) {
        print("Yes");
        yes = true;
        return;
      }
    }
  }
  if (yes == false) print("No");
}

Measured memory_bytes: 13036
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;

	if(a + b >= c)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <math.h>
#include <set>
#include <string>
#include <sstream>
#include <malloc.h>
using namespace std;

int main()
{
	string H;
	int n;
	cin>>H;
	for(size_t c = H.find_first_of("/"); c != string::npos; c = c = H.find_first_of("/")){
    H.erase(c,1);

	}
	istringstream ss = istringstream(H);
	ss>>n;
	if(n<=20190430)
	{
		cout<<"Heisei"<<endl;	
	}
	else
	{
		cout<<"TBD"<<endl;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  
  long long sum = 0;
  for(int i = 1; i <= n; i++){
	  if(i % 3 == 0 && i % 5 == 0) continue;
	  else if(i % 3 == 0) continue;
	  else if(i % 5 == 0) continue;
	  else sum += i;
  }
  
  cout << sum << "\n";
 
  return 0;
}




Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        for(int i = 0; i < 5; i++)
        {
            if(vars[i] == 0)
            {
                Console.WriteLine(i + 1);
                return;
            }
        }

    }
}

Measured memory_bytes: 28204
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
ll hp[100005],a,b,n;
bool nibu(int k)
{
  ll x,c=0;
  for(ll i=0;i<n;i++)
    {
      x=b*k;
      if(hp[i] > x)
	{
	  c+=(hp[i]-x)/(a-b);
	  if((hp[i]-x) %(a-b) !=0)c++;
	}
    }
  if(c > k)
    {
      return false;
    }
  else
    {
      return true;
    }
}
int main(int argc,char const* argv[])
{
  cin >> n >> a >> b;
  for(ll i=0;i<n;i++)
    {
      cin >> hp[i];
    }
  
  ll left=0,right=(1e9),center=(left+right)/2;

  while(right-left > 1)
    {
      if(nibu(center))
	{
	  right=center;
	  center=(left+right)/2;
	}
      else
	{
	  left=center;
	  center=(left+right)/2;
	}
    }
  cout << right << endl;
  return 0;
}


Measured memory_bytes: 1024
#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 <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    string S, T;
    cin >> S >> T;

    bool ok = T.substr(0, S.size()) == S;

    cout << (ok ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3644
a,b,x,y;c(int x,int y){if(!y){a=x;b=0;return;}c(y,x%y);b++;}main(){for(;;){scanf("%d%d",&x,&y);if(!x)return 0;if(x<y){a=y;y=x;x=a;}c(x,y);printf("%d %d\n",a,b);}}

Measured memory_bytes: 600
n = int(input())
tot = sum(range(1, n + 1))
a = 0
b = 0
c = 0
for i in range(1, n // 3 + 1):
    a += 3 * i
for i in range(1, n // 5 + 1):
    b += 5 * i
for i in range(1, n // 15 + 1):
    c += 15 * i
ans = tot - (a + b) + c
print(ans)


Measured memory_bytes: 9120
#include<iostream>
#include<algorithm>
#include <stdio.h>
using namespace std;
#define TREE_N (1<<17)

int ans,n,tree[ TREE_N * 2 -1];

void update(int i,int x){
  i+=TREE_N-1;
  tree[i]+=x;
  while(i>0){
    i=(i-1)/2;
    tree[i]=tree[i*2+1]+tree[i*2+2];
  }
}

void rec(int a,int b,int k=0,int l=0,int r=TREE_N){
  if((l<a&&a<r)||(l<b&&b<r)){
    int m=(l+r)/2;
    rec(a,b,k*2+1,l,m);
    rec(a,b,k*2+2,m,r);
  }else if(a<=l&&r<=b){
    ans+=tree[k];
  }
}

int Rec(int a,int b,int k=0,int l=0,int r=TREE_N){
  if((l<a&&a<r)||(l<b&&b<r)){
    int m=(l+r)/2;
    int left = Rec(a,b,k*2+1,l,m);
    int right = Rec(a,b,k*2+2,m,r);
    return min(left,right);
    
  }else if(a<=l&&r<=b){
    return tree[k];
  }else{
    return 2147483647;
  }
}

int main(){
  int q,com,a,b;
  cin>>n>>q;
  for(int i=1;i<=n;i++)update(i,0);
  for(int i=0;i<q;i++){
    cin>>com>>a>>b;
    if(com){
      ans=0;
      rec(a,b+1);
      printf("%d\n",ans);
    }
    else update(a,b);
  }
  return 0;
}

Measured memory_bytes: 3976
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 







int dp[200][200];
int x[100][100],y[100][100];
int main()
{
     int h,w;
     cin>>h>>w;
     int c[10][10];
     for(int i=0;i<=9;i++){
          for(int j=0;j<=9;j++)cin>>c[i][j];
     }
     for(int k=0;k<=9;k++){
          for(int i=0;i<=9;i++){
               for(int j=0;j<=9;j++){
                    if(c[i][j]>c[i][k]+c[k][j]){
                         c[i][j]=c[i][k]+c[k][j];
                    }
               }
          }
     }int a;
     ll res=0;
     for(int i=0;i<h;i++){
          for(int j=0;j<w;j++){
               cin>>a;
               if(a!=-1)
               res+=c[a][1];
          }
     }
     cout<<res;
}


























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

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K;
    cin >> K;
    ll sum = 0;

    for (ll i = 1; i <= K; i++) {
        for (ll j = 1; j <= K; j++) {
            for (ll k = 1; k <= K; k++) {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3656
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int temp;
		Scanner sc = new Scanner(System.in);
		// 整数の標準入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		// 数値比較
		if(a < b) {
			temp = a;
			a = b;
			b = temp;
		}
		if(b < c) {
			temp = b;
			b = c;
			c = temp;
		}
		if(a < b) {
			temp = a;
			a = b;
			b = temp;
		}
		// 結果出力
		System.out.println(10 * a + b + c);
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
#include<stack>
#include<vector>
#define VMAX 10000
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;

int n;
vector<int> adj[VMAX];
stack<int> ts;
int color[VMAX];

void dfs(int u) {
    color[u] = GRAY;

    for (int j=0; j<adj[u].size(); j++) {
        int v = adj[u][j];
        if (color[v]!=BLACK) {
            dfs(v);
        }
    }

    color[u] = BLACK;
    ts.push(u);
}

void topologicalSort() {
    int u;

    for (int j=0; j<n; j++) {
        if (color[j]!=BLACK) {
            dfs(j);
        }
    }

    while(!ts.empty()) {
        int n = ts.top();
        ts.pop();
        printf("%d\n", n);
    }

}

int main() {
    int s, t, E;

    scanf("%d %d", &n, &E);

    for (int i=0; i<n; i++) {
        color[i] = WHITE;
    }

    for (int i=0; i<E; i++) {
        scanf("%d %d", &s, &t);
        adj[s].push_back(t);
    }

    topologicalSort();

}


Measured memory_bytes: 3372
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

#p=1
res = 0
for i in range(n):
    res += abs(x[i]-y[i])
print(res)

#p=2
res = 0
for i in range(n):
    res += (x[i]-y[i])**2
print(res**0.5)

#p=3
res = 0
for i in range(n):
    res += (abs(x[i]-y[i]))**3
print(res**(1/3))

#p=inf
ma = 0
for i in range(n):
    tmp = abs(x[i]-y[i])
    if tmp > ma: ma = tmp
print(ma)


Measured memory_bytes: 5640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int l,i,j,n,k;
	int a[100009];
	cin>>n;
	long long int dp[n+1][n+1][2];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			dp[i][j][0]=0;
			dp[i][j][1]=0;
		}
	}
	for(l=1;l<=n;l++)
	{
		for(i=0;i<n-l+1;i++)
		{
		//for(j=i;j<n;j++)
		//{
		//	l=j-i+1;
			j=i+l-1;
			if(i==j)
			{
				dp[i][j][0]=a[i];
				dp[i][j][1]=0;
			}
			else
			{
				if(dp[i+1][j][1]+a[i]-dp[i+1][j][0] > dp[i][j-1][1]+a[j]-dp[i][j-1][0])
				{
					dp[i][j][0] = dp[i+1][j][1]+a[i];
					dp[i][j][1] = dp[i+1][j][0];
				}
				else
				{
					dp[i][j][0] = dp[i][j-1][1]+a[j];
					dp[i][j][1] = dp[i][j-1][0];
				}
			}
				
		}
	}
		cout<<dp[0][n-1][0]-dp[0][n-1][1]<<endl;
	return 0;
}


Measured memory_bytes: 140928
#include <iostream>
#include <complex>
#include <vector>
#include <set>
#include <cstring>
using namespace std;

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)
#define EREP(i,n,m) for(int i=n;i<=m;i++)
#define erep(i,n) EREP(i,0,n)

#define EPS (1e-8)

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0

typedef complex<double> P;

int par[100],rank[100]; //Union-Find

void init(int n){
	rep(i,n){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){
	if(par[x] == x)
		return x;
	else
		return par[x] = find(par[x]);
}

void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;

	if(rank[x] < rank[y])
		par[x] = y;
	else{
		par[y] = x;
		if(rank[x] == rank[y]) rank[x]++;
	}
}

double dot(P a,P b){
	return (a.real() * b.real() + a.imag() * b.imag());
}

double cross(P a,P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

int ccw(P p0,P p1,P p2){
	P a = p1 - p0;
	P b = p2 - p0;
	if(cross(a,b) > EPS) return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS) return CLOCKWISE;
	if(dot(a,b) < -EPS) return ONLINE_BACK;
	if(abs(a) < abs(b)) return ONLINE_FRONT;
	return ON_SEGMENT;
}

bool intersect_ls_ls(P p1,P p2,P p3,P p4){
	return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0 &&
					ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0);
}

bool inside_p_pol(vector<P> pol,P p){
	rep(i,4){
		if(ccw(pol[i],pol[(i+1)%4],p) == COUNTER_CLOCKWISE) return false;
	}
	return true;
}

bool intersect_pol_pol(vector<P> p1,vector<P> p2){
	rep(i,3) rep(j,3) {
		if(intersect_ls_ls(p1[i],p1[i+1],p2[j],p2[j+1])) return true;
	}
	rep(i,4) if(inside_p_pol(p1,p2[i])) return true;
	rep(i,4) if(inside_p_pol(p2,p1[i])) return true;
	return false;
}

int main(void){
	int n;

	while(cin>>n,n) while(n--) {
		int m; cin>>m;
		vector<P> pol[m];
		init(m);

		rep(i,m){
			rep(j,4){
				P p; cin>>p.real()>>p.imag();
				pol[i].push_back(p);
			}
			rep(j,i) if(intersect_pol_pol(pol[i],pol[j])) unite(i,j);
		}

		set<int> ans;
		rep(i,m) ans.insert(find(i));
		cout<<ans.size()<<endl;
	}

	return 0;
}

Measured memory_bytes: 988
def main():

    n, w = map(int, input().split())

    INF = 10 ** 20
    dp = [INF] * (n * 100001)
    dp[0] = 0

    max_vi = 0
    for _ in range(n):
        wi, vi = map(int, input().split())
        max_vi += vi

        for vj in range(max_vi + 1, vi - 1, -1):
            nw = dp[vj - vi] + wi
            if dp[vj] > nw:
                dp[vj] = nw

    for i in range(max_vi, -1, -1):
        if dp[i] <= w:
            print(i)
            return

main()


Measured memory_bytes: 83060
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<deque>
#include<cstdio>
#include<ctime>
#include<bitset>
#include<vector>
#include<climits>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL long long
#define ULL unsigned long long
LL read(){
	LL f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return f*x;
}
#define Mod 2019
#define MAXN 100000
#define INF 0x3f3f3f3f
LL A[MAXN+5],M[MAXN+5];
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		A[i]=read();
		M[1]+=((i&1)?1:-1)*A[i];
	}
	for(int i=2;i<=n;i++)
		M[i]=2*A[i-1]-M[i-1];
	for(int i=1;i<n;i++)
		printf("%lld ",M[i]);
	printf("%lld\n",M[n]);
	return 0;
}

Measured memory_bytes: 2816
#include<stdio.h>

int n;
int a[20][20];

void rot(int r, int c, int size, int angle){
  int time = angle/90, i;
  for(i=0;i<time;i++){
    int temp[20][20];
    int j, k;
    for(j=0;j<n;j++){
      for(k=0;k<n;k++) temp[j][k] = a[j][k];
    }
    int l=r-1;
    for(j=size-1;j>=0;j--){
      for(k=0;k<size;k++) a[r-1+k][c-1+j] = temp[l][c-1+k];
      l++;
    }
  }
  return;
}

void rev(int r, int c, int size){
  int i, j;
  for(i=r-1;i<r+size-1;i++){
    for(j=c-1;j<c+size-1;j++) a[i][j] = (a[i][j]+1)%2;
  }
  return;
}

void shf(int r, int o){
  int lr;
  if(o==2) lr=1;
  else lr=-1;

  int i, temp[n];
  for(i=0;i<n;i++) temp[i]=a[r-1][i];
  for(i=0;i<n;i++){
    a[r-1][i] = temp[(i+lr+n)%n];
  }
  return;
}


void irev(int r, int c, int is){
  int ser[4]={0, 1, 0, -1};
  int i;
  a[r][c] = is;
  for(i=0;i<4;i++){
    int nr = r+ser[i], nc = c+ser[i^1];
    if(a[nr][nc]!=is && nr>=0 && nc>=0 && nr<n && nc<n){
      irev(nr, nc, is);
    }
  }    
  return;
}

int main(){
  int m;
  scanf("%d %d", &n, &m);
  int i, j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) scanf("%d", &a[i][j]);
  }

  int ope;
  for(ope=0;ope<m;ope++){
    int o;
    scanf("%d", &o);

    if(o==0){
      int r, c, size, angle;
      scanf("%d %d %d %d", &r, &c, &size, &angle);
      rot(r, c, size, angle);
    }
    else if(o==1){
      int r, c, size;
      scanf("%d %d %d", &r, &c, &size);
      rev(r, c, size);
    }
    else if(o==2 || o==3){
      int r;
      scanf("%d", &r);
      shf(r, o);
    }
    else if(o==4){
      int r, c;
      scanf("%d %d", &r, &c);
      irev(r-1, c-1, (a[r-1][c-1]+1)%2);
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) printf("%d%c", a[i][j], " \n"[j==n-1]);
  }
  return 0;
}
  



Measured memory_bytes: 2144
#include <bits/stdc++.h>
 
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
 
signed main() {
    FAST_IO;
 
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

    int dp[n + 1][3]; // dp[i][j] : i represents the day and j represents the activity
    				  // j is 0 for activity A, 1 for activity B and 2 for activity C

  	// Set the base values
    dp[0][0] = a[0]; // If you swim in the sea in sea on the first day, you cannot get more than a[0] points.
    dp[0][1] = b[0]; // If you catch bugs in the mountains on the first day, you cannot get more than b[0] points.
    dp[0][2] = c[0]; // If you do homework at home on the first day, you cannot get more than c[0] points.

    // i represents what day it is (0 based indexing)
    for (int i = 1; i < n; i++) { 
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]); // If we do activity A today, we have to have done activities B or C on the previous day.
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]); // If we do activity B today, we have to have done activities A or C on the previous day.
        dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]); // If we do activity C today, we have to have done activities A or B on the previous day.
    }

  	// Our answer is the maximum of all the points gained by doing activity A, B, or C on the last day.
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}); 
    return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	string s;
	cin >> s;
	s[5] = ' ';
	s[13] = ' ';

	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

int longestPathHelper(const vector<vector<int>> &edges, int currentVertex,
                      vector<int> &maxCosts) {
  const auto &edge = edges[currentVertex];
  for (const auto i : edge) {
    // If we haven't calculated max cost from this vertex, then do it now.
    if (maxCosts[i] == 0) {
      longestPathHelper(edges, i, maxCosts);
    }
    // Cost for our vertex is max of all connecting vertices PLUS ONE.
    maxCosts[currentVertex] = max(maxCosts[currentVertex], maxCosts[i] + 1);
  }
  return maxCosts[currentVertex];
}

int main() {
  vector<vector<int>> edges;
  int numVertices, numEdges;
  cin >> numVertices >> numEdges;
  edges.resize(numVertices);
  for (int i = 0; i < numEdges; ++i) {
    int x, y;
    cin >> x >> y;
    assert(x <= edges.size());
    edges[x - 1].push_back(y - 1);
  }
  // cost[i] = max(cost[i], runningCost + 1)
  vector<int> maxCosts;
  maxCosts.resize(numVertices, 0);
  for (size_t i = 0; i < edges.size(); ++i) {
    longestPathHelper(edges, i, maxCosts);
  }
  cout << *max_element(maxCosts.begin(), maxCosts.end()) << endl;
  return 0;
}


Measured memory_bytes: 8832
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[3010][3010];
int v[3010];

int dfs(int l,int r,int f){
	if(l>=r) return (f?v[l]:-v[l]);
	if(dp[l][r]!=-1) return dp[l][r];
	if(f) dp[l][r]=max(dfs(l+1,r,!f)+v[l],dfs(l,r-1,!f)+v[r]);
	else  dp[l][r]=min(dfs(l+1,r,!f)-v[l],dfs(l,r-1,!f)-v[r]);
	//cerr<<l<<" "<<r<<" "<<dp[l][r]<<"\n";
	return dp[l][r];
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	For(i,0,n-1) For(j,0,n-1) dp[i][j]=-1;
	For(i,0,n-1) cin>>v[i];
	cout<<dfs(0,n-1,true)<<"\n";
	return 0;
}


Measured memory_bytes: 71040
use proconio::input;
use proconio::marker::{Bytes, Chars, Isize1, Usize1};

fn main() {
    input! {
        cs: Chars
    }


    let ans = {
        let mut ans = 0;
        let mut now = 0;
        let mut day = 0;
        while day <= 2 {
            if cs[day] == 'R' {
                now += 1;
            } else {
                ans = ans.max(now);
                now = 0;
            }
            day += 1;
        }
        ans = ans.max(now);
        ans
    };

    println!("{}",ans)
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

ll tri(ll n) {
    for(ll i = 1; ; ++i) {
        if(i*(i+1)/2 > n) {
            return i-1;
        } 
    }
}

ll prime(ll n) {
    map<ll, ll> res;
    while(n%2==0) {
        n/=2;
        res[2]+=1;
    }

    for(ll i =3; i*i<=n; ++i) {
        while(n%i==0) {
            n/=i;
            res[i]++;
        }
    }

    if(n>2) {
        res[n]++;
    }

    ll ans = 0;
    for(auto& it : res) {
        ans += tri(it.second);
    }
    return ans;
}

int main() 
{ 
    fastio
    ll n;
    cin>>n;
    cout<<prime(n)<<endl;
} 

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>

int main() {
	int m, f, r;
	char rank[5][2] = {"A", "B", "C", "D", "F"};
	int flug;
	while (1) {
		scanf("%d%d%d", &m, &f, &r);
		if (m + f + r == -3)break;
		if (m + f >= 80) flug = 0;
		else if (m + f >= 65) flug = 1;
		else if (m + f >= 50) flug = 2;
		else if (m + f >= 30 && r >= 50) flug = 2;
		else if (m + f >= 30 && r <= 50) flug = 3;
		else flug = 4;
if(m==-1||f==-1) flug = 4;
		printf("%s\n", rank[flug]);
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    vector<int> vc(3);
    cin >> vc[0] >> vc[1] >> vc[2];
    sort(vc.begin(), vc.end());
    cout << vc[0] * vc[1] / 2;
}



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

#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,l,r) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define ri(n) scanf("%d",&n)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<char,int> pci;
typedef tuple<int, int, int> tiii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const ll INF = LONG_LONG_MAX;
const int MAXN = 21;
const int mod = 1e9+ 7;

int can[MAXN][MAXN];
ll dp[MAXN][int(1<<MAXN)];
int allmask;

int n;

ll go(int idx, int mask){
    if(idx == n) return (mask == allmask);
    ll &r = dp[idx][mask];
    if(r!=-1) return r;
    r= 0;
    for(int i=0; i<n; ++i){ // i es mujeres, idx es hombres
        if(!((1<<i)&mask) && can[idx][i]){
            r+= go(idx+1, mask|(1<<i));
            r%=mod;
        }
    }
    return r;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>> n;
    memset(dp, -1, sizeof dp);
    forn(i,n){
        forn(j,n){
            cin>> can[i][j];
        }
    }
    allmask = (1<<n)-1;
    cout<< go(0,0)<<el;

}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int n;	cin >> n;
	ll x = 0;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		x ^= a[i];
	}
	for (int i = 0; i < n; i += 1) {
		ll ans = x^a[i];
		cout << ans << " ";
	}
	return 0;
}

Measured memory_bytes: 3960
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int n,a[220],ans=0 ;
    scanf ("%d",&n);
    for (int i=0; i<n*2; i++){
        scanf ("%d",&a[i]) ;
    }
    for (int i=0; i<n*2; i++){
        for (int j=i+1; j<n*2; j++){
            int tmp=0;
            if (a[i]<a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    for (int i=0; i<n*2; i++){
        if (i%2==1){
            ans+=a[i];
        }
    }
    printf ("%d\n",ans);
    return 0 ;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() 
{
  lli A,B,K;
  cin >>A>>B>>K;
  if(A>=K){
  cout<<A-K<<" "<<B<<endl;
  }
  else if(A+B>=K){
  cout<<0<<" "<<A+B-K<<endl;
  }
  else
  cout<<0<<" "<<0<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main()
{
    int n,i,j,k;
    cin>>n;
    int a[n],cnt=0;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=0; i<n-2; i++)
    {
        for(k=i+1; k<n-1; k++)
        {
            for(j=k+1; j<n; j++)
            {
                if(a[i]==a[k]||a[k]==a[j]||a[i]==a[j])
                {
                    continue;
                }
                else if(a[i]+a[k]>a[j]&&a[i]+a[j]>a[k]&&a[j]+a[k]>a[i])
                {
                    cnt++;
                }

            }
        }
    }
    cout<<cnt<<endl;
}



Measured memory_bytes: 3196
l=gets.to_i;n=l.bit_length;p n,n*2+l.to_s(2).count(?1)-3;(n-1).times{|i|p i+1,i+2,0,i+1,i+2,1<<i;l[i]==1&&p(i+1,n,l-=1<<i)}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef signed long long lint;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  vector< int > p(n);
  for (int i=0; i<n; ++i) cin >> p[i];
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i=0; i<k; ++i) ans += p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long


using namespace std;

int v[100002];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++)
        cin >> v[i];
    sort(v + 1, v + n + 1);
    ll ans = 0, a, b;
    a = b = 0;
    i = 1;
    while(i <= n) {
        if(i < n && v[i] == v[i + 1]) {
            a = b;
            b = v[i];
            i += 2;
        }
        else
            i++;
    }
    cout << a * b;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		return cnt < 1;
		// return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		String ans = str;
		for (;;) {
			int n = 0;
			for (char c : ans.toCharArray()) {
				if (c == '(')
					n++;
				else if (c == ')')
					n--;
				if (n < 0)
					break;
			}
			if (n == 0)
				break;
			else if (n < 0)
				ans = "(" + ans;
			else {
				for (int i = 0; i < n; i++)
					ans = ans + ")";
			}
		}
		System.out.println(ans);
		cnt++;
	}
}


Measured memory_bytes: 22996
<?php
	$output = array();
	while( true ) {
		list( $m, $f, $r ) = explode( ' ', trim( fgets( STDIN ) ) );
		if( -1 == $m && -1 == $f && -1 == $r ) { break; }
		
		$sum = $m + $f;
        if( -1 == $m || -1 == $f ) {
            array_push( $output, 'F' );
        } else if( 80 <= $sum ) {
            array_push( $output, 'A' );
        } else if( 65 <= $sum && $sum < 80 ) {
            array_push( $output, 'B' );
        } else if( 50 <= $sum && $sum < 65 ) {
            array_push( $output, 'C' );
        } else if( 30 <= $sum && $sum < 50 ) {
            if( 50 <= $r ) {
                array_push( $output, 'C' );
            } else {
                array_push( $output, 'D' );
            }
        } else {
            array_push( $output, 'F' );
        }
    }
	print implode( "\n", $output );
?>

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

#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)

#define ll long long

#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));

int main(){
	ll N;
  cin >> N;
  ll count = 0,c = N - 1,d = N - 1;
  for(ll a = 1;a < N;a++){
    c = d;
    for(ll b = c;b > 0;b--){
      
      if(a*b < N){ count += b;
                  d = b;
                  break;
                 }
      
      
    }
    if(a > N / 2){ count += N - a - 1;
    break;
                 }
  }
  
  cout << count<< endl;
return 0;
}

Measured memory_bytes: 3628
def f(a):
    i = 1
    r = 1 if a % 4 in (1, 2) else 0
    t = a & 1
    a >>= 1
    while a:
        t |= (a & 1) << i
        if a & 1:
            r |= ((t % (1 << i) + 1) & 1) << i
        a >>= 1
        i += 1
    return r

def main():
    A, B = map(int, input().split())
    if A == 0:
        A += 1
    print(f(A - 1) ^ f(B))

main()


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;
//typedef pair<int,int> P;
 
 int main(void){
	 map<string,int> s;
	 int N;
	 cin >> N;
	 for(int k=0;k<N;k++){
		 string str;
		 cin >>str;
		 s[str]++;
	 }
	 cout << s.size()<<endl;
 }

Measured memory_bytes: 19228
#include <iostream>
#include <cstdio>
#include <cmath>
#include <complex>
using namespace std;

#define EPS			(1e-10)
#define X(a)		(a).real()
#define Y(a)		(a).imag()
#define UNIT(a)		( (a)/abs(a) )
#define NORM(a)		( (a)*P(0,1) )


typedef complex<double> P;

double dot(P a, P b)
{
	return ( X(a)*X(b) + Y(a)*Y(b) );
}

double cross(P a, P b)
{
	return ( X(a)*Y(b) - Y(a)*X(b) );
}

double distPL(P p, P a, P b)
{
	return ( abs(cross(b-a, p-a))/abs(b-a) );
}

P symPL(P p, P a, P b)
{
	P v = UNIT(b-a);
	v *= ( cross(v,p-a)>0 ?  P(0,-1) : P(0,1) );

	return p+2.0*v*distPL(p,a,b);
}

int main()
{
	P a,b,p,s; char c;
	while(cin >> X(a))
	{
		cin >> c >> Y(a);
		cin >> c >> X(b);
		cin >> c >> Y(b);
		cin >> c >> X(p);
		cin >> c >> Y(p);

		s = symPL(p,a,b);

		printf("%.6lf %.6lf\n",X(s),Y(s));
	}

}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

#define REP(i, n) for (size_t i = 0; i < (n); ++i)

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using vi = vector<int>;
using vsz = vector<size_t>;

bool ok (vi const &a, int X)
{
    return a.end () ==
           find_if (a.begin (), a.end (), [X] (int x) { return x < X; });
}

struct TextBook {
    int c;
    vi a;
    TextBook (int M) : c (0), a (M) {}
    TextBook &operator+= (TextBook const &rhs)
    {
        c += rhs.c;
        REP (i, a.size ()) a[i] += rhs.a[i];
        return *this;
    }
    TextBook operator+ (TextBook const &rhs)
    {
        TextBook ret = *this;
        ret += rhs;
        return ret;
    }
};

i64 f (TextBook select, int i, vector<TextBook> const &textbook, int X)
{
    if (ok (select.a, X)) {
        return select.c;
    }
    size_t N = textbook.size ();
    if (N <= i) {
        // 最後まで足したが ok じゃない
        return -1;
    }
    auto c0 = f (select, i + 1, textbook, X);
    auto c1 = f (select + textbook[i], i + 1, textbook, X);
    if (0 <= c0 && 0 <= c1) {
        return min (c0, c1);
    } else if (0 <= c0) {
        return c0;
    } else if (0 <= c1) {
        return c1;
    } else {
        return -1;
    }
}

int main ()
{
    int N, M, X;
    cin >> N >> M >> X;
    vector<TextBook> textbook (N, TextBook (M));
    vi critical (M);
    REP (i, N)
    {
        cin >> textbook[i].c;
        REP (j, M)
        {
            cin >> textbook[i].a[j];
            critical[j] += textbook[i].a[j];
        }
    }
    if (!ok (critical, X)) {
        // すべて足しても足りない
        cout << -1;
        return 0;
    }
    auto minimum = f (TextBook (M), 0, textbook, X);
    cout << minimum;
}


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

int main(){
	string week[] = {"Wednesday","Thursday","Friday","Saturday","Sunday", "Monday","Tuesday"};
	while(1){
		int a, b;
		cin >> a >> b;
		if(a == 0) break;
		int day = 1, c = 1, d = 1;
		while(1){
			if(a == c && b == d) break;
			day++;
			d++;
			if(c == 1 && d == 32 ||
				c == 2 && d == 30 ||
				c == 3 && d == 32 ||
				c == 4 && d == 31 ||
				c == 5 && d == 32 ||
				c == 6 && d == 31 ||
				c == 7 && d == 32 ||
				c == 8 && d == 32 ||
				c == 9 && d == 31 ||
				c == 10 && d == 32 ||
				c == 11 && d == 31){
				c++;
				d = 1;
			}
		}
		cout << week[day % 7] << endl;
	}
	return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    unsigned int num, x=1;
    cin >> num;
    int p = pow(10,9)+7;
    for(int i=1; i<=num; i++){
        x = (long long)i*x%p;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){
}

Node treeSearch(Node u, int k){

  if (u == NIL || k == u->key)
    return u;

  if(k < u->key)
    return treeSearch(u->left, k);
else
  return treeSearch(u->right, k);
  }

Node treeSuccessor(Node x){
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key)
      x=x->left;
    else
      x=x->right;
  }
  z->parent=y;
   

  if (y == NIL)
    root=z;
  else if (z->key < y->key)
    y->left=z;
  else
    y->right=z;
}

void inorder(Node u){
  if( u != NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder( u->right);
  }
}

void preorder(Node u){
  if( u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


  int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
n = int(input())
a = [int(input()) for i in range(n)]

ok = True
rg = range(n)
l = 0
for i,d in zip(rg,a):
    if i*10 > l:
        ok = False
        break
    if l >= (n-1)*10:
        break
    if i*10+d > l:
        l = i*10+d

a.reverse()
l = 0
for i,d in zip(rg,a):
    if i*10 > l:
        ok = False
        break
    if l >= (n-1)*10:
        break
    if i*10+d > l:
        l = i*10+d

if ok:
    print('yes')
else:
    print('no')


Measured memory_bytes: 17452
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        //string input= Console.ReadLine();
        int input =int.Parse(Console.ReadLine());
        Console.WriteLine(input<1200?"ABC":"ARC");


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 11092
mod = 10 ** 9 + 7
N = int(input())
A = list(map(int,input().split()))
B = [A[0] % mod]
for i in range(N-1):
    B.append((B[-1] + A[i+1]) % mod)
ans = 0
for i in range(N-1):
    ans += A[-i-1] * B[-i-2]
    ans %= mod

print(ans)

Measured memory_bytes: 31608
#include <iostream>
using namespace std;
int main(void){
    int H,W;
    
    for(int i = 0;i < 10000;i++){
        
        cin >> H >> W;
        
        if(H == 0 && W == 0){break;}
        
       for(int h =0;h < H;h++){
           
           for (int w = 0;w < W;w++)
           {
               cout << "#";
           }
           
           cout << endl;
       }
        cout << endl;
    }
}



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

int main()
{
  int N, K;
 cin >> N >> K;
  char line[50], a;
  for(int i=0;i<N;i++)
  {
   	cin >> line[i];
  }

  if(line[K-1] == 'A') line[K-1] = 'a';
  else if(line[K-1] == 'B') line[K-1] = 'b';
  else if(line[K-1] == 'C') line[K-1] = 'c';

  for(int i=0;i<N;i++)
  {
   	cout << line[i]; 
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256