akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

const long long int MOD = 1e9 + 7;

int main(){
  
  // read problem
  long long int H, W;
  std::vector<std::string> a;
  std::string line;
  
  scanf("%lld%lld", &H, &W);
  for(long long int i = 0; i < H; i++){
    std::cin >> line;
    a.push_back(line);
  }
  
  // solve problem
  std::vector<std::vector<long long int> > dp_table(H);
  for(long long int i = 0; i < H; i++){
    for(long long int j = 0; j < W; j++){
      dp_table[i].push_back(0);
    }
  }
  
  for(long long int j = 0; j < W; j++){
    if(a[0][j] == '.'){
      dp_table[0][j] = 1;
    }
    else break;
  }
  
  for(long long int i = 1; i < H; i++){
    if(a[i][0] == '.'){
      dp_table[i][0] = 1;
    }
    else break;
  }
  
  for(long long int i = 1; i < H; i++){
    for(long long int j = 1; j < W; j++){
      // if the cell (i, j) is a wall cell
      if(a[i][j] == '#'){
        dp_table[i][j] = 0;
      }
      // if the cell (i, j) is a empty cell
      else{
        dp_table[i][j] = (dp_table[i][j-1] + dp_table[i-1][j])%MOD;
      }
    }
  }
  
  std::cerr << "Answer: " << std::endl;
  std::cout << dp_table[H-1][W-1] << std::endl;
  
  return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
bool test(int a1, int a2, int a3, set<int>& B) {
  return B.count(a1) && B.count(a2) && B.count(a3);
}
int main() {
  vector<vector<int> > A(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> A[i][j];
  int N;
  cin >> N;
  set<int> B;
  rep(i, N) {
    int b;
    cin >> b;
    B.insert(b);
  }
  rep(i, 3) {
    if(test(A[i][0], A[i][1], A[i][2], B)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  rep(i, 3) {
    if(test(A[0][i], A[1][i], A[2][i], B)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if(test(A[0][0], A[1][1], A[2][2], B) ||
     test(A[0][2], A[1][1], A[2][0], B)) {
      cout << "Yes" << endl;
      return 0;
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

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

    vector<long> values(n+1);
    vector<long> weights(n+1);
    for (int i = 1; i <= n; i++) {
      cin >> weights[i];
      cin >> values[i];
    }
    vector<vector<long> > knapsack(n+1, vector<long>(W+1, 0));
    for (int i = 1; i <= n; i++) {
      for (int w = 1; w <= W; w++) {
        if (w >= weights[i]) {
          knapsack[i][w] = knapsack[i-1][w-weights[i]] + values[i];
        }
        knapsack[i][w] = max(knapsack[i][w], knapsack[i-1][w]);
      }
    }
    cout << knapsack[n][W] << endl;
    return 0;
}


Measured memory_bytes: 80256
import math
a,b,x = map(int,input().split())
x /= a
if x >= a*b/2:
    print(math.atan(2/(a**2)*(a*b-x))/math.pi*180) 
else:
    print(90-(math.atan((2*x/b**2))/math.pi*180))

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

const long long mod = 1e9+7;

long long A[10010];
long long prime[1015];
 
void isPrime(){
	for(int i=0;i<1005;++i)
		prime[i]=true;
	
	prime[1]=false;
	for(int i=1;i*i<1005;i++){
		if(prime[i]){
			for(int j=2*i;j<1005;j+=i){
				if(prime[j]){
					prime[j]=false;
				}
			}
		}
	}
	
	return;
}


int main(){
	isPrime();
	long long n,a,ans=1;
	
	cin >> n;
	for(int i=2;i<=n;i++){
		a=i;	
		for(int k=2;k<=1000;k++){
			if(a==1) break;
			if(prime[k]){
				while(1){
					if(a%k==0){
						a/=k;
						A[k]++;
					}
					else break;
				}
			}
		}
	
	}
	
	
	for(int i=0;i<=1000;i++){
		if(A[i]){
			ans = (ans*(A[i]+1))%mod;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N,a[100],i,j,k,temp;
	
	scanf("%d",&N);
	
	for(i=0;i<N;i++) scanf("%d",&a[i]);
	for(i=0;i<N-1;i++) printf("%d ",a[i]);
	printf("%d\n",a[i]);
	
	for(i=1;i<N;i++){
		temp = a[i];
		j = i-1;
		while(j >= 0 && a[j] > temp){
			a[j+1] = a[j];
			j--;
			a[j+1] =temp;
		}
		for(k=0;k<N-1;k++) printf("%d ",a[k]);
		printf("%d\n",a[k]);
	}
	return 0;
}

Measured memory_bytes: 600
s = input()

cnt = 0
li = []
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        cnt += 1
    else:
        li.append(cnt)
        cnt = 0

li.append(cnt)
print(max(li))

Measured memory_bytes: 9040
S=input()
Q=int(input())
c=0
left=""
right=""
for i in range(Q):
    T=list(map(str,input().split()))
    if len(T)==1:
        c+=1
    else:
        if (T[1]=="1" and c%2==0) or (T[1]=="2" and c%2==1):
            left+=T[2]
        else:
            right+=T[2]

if c%2==0:
    ans=left[::-1]+S+right
else:
    ans=right[::-1]+S[::-1]+left
print(ans)

Measured memory_bytes: 4340
s = gets.chomp

i = s.to_i(2)
if s.size.even?
  j = ('01'*(s.size/2)).to_i(2)
  k = ('10'*(s.size/2)).to_i(2)
else
  j = ('01'*(s.size/2) + '0').to_i(2)
  k = ('10'*(s.size/2) + '1').to_i(2)
end

puts [(i ^ j).to_s(2).count('1'), (i ^ k).to_s(2).count('1')].min


Measured memory_bytes: 2684
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main(){
	int h,w,i,j;
	cin>>h>>w;
	for(i=0;i<w+2;i++){
		cout<<'#';
	}
	cout<<endl;
	for(i=0;i<h;i++){
		cin>>s;
		cout<<'#'<<s<<'#'<<endl;
	}
	for(int i=0;i<w+2;i++) cout<<'#';
	return 0; 
} 

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

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;

const int MAX_N = 110;
const int MAX_V = 100100;

int N;
long long W, weight[MAX_N], value[MAX_N];

long long dp[MAX_N][MAX_V];

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) cin >> weight[i] >> value[i];
  
  for (int i = 0; i < MAX_N; i++) for (int j = 0; j < MAX_V; j++) dp[i][j] =INF;
  
  dp[0][0] = 0;
  
  for (int i = 0; i < N; i++) {
    for (int sum_v = 0; sum_v <= MAX_V; sum_v++) {
      if (sum_v - value[i] >= 0) {
        chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
      }
      chmin(dp[i + 1][sum_v], dp[i][sum_v]);      
    }
  }
  long long res = 0;
  for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
    if (dp[N][sum_v] <= W) res = sum_v;
  }    
  cout << res << endl;
}
    


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

int a[111111];
pair<int, int> b[111111];
int main() {
	int n, m, x = 0;
	long s = 0;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i), s += a[i];
	sort(a, a + n);
	for (int i = 0; i < m; i++)
		scanf("%d%d", &b[i].second, &b[i].first);
	sort(b, b + m, greater<>());
	for (int i = 0; i < n; i++) {
		if (!b[x].second)
			x++;
		if (x == m) break;
		if (b[x].first > a[i])
			b[x].second--, s += b[x].first - a[i];
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	cin >> n;
	rep(tt,n){
		string m,s;
		cin >> m >> s;
		rep(ii,m.size()){
			int i=m.size()-1-ii;
			if(m[i]=='A'){
				reverse(s.begin(),s.end());
			}
			if(m[i]=='C'){
				s+=s[0];
				s=s.substr(1,s.size()-1);
			}
			if(m[i]=='J'){
				s=s[s.size()-1]+s;
				s=s.substr(0,s.size()-1);
			}
			if(m[i]=='E'){
				string l,r;
				if(s.size()%2==0){
					l=s.substr(0,s.size()/2),r=s.substr(s.size()/2,s.size()/2);
					s=r+l;
				}else{
					l=s.substr(0,s.size()/2),r=s.substr(s.size()/2+1,s.size()/2);
					s=r+s[s.size()/2]+l;
				}
			}
			if(m[i]=='P'){
				rep(j,s.size()){
					if(isdigit(s[j])){
						if(s[j]=='0') s[j]='9';
						else s[j]--;
					}
				}
			}
			if(m[i]=='M'){
				rep(j,s.size()){
					if(isdigit(s[j])){
						if(s[j]=='9') s[j]='0';
						else s[j]++;
					}
				}
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

map< ll, int > prime_factor(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n; cin >> n;
  auto p = prime_factor(n);
  ll ans = 0;
  for(auto q : p){
    ll e = q.second;
    ll cnt = 1;
    while(1){
      if(e - cnt < 0) break;
      e -= cnt;
      ans++;
      cnt++;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3656
k = input()
s = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
row = s.split(', ')
print(row[int(k)-1])


Measured memory_bytes: 2940
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


int N, a[100001], cnt;

int main(void) {
  cin >> N;
  REP(i, 1, N + 1) {
    cin >> a[i];
  }

  cnt = 0;
  REP(i, 1, N + 1) {
    if(a[a[i]] == i) cnt++;
  }

  cout << cnt / 2 << endl;

  return 0;
}


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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            c = (x - a) % b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <stdio.h>

int main(){
	long long int n;
	long long int ctr = 0;
	scanf("%lld", &n);
	for(int i = 1; i <= n; i++){
		if(i%3 == 0 || i%5 == 0){
			continue;
		}
		else{
			ctr+=i;
		}
	}
	printf("%lld", ctr);
	return 0;
}

Measured memory_bytes: 1724
def distance(p1,p2):
    return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

M,N=[int(x) for x in input().split()]

student=[]
check=[]
for i in range(0,M):
    a,b=[int(x) for x in input().split()]
    student.append((a,b))

for j in range(0,N):
    c,d=[int(x) for x in input().split()]
    check.append((c,d))


for i in range(0,M):
    dist=distance(student[i],check[N-1])
    num=N-1
    for j in range(0,N):
        k=N-j-1
        if dist>=distance(student[i],check[k]):
            dist=distance(student[i],check[k])
            num=k
    print(num+1)


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#include <bitset>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
string s;
int x, y;
vector<int> compress;
bitset<16001> xbit, ybit;
/**********************************************/

signed main(){
    cin >> s;
    cin >> x >> y;
    
    compress.pb(0);
    REP(i, s.size()){
        if(s[i] == 'T') compress.pb(0);
        else compress.back()++;
    }

    xbit[8000 + compress.front()] = true;
    ybit[8000] = true;

    FOR(i, 1, compress.size()){
        if(i%2 == 0){
            xbit = (xbit << compress[i]) | (xbit >> compress[i]);
        }else{
            ybit = (ybit << compress[i]) | (ybit >> compress[i]);
        }
    }

    if(xbit[8000 + x] && ybit[8000 + y]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;

int main(){
    string S;
    cin>>S;
    vector<int> vsa=suffix_array(S);
    vector<int> vlc=lcp_array(S,vsa);

    long long sum=0;
    for(long long i=0;i<vlc.size();i++){
        sum+=(i+1)-(long long)vlc[i];
    }
    cout<<sum+S.size()<<endl;
}


Measured memory_bytes: 15668
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,sum,Highest;
  sum=0;
  Highest=0;
  cin>>N;
  
  for(int i=0;i<N;i++){
    int H;
    cin>>H;
    if(H>=Highest){
      sum++;
      Highest=max(Highest,H);
    }else{
      sum+=0;
      Highest=Highest;
    }
  }
  cout<<sum<<endl;  
}
  


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

int main(){
	long long N;
	cin >> N;
	vector<int> v;
	while(N != 0){
		int rest = N % (-2);
		if(rest == -1){
			rest = 1;
			N = N / (-2) + 1;
		}
		else N /= -2;
		v.push_back(rest);
	}
	for(int i = (int)v.size() - 1;i>=0;i--){
		cout << v[i];
	}
	if((int)v.size() == 0) cout << 0;
	cout << endl;
}

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

int main(){
  int N,M; 
  cin >>N>>M;
  
  int a[N],b[N];
  rep(i,N) cin >>a[i]>>b[i];
  
  int c[M], d[M];
  rep(i,M) cin >>c[i]>>d[i];

  int ans;
  rep(i,N){
    int mnD = abs(a[i]-c[0]) + abs(b[i]-d[0]);
    ans = 1;
    rep(j,M){
      int D = abs(a[i]-c[j]) + abs(b[i]-d[j]);
      if(D<mnD){
        ans = j+1;
        mnD = D;
      }
    }
    cout <<ans<< endl;
  } 
}

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

using namespace std;

int main(void)
{
    int n, x;
    cin >> n >> x;

    int w[n], v[n];

    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];

    long long a[x + 1] = {};

    for(int i = 0; i < n; i++)
    {
        for(int j = x; j >= 1; j--)
        {
            if(j >= w[i])
            {
                a[j] = max(a[j], a[j - w[i]] + v[i]);
            }
        }
    }
    cout << a[x] << endl;
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;

#define     endl               '\n'
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }




int main(int argc, char** argv) {
    //fast_io
    

    int n, oc = 0;
    cin >> n;
    
    
    for(int i = 0, a; i < n; ++i) {
	cin >> a;
	if(a&1) ++oc;
    }
    
    if(n == 1 || !(oc&1)) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define inf (int)(3e18)
#define mod (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,sum[114514];
int a[114514];
int mod_pow(int x,int y,int z){
	int res=1;
	while(y>0){
		if(y&1)res*=x;
		res%=z;
		x*=x;x%=z;
		y>>=1;
	}
	return res;
}
void init(){
	int now=1;
	for(int i=1;i<=n;i++){
		now*=i;now%=mod;
	}
	for(int i=1;i<=n;i++){
		sum[i]=now*mod_pow(i,mod-2,mod)%mod;
		sum[i]+=sum[i-1];sum[i]%=mod;
	}
}
signed main(){
	cin>>n;
	init();
	rep(i,n)cin>>a[i];
	int ans=0;
	rep(i,n){
		int memo=sum[i+1];
		memo+=sum[n-i]-sum[1];
		ans+=a[i]*memo;ans%=mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
sx,sy,tx,ty=map(int,input().split())
p=[sx,sy]
root=""
for i in range(ty-sy):
    p[1]=p[1]+1
    root="".join((root,"U"))
for i in range(tx-sx):
    p[0]=p[0]+1
    root="".join((root,"R"))
for i in range(ty-sy):
    p[1]=p[1]-1
    root="".join((root,"D"))
for i in range(tx-sx):
    p[0]=p[0]-1
    root="".join((root,"L"))

p[0]=p[0]-1
root = "".join((root, "L"))
for i in range(ty - sy+1):
    p[1] = p[1] + 1
    root = "".join((root, "U"))
for i in range(tx - sx+1):
    p[0] = p[0] + 1
    root = "".join((root, "R"))
p[1]=p[1]-1
root = "".join((root, "D"))
p[0]=p[0]+1
root = "".join((root, "R"))
for i in range(ty - sy+1):
    p[1] = p[1] + 1
    root = "".join((root, "D"))
for i in range(tx - sx+1):
    p[0] = p[0] + 1
    root = "".join((root, "L"))
p[1]=p[1]+1
root = "".join((root, "U"))
#UUURRRDDDLLLLUUUURRRRDRDDDDLLLLU
#UURRURRDDDLLDLLULUUURRURRDDDLLDL

print(root)

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

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    if(x==W/2 && y == H/2){
        printf("%lf %d\n", W*H/2, 1);
    }else{
        printf("%lf %d\n", W*H/2, 0);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int a[26];
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;i<s.size();i++)a[(int)(s[i]-96)]++;
	for(int i=0;i<26;i++)if(a[i]%2==1){cout<<"No"<<endl;return 0;}
	cout<<"Yes"<<endl;
	return 0;	
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
      int b = scan.nextInt();
      int c = scan.nextInt();
      
      System.out.println(c-(a-b)>0?c-(a-b):0);
	}
}

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


// 11717
int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end());

    ll ans = 0;
    for (int i=0; i<N; ++i) {
        for (int j=i+1; j<N; ++j) {

            int a = abs(L[i] - L[j]);
            int b = L[i] + L[j];

            auto p1 = upper_bound(L.begin(), L.end(), a);
            auto p2 = lower_bound(L.begin(), L.end(), b);
            p2--;

            if (p1 != L.end() and p2 != L.end()) {

                ll tmp1 = p1 - L.begin();
                ll tmp2 = p2 - L.begin();

                if (tmp1 >= tmp2) continue;

                ll tmp = tmp2 - tmp1 + 1;
                if (a < L[i] and L[i] < b) tmp--;
                if (a < L[j] and L[j] < b) tmp--;

                ans += max(0LL, tmp);
            }
        }
    }

    cout << ans/3 << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    long long sum = 0;
    int c = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if (i < n-1 && sum * 2 < a[i+1]) c = 0;
        else c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=200000+10;
int k,n,a[N];
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>k>>n;
    for(int i=1;i<=n;i++){
    	cin>>a[i];
    }
    int ans=a[n]-a[1];
    for(int i=2;i<=n;i++)ans=min(ans,k-(a[i]-a[i-1]));
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(ll i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll f(ll n) {
  ll i = 1, c = 0;
  while((n -= i) >= 0) {
    c++;
    i++;
  }
  return c;
}

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

  ll n, c = 0;
  cin >> n;

  map<ll, ll> factors = prime_factor(n);
  for (auto it = factors.begin(); it != factors.end(); it++) {
    c += f(it->second);
  }

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 3660
/*Author: Gautam*/
 
 
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 

void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d==1)
    {
        cout<<"1";
    }
    else
    {
        cout<<"0";
    }
}
 
int main()
{
    FastIO;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
from collections import deque

s = list(input())
q = int(input())
t = [list(map(str,input().split())) for _ in range(q)]

d = deque(s)

cnt = 0
for i in range(q):
  if len(t[i]) == 1:
    cnt += 1
  else:
    if (int(t[i][1])+cnt) % 2 != 0:
      d.appendleft(t[i][2])
    else:
      d.append(t[i][2])
      
if cnt%2 != 0:
  d = list(d)[::-1]
print(''.join(d))

Measured memory_bytes: 40040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                    \
  ifstream in("abc162/abc162_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  ll ans = 0;
  rep(i, N+1) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }

  cout << ans<< endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n)
{
    KAKA
    vector<ll> v(n);
    pragi(0,n)
    {
        cin>>v[i];
    }
    vector<ll> stools(n);
    stools[0] = 0;
    ll mx = v[0];
    pragi(1,n)
    {
        stools[i] = max(0ll,mx - v[i]);
        mx = max(mx,v[i] + stools[i]);
    }
    ll sum = 0;
    for(auto h : stools) sum += h;
    cout<<sum<<"\n";
}
int main()
{
    KAKA
    ll n;
    cin>>n;
    Compute(n);
}

Measured memory_bytes: 6344
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll a[100010], b[100010], c[100010];
priority_queue<ll> Q;
int main()
{
	ll X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	for (int i = 0; i < A; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < B; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < C; i++) {
		cin >> c[i];
	}
	sort(a, a + A, greater<ll>());
	sort(b, b + B, greater<ll>());
	sort(c, c + C, greater<ll>());
	for (int i = 0; i < X; i++) {
		Q.push(-a[i]);
	}
	for (int i = 0; i < Y; i++) {
		Q.push(-b[i]);
	}
	for (int i = 0; i < C; i++) {
		ll num = Q.top();
		num *= -1;
		if (c[i] > num) {
			Q.pop();
			Q.push(-c[i]);
		}
		else {
			break;
		}
	}
	ll ans = 0;
	while (!Q.empty()) {
		ll num = Q.top();
		ans -= num;
		Q.pop();
	}
	cout << ans << endl;
}

Measured memory_bytes: 4724
#include <bits/stdc++.h>
 
#define Set(a, b) memset(a, (b), sizeof(a))
#define F first
#define S second
#define FT front()
#define BK back()
#define PB push_back
#define MP make_pair
#define repi(i, l, r) for (int i=l ; i <= (int)(r) ; ++i)
#define repd(i, r, l) for (int i=r ; i >= (int)(l) ; --i)
#define repv(x, v) for (auto (x) : v)
#define all(cont) cont.begin(), cont.end()
#define Sort(n) sort(all(n))
#define Sortcmp(n) sort(all(n), cmp)
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define nl "\n"

using namespace std;

bool cmp(const pair<long,long> &a,
              const pair<long,long> &b)
{
    return (a.second < b.second || (a.second == b.second && a.first < b.first));
}

bool binarySearch(int arr[], int n, int x){
    int k = 0;
    for (int b = n/2; b >= 1; b/2)
        while (k+b < n && arr[k+b] <= x) k += b;

    if (arr[k] == x) return k;
    return -1;
}

/* ASCII Table */
/* 48 == '0', 57 = '9', 65 == 'A', 90 == 'Z', 97 == 'a', 122 == 'z' */  

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n, idx = 1;;
    float t, a, x, min;

    cin >> n;
    cin >> t >> a;

    cin >> x;
    min = fabs(a - (t - (x / 1000.0f * 6.0f)));
        
    repi(i, 1, n-1){
        cin >> x;
        x = fabs(a - (t - (x / 1000.0f * 6.0f)));
        if(min > x){
            min = x;
            idx = i+1;
        }
    }

    cout << idx << nl;

}

/* Compile */
// g++ -std=c++11 -O2 -Wall test.cpp -o test
 
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("%d\n", ans);
    }
    return 0;
}
 */
 
/* Source code dengan case
 
int main(){
    int T;
    cin >> T;
    for(int counterT = 1 ; counterT <= T ; T++){
         
        printf("Case #%d: %d\n", counterT, ans);
    }
    return 0;
}
 */

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int[] a = new int[q];
        int[] b = new int[q];
        int[] c = new int[q];
        int[] d = new int[q];
        for(int i = 0;i < q;i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        List<int[]> AList = new ArrayList<>();
        dfs(new int[n], 0, m, AList);

        int maxScore = 0;
        for(int i = 0;i < AList.size();i++) {
            int[] A = AList.get(i);
            int score = 0;
            for(int j = 0;j < q;j++) {
                if(A[b[j] - 1] - A[a[j] - 1] == c[j]) score += d[j];
            }

            if(score > maxScore) maxScore = score;
        }

        System.out.println(maxScore);
    }

    private static void dfs(int[] a, int idx, int m, List<int[]> result) {
        if(idx >= a.length) {
            result.add(a);
            return;
        }

        int preA = ((idx - 1) >= 0 ? a[idx - 1] : 1);
        for(int i = preA;i <= m;i++) {
            int[] newA = new int[a.length];
            for(int j = 0;j < a.length;j++) newA[j] = a[j];
            newA[idx] = i;
            dfs(newA, idx + 1, m, result);
        }

        return;
    }
}


Measured memory_bytes: 49364
import math
from sys import stdin, exit

def calc_dist(y, z, D):
    dist = 0
    for i in range(D):
        dist += pow(y[i]-z[i], 2)
    return pow(dist, 0.5)

N, D = [int(_) for _ in stdin.readline().rstrip().split()]
X = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        dist = calc_dist(X[i], X[j], D)
        if dist.is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 38384
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] a = new long[n];
		int MOD = 1000000007;
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextLong();
		}
		
		// 計算
		long result = 0;
		long[] bit = new long[60];
		for(int i = 0; i < n; i++){
		    String s = Long.toString(a[i], 2);
		    for(int j = 0; j < s.length(); j++){
		        if(s.charAt(s.length()-1-j) == '1') bit[j]++;
		    }
		}
		for(int i = 0; i < bit.length; i++){
		    //result += (((1L<<i)%MOD)*((bit[i])*(n-bit[i]))%MOD)%MOD;
		    result += (1L<<i)%MOD * bit[i]%MOD * (n-bit[i])%MOD;
		    result %= MOD;
		}
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 138668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>

using namespace std;

long long GCD(long long a, long long b)
{
	if (b == 0) {
		return a;
	}

	GCD(b, a%b);
}

bool IsPrime(long long n)
{
	if (n == 1 || n == 2) return true;
	if (n % 2 == 0) return false;

	for (int ni = 3; ni <= sqrt(n); ni += 2) {
		if (n % ni == 0) {
			return false;
		}
	}

	return true;
}

long long CntPrime(long long n)
{
	vector<long long> P(n + 1, 1);

	P[0] = 0;
	for (int ni = 2; ni <= sqrt(n); ni++) {
		for (int mi = 2; ni * mi <= n; mi++) {
			P[ni * mi] = 0;
		}
	}

	long long cnt = 0;
	for (int ni = 1; ni <= n; ni++) {
		if (n % ni == 0 && P[ni] > 0) {
			cnt++;
		}
	}

	return cnt;
}

int main()
{
	string S;

	cin >> S;

	int cnt = 0;
	for (int si = 0; si < 3; si++) {
		if (S[si] == 'o') {
			cnt++;
		}
	}



	int  ans = 700 + 100 * cnt;
	//printf("%.9f", ans);
	std::cout << ans;

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    int N, A, B, C;
    int[] len;

    void solve() {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        A = sc.nextInt();
        B = sc.nextInt();
        C = sc.nextInt();
        len = new int[N];

        for (int i = 0; i < N; i++) {
            len[i] = sc.nextInt();
        }
        int ans = calcMinMP(0, 0, 0, 0);
        System.out.print(ans);
    }

    // Aの長さがlenA、 Bの長さがlenB、Cの長さがlenCの時、curIndex 以降の材料を使って算出した最小のMP。
    int calcMinMP(int curIndex, int lenA, int lenB, int lenC) {
        // 最後の len[i] まで処理したので、ここで最小値を計算してreturnする。脱出条件。
        if (curIndex == N) {
            if (Math.min(Math.min(lenA, lenB), lenC) > 0) {
                int MP = (Math.abs(A - lenA) - 10) + (Math.abs(B - lenB) - 10) + (Math.abs(C - lenC) - 10);
                return MP;
            }
            else {
                return Integer.MAX_VALUE - 10;
            }
        }

        // まだ処理すべきlen[i]があるので、次に行く。

        int resultA    = calcMinMP(curIndex + 1, lenA + len[curIndex], lenB, lenC) + 10;
        int resultB    = calcMinMP(curIndex + 1, lenA, lenB + len[curIndex], lenC) + 10;
        int resultC    = calcMinMP(curIndex + 1, lenA, lenB, lenC + len[curIndex]) + 10;
        int resultNone = calcMinMP(curIndex + 1, lenA, lenB, lenC);
        return Math.min(resultA, Math.min(resultB, Math.min(resultC, resultNone)));
    }

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

Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>

#define ll (long long)
#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)
#define COUNTER int i= 0,j = 0,k = 0,l = 0,m = 0, n= 0;
#define RETURN cout << endl;

using namespace std;

int main (void){
    
    COUNTER
    int number;
    int r;
    
    while(cin >> number >> r ,number+r)
    {
        int p,c;
        
        vector<int>d(51,0);
        for(int i = 0; i<= number;i++){d[i] = number-i;}
        for(int i = 0; i< r;i++)
        {
            cin >> p >> c;
            vector<int>temp(51,0);
            for(int i = p-1; i< p-1+c;i++)
            {
                temp[i] = d[i];
               // cout << temp[i] << endl;
            }
            for(int l = 0; l < c;l++)
            {
                //cout << d[p-1];
                d.erase(d.begin()+p-1);
                
            }
            d.insert(d.begin(),temp.begin()+p-1,temp.begin()+c+p-1);
            /*REP(i,number)
            cout << d[i] << " ";*/
        }
        cout << d[0] << endl;
        
    }

    return 0;
}

Measured memory_bytes: 1224
// at_152d.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<math.h>
using namespace std;
#define FOR(i,a) for(int i=0;i<a;i++)
int n;
int working(int i, int j) {
    int out = 0;
    for(int a=1;a<=n;a++) {
        int temp = log10(a);
        if (a % 10 == j&&((a/(int)pow(10,temp))==i)) {
            out++;
        }
    }
    return out;
}
int main()
{
    cin >> n;
    long long ans = 0;
    for (int i = 1;i <= 9;i++) {
        for (int a = 1;a <= 9;a++) {
            //cout << i << " " << a << " " << working(i, a) << "\n";
            ans += working(i, a) * working(a, i);
        }
    }
    cout << ans << "\n";
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    string s;cin>>s;
    bool b=true;
    if(s[0]==s[s.size()-1]){
        if(s.size()%2==1){
            b=false;
        }
    }else{
        if(s.size()%2==0){
            b=false;
        }
    }
    
    if(b){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    return 0;
}





Measured memory_bytes: 512
#include <stdio.h>
#define N 100000
 
int main(void){
 
  int i,j,n,m,count=0;
  int s[N],t[N];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
 
  scanf("%d",&m);
 
  for(j=0;j<m;j++){
    scanf("%d",&t[j]);
  }
 
  for(j=0;j<m;j++){
    for(i=0;i<n;i++){
      if(s[i] == t[j]){
    count++;
    break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2128
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, X;
ll s[55], p[55];

ll f(ll n, ll x){   //レベルn, 下からx
    if(x == 1){
        return n == 0 ? 1 : 0;
    }else if(1 < x && x <= s[n-1] + 1){
        return f(n-1, x-1);
    }else if(x == s[n-1] + 2){
        return p[n-1] + 1;
    }else if(s[n-1] + 2 < x && x <= 2*s[n-1] + 2){
        return p[n-1] + 1 + f(n-1, x-(s[n-1]+2));
    }else{  //x == 2*s[n-1] + 3
        return p[n];
        //return 2*p[n-1] + 1;
    }
}

int main() {
    cin>>N>>X;

    s[0] = 1;
    p[0] = 1;
    REP(i,1,N+1) s[i] = 2*s[i-1] + 3;
    REP(i,1,N+1) p[i] = 2*p[i-1] + 1;

    cout<<f(N, X)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int c[3][3];

void input(){
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> c[i][j];
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    bool flg = true;
    if(!(c[0][0]-c[0][1]==c[1][0]-c[1][1]&&c[1][0]-c[1][1]==c[2][0]-c[2][1])) flg = false;
    if(!(c[0][1]-c[0][2]==c[1][1]-c[1][2]&&c[1][1]-c[1][2]==c[2][1]-c[2][2])) flg = false;
    if(!(c[0][2]-c[0][0]==c[1][2]-c[1][0]&&c[1][2]-c[1][0]==c[2][2]-c[2][0])) flg = false;
    if(!(c[0][0]-c[1][0]==c[0][1]-c[1][1]&&c[0][1]-c[1][1]==c[0][2]-c[1][2])) flg = false;
    if(!(c[1][0]-c[2][0]==c[1][1]-c[2][1]&&c[1][1]-c[2][1]==c[1][2]-c[2][2])) flg = false;
    if(!(c[2][0]-c[0][0]==c[2][1]-c[0][1]&&c[2][1]-c[0][1]==c[2][2]-c[0][2])) flg = false;
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

#define rep(i, n) for(int i=0;i<(int)(n);i++)

using namespace std;

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;
}

int r;

int main() {
    cin >> r;
    cout << r * r << endl;
}



Measured memory_bytes: 256
Option Strict On
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim w As Integer = NextInt()
        Dim h As Integer = NextInt()
        Dim n As Integer = NextInt()

        Dim x As Integer = 0
        Dim y As Integer = 0

        For i As Integer = 1 To n
            Dim xi As Integer = NextInt()
            Dim yi As Integer = NextInt()
            Dim a As Integer = NextInt()

            Select Case a
                Case 1
                    x = Max(x, xi)
                Case 2
                    w = Min(w, xi)
                Case 3
                    y = Max(y, yi)
                Case 4
                    h = Min(h, yi)
            End Select
        Next

        WriteLine(Max(0, w - x) * Max(0, h - y))
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As Char() = New Char() {}
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                ReDim Preserve result(UBound(result) + 1)
                result(UBound(result)) = nextChar
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result)
    End Function

End Module


Measured memory_bytes: 19920
// In the name of God
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <bitset>
#define sqr(a) (a)*(a)
#define all(a) (a).begin(), (a).end()
using namespace std;
  
template <typename T>
T next_int() {
    T x = 0, p = 1;
    char ch;
    do { ch = getchar(); } while(ch <= ' ');
    if(ch == '-') {
        p = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = x * 10 + (ch - '0');
        ch = getchar();
    }
    return p * x;
}
  
string next_token() {
    char ch;
    string ans = "";
    do { ch = getchar(); } while(ch <= ' ');
    while(ch > ' ') {
        ans += ch;
        ch = getchar();
    }
    return ans;
}
     
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e6 + 227 + 1;    
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-9;

long long bin_pow(long long a, long long b, int MOD) {
    if(!b) return 1;
    long long ans = bin_pow(a, b / 2, MOD);
    ans = ans * ans % MOD;
    if(b % 2) ans = ans * a % MOD;
    return ans;
}

int main() {
    // freopen(".in", "r", stdin);

    string b = "CODEFESTIVAL2016";
    string a; cin >> a;

    int ans = 0;
    for(int i = 0; i < a.size(); i++)
        if(a[i] != b[i]) ans++;

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char c;
    cin>> c;
    if (c == 'a' ||c== 'e' || c=='i' || c=='o' ||c== 'u'){
        cout<< "vowel";
    }else{
        cout<< "consonant";
    }

    return 0;
}

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

int main(){
    long N, M, C;
    cin >> N >> M >> C;
    vector<long> B(M);
    for(auto& i : B) cin >> i;

    long ans(0), c;
    while(N--){
        c = C;
        for_each(B.begin(), B.end(), [&c](auto b){long a; cin >> a; c += a * b;});
        ans += c > 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
let count_combination n =
    let count = ref 0 in
    for a = 0 to 9 do
        for b = 0 to 9 do
            for c = 0 to 9 do
                for d = 0 to 9 do
                    if a + b + c + d = n then (
                        count := !count + 1
                    )
                done
            done
        done
    done ;
    !count

let () =
    try
        while true do
            let n = read_int () in
            let c = count_combination n in
            Printf.printf "%d\n" c
        done
    with
        End_of_file -> ()

Measured memory_bytes: 2272
N,K = map(int,input().split())
count =0

for i in range(K,N+2):
  if i ==N+1:
    count+=1
  else:  
    a = (i-1)
    a = a/2
    a = a*i
    b = (N+N-(i-1))/2
    b = b*i
    count +=b-a+1
    #print(i,count,a,b)
print(int(count%(10**9+7)))

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

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

  cout << ((a<10 && b<10) ? a*b : -1) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		int e=sc.nextInt();
		 System.out.println(a<=0?a*-c+d+e*b:(b-a)*e);
		}
	}



Measured memory_bytes: 26356
#include <stdio.h>
int main() {
	int a, b, n, ans = 0;
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; i++)
	{
		int t = 10, sum = 0, ii;
		ii = i;
		for (int j = 0; j < 5; j++)
		{
			sum += ii%t;
			ii /= t;
		}
		if (a <= sum&&sum <= b) {
			ans += i;
		}
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll d,t,s;  cin>>d>>t>>s;
    cout<<(d<=t*s?"Yes":"No");
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin>>N;
  for(ll i=int(sqrt(N))+1;i>=1;i--){
    if(N%i==0){
      cout<<i+N/i-2<<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 cnt = 0;
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		for(int i = a; i <= b; ++i){
			if(c % i == 0) ++cnt;
		}
		System.out.printf("%d\n", cnt);
	}
}



Measured memory_bytes: 26416
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  std::string N; std::cin >> N;
  std::string IN = N;
  std::reverse(IN.begin(), IN.end());

  if ( N == IN ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;

  return 0;
}


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

public class Hello{
    public static void Main()
    {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if(input[0] < input[1] && input[1] < input[2])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
    }
}



Measured memory_bytes: 18400