akhauriyash/Code-Regression huggingface dataset:
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  ll n;
  cin>>n;
  ll ans=-1;
  int num=7;
  int a[n+1]={0};
  int cnt=1;
  while(1)
  {
    int rem=num%n;
    a[rem]++;
    if(rem==0)
    {
      ans=cnt;
      break;
    }
    else if(a[rem]>1)
    break;
    num=rem*10+7;
    cnt++;
  }
  cout<<ans;

  
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int tx = x2 - x1;
  int ty = y2 - y1;
  cout << x2 - ty << ' ' << y2 + tx << ' ';
  cout << x1 - ty << ' ' << y1 + tx << '\n';
}


Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back

int x1, x2, x3, y111, y2, y3;
LL s;

int main() {
scanf("%lld", &s);
x1 = y111 = 0;
x2 = 1000000000;
y2 = 1;
x3 = x2 - s % x2;
y3 = s / x2 + 1;
if (y3 > x2) {
	y3--;
	x3 = 0;
}

printf("%d %d %d %d %d %d\n", x1, y111, x2, y2, x3, y3);

return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            if (N/i != i) res.push_back(N/i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

int main(){
    ll n; cin >> n;
    /*rept(k, 2, n+1){
        ll m = n;
        rep(i, 1000){
            if(m==1)cout << k << " ";
            if(m%k==0) m /= k;
            else m -= k;
        }
    }
    cout << ln;*/
    set<ll> st{n};
    auto ed = enum_divisors(n-1);
    for(auto p: ed) st.insert(p);

    auto ed2 = enum_divisors(n);
    for(auto a: ed2){
        ll num = n;
        if(a==1)continue;
        while(num%a==0){
            num /= a;
        }
        if(num==1 || num % a == 1)st.insert(a);
    }
    //for(auto tmp: st)cout <<tmp << " ";
    cout << st.size() - 1 << ln;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
       public static void main(String[] args){
       int i,j;
    	int[] a = new int[1000000];
    	int[] b = new int[1000000];
    	int[] k = new int[1000000];
    	int c; 
        Scanner scan = new Scanner(System.in);
       
        i = 0;
        while(scan.hasNextInt()){
        	a[i] = scan.nextInt();
        	b[i] = scan.nextInt();
        	c = a[i]+b[i];
        	j = 0;
        	while(c > 0){
        	c= c/10;
        	j++;
        	}
        	k[i] = j;
               	i++;
        }
        
        
        j = 0;
        while(j < i){
        	System.out.println(k[j]);
        	j++;
       		}
       		}
}

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

#define N 3005
#define T 3005

long long int dp[N][T], answer[N][T];
vector<pair<int,int> > dish;


int main() {
	int n,t ; 
	scanf("%d %d",&n, &t);
	for(int i=0; i<n; i++) {
		int a,b;
		scanf("%d %d", &a, &b);
		dish.push_back(make_pair(a, b));
	}
	
	sort(dish.begin(), dish.end());
	// for(int i=0; i<n; i++) {
	// 	int a = dish[i].first, b=dish[i].second;
	// 	cout<<i<<"  "<<a<<"  "<<b<<endl;
	// }


	memset(dp, 0, sizeof(dp));
	for(int i=0; i<n; i++) {
		for(int j=0; j<t; j++) {
			int a = dish[i].first, b=dish[i].second ;
			if( j == 0)
				continue;
			if(i == 0) {
				if(j >= a) {
					dp[i][j] = b;
				}
				continue;
			}
			dp[i][j] = dp[i-1][j];
			if(j >= a) {
				dp[i][j] = max(dp[i][j], dp[i-1][j-a] + b);
			}
		}
	}

	memset(answer, 0, sizeof(answer));
	for(int i=0; i<n; i++) {
		int a = dish[i].first, b=dish[i].second;
		for(int j=0; j<t+1; j++) {
			if(j == 0)
				continue;
			if(i == 0) {
				answer[i][j] = b;
				continue;
			}
			answer[i][j] = max(b+dp[i-1][j-1], answer[i-1][j]);
		}
	}

	cout<<answer[n-1][t];

	return 0;
}

Measured memory_bytes: 141440
M,D = map(int,input().split())
ans = 0
for m in range(1,M+1):
    for d in range(22,D+1):
        d10 = int(str(d)[0])
        d1 = int(str(d)[1])
        if d10 * d1 == m and d1>=2 and d10>=2:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main(){
   int n;
 	scanf("%d",&n);
 	ll ans=0;
 	for(int i=1;i<=n;i++)
 		if(i%3!=0&&i%5!=0) ans+=i;
 	printf("%lld\n",ans);
  return 0;
};

Measured memory_bytes: 3232
#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());

typedef long long ll;

int digits(int a){
  if(a) return a%10 + digits(a/10);
  return 0;
}

int main(){
  int n;
  cin >>n;
  string ans = n%digits(n) ? "No" : "Yes";
  cout << ans << endl;
}

Measured memory_bytes: 256
import * as fs from 'fs'
const reader = (s: string) => s.split('\n') // .map(t => parseInt(t, 10))

function Main(input: string) {
  const [a, s] = reader(input)

  const A = parseInt(a, 10)

  if (A >= 3200) {
    console.log(s)
  } else {
    console.log('red')
  }
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int TAN = 0, FUKU = 1;

int way, bill;
double rate = 0;

int main()
{
    int m, nowm, money, year, n, maxmoney, risi;
    cin >> m;
    while(m--)
    {
        cin >> money >> year >> n;
        maxmoney = money;

        REP(n)
        {
            nowm = money, risi = 0;
            cin >> way >> rate >> bill;
            if(way == TAN)
            {
                rep(j, year)
                {
                    risi += rate * nowm;
                    nowm -= bill;
                }
                nowm = nowm + risi;
            }
            if(way == FUKU)
            {
                rep(j, year)
                {
                    nowm += rate * nowm;
                    nowm -= bill;
                }
            }
            maxmoney = max(maxmoney, nowm);
        }
        cout << maxmoney << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
import java.util.Scanner;

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

        String c[] = new String[3];
        String m[][] = new String[3][3];
        for (int i = 0; i < 3; i++)
            c[i] = sc.nextLine();
        for (int i = 0; i < 3; i++)
            m[i] = c[i].split("");
        System.out.println(m[0][0] + m[1][1] + m[2][2]);
    }
}

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

int main() {
  int n; cin >> n; int a[n];
  for (int k=0; k<n; k++) {
    int h; cin >> h;
    a[k]=h;
  }
  int l=0; int r=n-1; int count=0;
  for (int l=0; l<n-2; l++) {
    for (int m=l+1; m<n-1; m++) {
      for (int r=m+1; r<n; r++) {
        if (a[l]+a[m]>a[r] && a[l]+a[r]>a[m] && a[r]+a[m]>a[l] && a[l]!=a[m] && a[l]!=a[r] && a[m]!=a[r]) {
          count++;
          //cout << 1 << ": ";
        }
        //cout << a[l] << " " << a[m] << " " << a[r] << "\n";
      }
    }
  }
  cout << count << "\n";
}

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

int main(){
  int n,k; cin >> n >> k;
  string s; cin >> s;
  if(s.at(k-1) == 'A'){
    s.at(k-1) = 'a';
  }
  if(s.at(k-1) == 'B'){
    s.at(k-1) = 'b';
  }
  if(s.at(k-1) == 'C'){
    s.at(k-1) = 'c';
  }
  
  cout << s << endl;
}

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int const ans1 = A < B ? A : B;
	int ans2 = 0;
	if (A + B <= N) ans2 = 0;
	else ans2 = A + B - N;
	cout << ans1 << ' ' << ans2 << endl;
}

Measured memory_bytes: 256
def solve(n):
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))[::-1]
    ind = [-1] * (n + 1)
    for i in range(n):
        if i == 0:
            ind[b[i]] = 0
        elif b[i] != b[i - 1]:
            ind[b[i]] = i
    cnt = 0
    for i in range(n):
        if a[i] != b[i]:
            continue
        else:
            swap = 0
            for j in range(b[i] - 1, 0, -1):
                if ind[j] != -1 or ind[j] >= ind[j - 1]:
                    swap = ind[j]
                    ind[j] += 1
                    break
            if n <= swap:
                swap = cnt
                cnt += 1
                cnt %= n
            b[i], b[swap] = b[swap], b[i]
    return a, b


def main():
    n = int(input())
    a, b = solve(n)
    if all(a[i] != b[i] for i in range(n)):
        print("Yes")
        print(" ".join(map(str, b)))
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 41748
N,K = map(int,input().split())
lst = list(range(0,N+1))
m = 10**9 + 7
cnt = 0
start = sum(lst[:K])
end = sum(lst[-K:])
cnt += end - start + 1
for i in range(K+1,N+2):
    start += lst[i-1] 
    end += lst[-i]
    cnt += end - start + 1
print(cnt % m)
   

Measured memory_bytes: 78984
#include <stdio.h>
#define MAX 1000000

int main(void){
  int p_num[MAX]={0};
  int a, d, n;
  int i, j;
  int count;

  while(1){
    scanf("%d %d %d", &a, &d, &n);
    
    if((a>9307 || d>346 || n>210) || (a==0 && d==0 && n==0))
      break;

    for(i=2;i<MAX;i++)
      p_num[i]=1;
    
    for(i=2;i*i<MAX;i++){
      if(p_num[i]){
	for(j=2*i;j<MAX;j+=i)
	  p_num[j]=0;
      }
    }

    count=0;

    for(i=a;count<=n;i+=d){
      if(p_num[i]==1)
	count++;
      if(n==count)
	break;
    }
    printf("%d\n",i);
  }

  return 0;
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
#define trav(x,v) for(auto &x:v)
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Ford(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(i, n) for (int i=0;i<(n);i++)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define debug(x) {cerr<<"L"<<__LINE__ <<" : "<<#x<<" = "<<(x)<<endl;}


using vi=vector<int>;
using pii=pair<int,int>;
using ll=long long;
using vll=vector<ll>;
using pll=pair<ll,ll>;

//const int EPS=1e-9;


int main() {
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // or
    //ifstream fin("input.txt");
    //ofstream fout("ouput.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin.exceptions(cin.failbit);
    //Solution
    int x;
    cin>>x;
    cout<<x*x*x<<endl;
}



Measured memory_bytes: 3180
N,H=map(int,input().split())
B=[]
index=-1
tmp=-1
for i in range(N):
  a,b=map(int,input().split())
  B.append(b)
  if a>tmp:
    index=i
    tmp=a
a_,b_=tmp,B[index]
cnt=0
B=sorted(B,reverse=True)
while H>0 and len(B)!=0:
  b=B.pop(0)
  if b<a_:
    break
  H-=b
  cnt+=1
if H<=0:
  print(cnt)
else:
  v=H//a_
  if H%a_==0:
    cnt+=v
  else:
    cnt+=(v+1)
  print(cnt)

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

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

  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  int ans = 1;
  for(int sign = 0, i = 0; i + 1 < N; i++){
    if((A[i + 1] - A[i]) * sign < 0){
      ans++;
      sign = 0;
    }else if(A[i + 1] - A[i] > 0){
      sign = 1;
    }else if(A[i + 1] - A[i] < 0){
      sign = -1;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 640
#include <stdio.h>
int k, a, b;
int main() {
	scanf("%d%d%d", &k, &a, &b);
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			printf("OK\n");
			return 0;
		}
	}
	printf("NG\n");
}

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

int main()
{
	int a,b,N;
	cin >> N >> a >> b;
	
	if (N * a > b) {
		cout << b << endl;
	}
	else if (N * a <= b) {
		cout << N * a << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define pps(n) printf("%lld ",n)
#define all(x) x.begin(),x.end()
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#ifdef G
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<' '<<#zz<<' '<<zz<<endl;
#else
#define dg(x) ;
#define dg2(x,y) ;
#define dg3(x,y,z) ;
#define dg4(x,y,z,zz) ;
#endif
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
#define yes printf("YES\n")
#define no printf("NO\n")
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e6+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
vector<lld> v[M];
int main()
{
      lld i,j;
        ds(x,y);
        ans=2*y-x;
        pp(ans);
        return 0;
}

Measured memory_bytes: 23680
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

bool solve(int n, int i);

int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int ans = 0;
        for(int i = 2; i <= n / 2 + 1; i++){
            if(solve(n, i)) ans++;
        }
        cout << ans << endl;
    }
   return 0;
}

bool solve(int n, int i)
{
    int a = n / i;
    for(int j = a - (i / 2) - 1; j < a + 1; j++){
        int sum = 0;
        if(j <= 0) continue;
        for(int k = 0; k < i; k++){
            sum += j + k;
        }
        if(sum == n){
            return true;
        }
    }
    return false;  
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

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

    int t = sum(next<vector<int>>(4));
    cout << t / 60 ln << t % 60 ln;

    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

bool seen[200010];
int dist[200010] = {};
vector<vector<int>> tree(200010);
void dfs(int i, int prev) {
    seen[i] = 1;
    if (i != 0) dist[i] += dist[prev];
    for (auto next : tree[i])
        if (!seen[next]) dfs(next, i);
}

signed main() {
    int n, q;
    cin >> n >> q;
    rep(i, 0, n - 1) {
        int a, b;
        cin >> a >> b;
        tree[--a].push_back(--b);
        tree[b].push_back(a);
    }
    rep(i, 0, q) {
        int p, x;
        cin >> p >> x;
        dist[--p] += x;
    }
    dfs(0, 0);
    rep(i, 0, n) { cout << dist[i] << "\n"; }
}

Measured memory_bytes: 25180
import java.util.*;

public class Main{
  static char[] p;

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

    while(n-- > 0){
      p = sc.next().toCharArray();
      System.out.println(expr(0).val);
    }
  }

  static class Parsed{
    int val;
    int idx;
    Parsed(int val, int idx){
      this.val = val;
      this.idx = idx;
    }
  }

  static Parsed expr(int idx){
    Parsed r = term(idx);
    while(p[r.idx]=='+' || p[r.idx]=='-'){
      char op = p[r.idx];
      int tmp = r.val;
      r = term(r.idx+1);
      if(op == '+') r.val = tmp + r.val;
      else r.val = tmp - r.val;
    }
    return r;
  }

  static Parsed term(int idx){
    Parsed r = fact(idx);
    while(p[r.idx]=='*' || p[r.idx]=='/'){
      char op = p[r.idx];
      int tmp = r.val;
      r = fact(r.idx+1);
      if(op == '*') r.val = tmp * r.val;
      else r.val = tmp / r.val;
    }
    return r;
  }

  static Parsed fact(int idx){
    if(Character.isDigit(p[idx])){
      int t = p[idx++] - '0';
      while(Character.isDigit(p[idx]))t = t*10 + p[idx++]-'0';
      return new Parsed(t, idx);
    }
    else if(p[idx]=='('){
      Parsed r = expr(idx+1);
      if(p[r.idx]!=')') return null; // invalid input
      return new Parsed(r.val, r.idx+1);
    }
    else return null; // invalid input
  }
}

Measured memory_bytes: 12000
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

int N;
int[] ary;
void main() {
    while(true) {
        N = readln.chomp.to!int;
        if (N==0) break;
        ary = readln.split.to!(int[]);
        rec(0, 0).writeln;
    }
}
int rec(int depth, int x) {
    if (depth==N) return x.abs;
    return min(rec(depth+1, x+ary[depth]), rec(depth+1, x-ary[depth]));
}

Measured memory_bytes: 2300
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++)
        {
            a[i] = sc.nextInt();
        }
        int x;
        for(int i=0; i<n; i++)
        {
            for(int j=i; j<n; j++)
            {
                if(a[i] > a[j])
                {
                    x    = a[i];
                    a[i] = a[j];
                    a[j] = x;
                }
            }
        }
        int sum = 0;
        for(int i=n-1; i>=1; i--)
        {
             sum += a[i];
             sum -= a[--i];

        }
        if(n % 2 == 1)
        {
            sum += a[0];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23508
import sys
from collections import Counter
from itertools import combinations


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    L = list(map(int, input().split()))
    count = Counter(L)
    key = count.keys()

    set_list = combinations(key, 3)
    answer = 0
    for s in set_list:
        a = s[0]
        b = s[1]
        c = s[2]
        if (a + b) > c and (b + c) > a and (c + a) > b:
            answer += count[a] * count[b] * count[c]
    print(answer)


if __name__ == "__main__":
    main()


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	string s;
	cin >> s;

	int red = 0;

	for (int i = 0; (size_t) i < s.size(); i++) {
		if (s[i] == 'R') {
			red++;
		}
	}

	if (red > N / 2) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

int main() {
    ll mod1 = 998244353;
    ll N, M, K;
    cin>>N>>M>>K;
    ll DP[N+1], DP1[N+1];
    DP[0] = 1;
    for(int i=1;i<=N;++i){
        DP[i] = (M-1) * DP[i-1];
        DP[i] %= mod1;
    }
    DP1[0] = 1;
    DP1[1] = 1;
    for(ll i=2;i<=N;++i){
        DP1[i] = DP1[i-1] * i;
        DP1[i] %= mod1;
    }
    ll DP2[N+1]; // 階乗の分母
    ll h;
    ll two;
    ll tmpshita, shita;
    for(int i=0;i<=N;++i){
        h = mod1 - 2;
        DP2[i] = 1;
        while(h>0){
            tmpshita = DP1[i];
            two = 1;
            while(two*2<=h){
                two *= 2;
                tmpshita *= tmpshita;
                tmpshita %= mod1;
            }
            DP2[i] *= tmpshita;
            DP2[i] %= mod1;
            h -= two;
        }
    }
    ll ans = 0;
    for(ll i=0;i<=K;++i){
        ans += (((((((DP1[N-1]*DP2[i])%mod1)*DP2[N-1-i])%mod1)*M)%mod1)*DP[N-i-1])%mod1;
        ans %= mod1;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 8208
#include<bits/stdc++.h>
using namespace std;
#define int long long  
#define mod 1000000007
#define am 998244353
#define INFi 2147483647
#define INFl 9223372036854775807LL
#define fi first
#define se second
#define be begin()
#define en end()
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
}
int lcm(int a,int b){//最小公倍数
    return (a*b)/gcd(a,b);
}	    
signed main(){
// __builtin_ctz(N);      Nを２で何回割り切れるかを返す
//(n+1)*n/2;              １からNまでの総和を求める式
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c=0;
    cin>>a>>b;
    if(a==1) c=300000;
    if(a==2) c+=200000;
    if(a==3) c+=100000;
    if(b==1) c+=300000;
    if(b==2) c+=200000;
    if(b==3) c+=100000;
    if(a+b==2) c+=400000;
    cout<<c<<"\n";
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scn = new Scanner(System.in);
    int N = scn.nextInt();
    ArrayList<Integer> V = new ArrayList<>();
    for (int i = 0; i < N; i++) {
      V.add(scn.nextInt());
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int C = scn.nextInt();
      if (V.get(i) > C) {
        ans += V.get(i) - C;
      }
    }

    System.out.println(ans);

  }

}


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

long long s(long long n){
	return n*(n+1)/2;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	long long sum = s(n) - 3*s(n/3) - 5*s(n/5) + 15*s(n/15);
	cout << sum << "\n";
}

Measured memory_bytes: 3540
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B;
    cin >> A >> B;
    if(A>B){
        cout << 2*A-1 <<endl;
    }
    else if(B>A){
        cout <<2*B-1 <<endl;
    }
    else{
        cout << A+B<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	char c;
	scanf("%c", &c);
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') printf("vowel\n");
	else printf("consonant\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1572
s_list = list()

while True:
    h,w = map(int,input().split())
    s_pair = [h,w]
    if s_pair == [0,0]:
        break
    s_list.append(s_pair)

for pair in s_list:
    for h in range(pair[0]):
        if h % 2 == 0:
            for w in range(pair[1]):
                if w % 2 == 0:
                    print('#', end='')
                elif w % 2 == 1:
                    print('.', end='')
            print('')
        elif h % 2 == 1:
            for w in range(pair[1]):
                if w % 2 == 0:
                    print('.', end='')
                elif w % 2 == 1:
                    print('#', end='')
            print('')
    print('')



Measured memory_bytes: 7012
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
	    long[] input = new long[5];
	    long N = sc.nextLong();
	    for(int i = 0; i < input.length; i++) {
	    	input[i] = sc.nextLong();
	    }
	    long minTransCapa = Long.MAX_VALUE;
	    for( int i = 0; i < input.length; i++) {
	    	if( input[i] <= minTransCapa ) {
	    		minTransCapa = input[i];
	    	}
	    	
	    }
	    long total = 0;
	    if( N%minTransCapa == 0 ) {
	    	total = 5 + N/minTransCapa - 1;
	    } else {
	    	total = 5 + N/minTransCapa;
	    }
	    
	    
    	System.out.println(total);

		sc.close();
	}
}


Measured memory_bytes: 23892
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	a,b = map(int,input().split())
	idx = b - a
	ans = 0
	for i in range(idx):
		ans += i
	ans -= a
	print(ans)
	

if __name__ == '__main__':
	main()

Measured memory_bytes: 9160
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

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

    // F[0] から F[N] までのメモリを確保
    // 初期値 0 ，N + 1 コの要素
    vector<ll> dp(N+1, 0);

    // 初期条件，フィボナッチ数列の初期値 F[0] と F[1] は 1
    dp[0] = 1;
    dp[1] = 1;

    // 配列 dp の遷移を行う
    for (int i=2; i<=N; i++){
        // 現在の項以前の 2 項を足す処理
        dp[i] += dp[i-1];
        dp[i] += dp[i-2];
        // cout << i << " : " << dp[i] << endl;
    }

    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;
public class Main {

   
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        int a=s.nextInt();
        int b=s.nextInt();
        int c=s.nextInt();
        
        if(a+b>=c){
            System.out.println("Yes");
        }else
            System.out.println("No");
    }
    
}


Measured memory_bytes: 21844
n = int(input())
v = sorted(list(map(int, input().split())))

while True:
  ans = 0
  ans += (v[0] + v[1])/2
  if len(v) == 2:
    break
  else:
    v.pop(0)
    v.pop(0)
    v.insert(0, ans)
print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6;
const double PI = acos(-1.0);
#define Test ll tesnum;tesnum = read();while(tesnum--)
ll read();
int a[N];
int main()
{
    ll n;
    cin>>n;
    string s ="";
    while(n)
    {
        int m = n%26;
        if(m==0)m = 26;
        char c = 'a'+m-1;
        s+=c;
        n = (n-m)/26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return "BT7274", NULL;
}

inline ll read() {
    ll hcy = 0, dia = 1;char boluo = getchar();
    while (!isdigit(boluo)) {if (boluo == '-')dia = -1;boluo = getchar();}
    while (isdigit(boluo)) {hcy = hcy * 10 + boluo - '0';boluo = getchar();}
    return hcy * dia;
}

Measured memory_bytes: 3628
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9 + 7;
void solve(){
    int n;
    cin >> n;
    set<int> s;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        s.in(x);
    }
    if(s.size() == n) cout << "YES";
    else cout << "NO";
}
int main(){
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

Measured memory_bytes: 9600
#include<stdio.h>

main(){

    int n;

    while(~scanf("%d",&n)){

        int a,b,c,f=0;

        // for(a=0;a<10;a++)

        //     for(b=0;b<10;b++)

        //         for(c=0;c<10;c++)

        //             if(n-a-b-c < 10 && n-a-b-c >=0)f++;

        // printf("%d\n",f);



        int k,i;

        f = 0;

        for(i=0; k = n-(i/100)-((i/10)%10)-i%10, i < 1000; ++i)

            if(k < 10 && k >= 0) f++;

        printf("%d\n", f);

    }

}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

int main() {
  long n, a, b;
  cin >> n >> a >> b;
  if (a > b || (a != b && n == 1)) {
    cout << 0 << endl;
    return 0;
  }
  long minSum, maxSum;
  minSum = a + b + a * (n - 2);
  maxSum = a + b + b * (n - 2);
  cout << maxSum - minSum + 1 << endl;
  return 0;
}



Measured memory_bytes: 256
N=gets.to_i
a=gets.split.map(&:to_i)
aa=[]
N.times{|i|
  if i==0 then
    aa[i]=a[i]
  else
    aa[i]=aa[i-1]+a[i]
  end
}
aa.push(0)
aa.sort!
t=-1e10
nt,ans=0,0
(N+1).times{|i|
  if t!=aa[i] then
    ans+=nt*(nt-1)/2
    nt=0
    t=aa[i]
  end
  nt+=1
}
ans+=nt*(nt-1)/2

puts ans


Measured memory_bytes: 19788
#include "stdio.h"
int main()
{
	char a[4];
	scanf("%s",a);
	if ((a[0] != a[1]) && (a[1] != a[2]) && (a[0] != a[2])) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  
  vector<long>A(N);for(long i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end(),greater<long>());
  
  
  
  multiset<long>M;for(long a:A)M.insert(a);
  long ans=0;long p=INT_MAX;
  for(long i=0;i<N;i++){
    if(M.find(A[i])!=M.end()){
      while(p/2>=A[i]){p/=2;assert(p/2!=p);}// これで, p/2<A[i]となるような最小の11...1が得られる
      long d=(~(A[i]-1))&p;
      if((A[i]!=d||M.count(A[i])>1)&&M.find(d)!=M.end()){
        if(A[i]!=d){
          if(M.count(d)>M.count(A[i])){
            ans+=M.count(A[i]);
            for(long j=0;j<M.count(A[i]);j++)M.erase(M.find(d));
            M.erase(A[i]);
          }
          else{
            ans+=M.count(d);
            for(long j=0;j<M.count(d);j++)M.erase(M.find(A[i]));
            M.erase(d);
          } 
        }else{
          ans+=M.count(d)/2;
          if(M.count(d)%2){M.erase(d);M.insert(d);}
          else M.erase(d);
        }
      }
    }
  }
  cout<<ans;
}





Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int c=0;
  for(int i=0;i<n;i++){
    int h;
    cin>>h;
    if(h>=k)
      c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int a[]=new int[n];
    int[] dp=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
      dp[i]=Integer.MAX_VALUE;
    }
    dp[0]=0;
    dp[1]=Math.abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
      for(int j=1;j<=k;j++){
        if(i-j>=0){
           dp[i]=Math.min(dp[i-j]+Math.abs(a[i]-a[i-j]),dp[i]);
        }
      }
     
    }
    System.out.print(dp[n-1]);
  }
}

Measured memory_bytes: 51940
#include<stdio.h>
int main(void)
{
	int n=0,i,j,number[1000];
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d",&number[i]);
	}
	for(j=n-1;j>=0;j--)
	{
		printf("%d",number[j]);
		if(j>0)
		{
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <limits>

constexpr int MAX_WH = 20;
constexpr int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

typedef std::pair<int, int> P;

int dfs(const int& x, const int& y, const int count = 1);

int W, H, sx, sy, gx, gy;
int map[MAX_WH][MAX_WH];

int main(){
	std::ios::sync_with_stdio(false);

	while(true){
		std::cin >> W >> H;
		if(W == 0 && H == 0){
			break;
		}

		for(int i = 0; i < H; ++i){
			for(int j = 0; j < W; ++j){
				std::cin >> map[j][i];
				if(map[j][i] == 2){
					sx = j, sy = i;
				}
				if(map[j][i] == 3){
					gx = j, gy = i;
				}
			}
		}
		std::cout << dfs(sx, sy) << '\n';
	}
	
	return 0;
}

int dfs(const int& x, const int& y, const int count){
	if(count > 10){
		return -1;
	}
	int res = std::numeric_limits<int>::max();
	for(int i = 0; i < 4; ++i){
		int nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= W || ny >= H || map[nx][ny] == 1){
			continue;
		}
		while(true){
			if(nx == gx && ny == gy){
				return count;
			}
			nx += dx[i], ny += dy[i];
			if(nx < 0 || ny < 0 || nx >= W || ny >= H){
				break;
			}
			if(map[nx][ny] == 1){
				map[nx][ny] = 0;
				int tmp = dfs(nx - dx[i], ny - dy[i], count + 1);
				map[nx][ny] = 1;
				if(tmp != -1){
					res = std::min(res, tmp);
				}
				break;
			}
		}
	}
	if(res > 10){
		return -1;
	}
	return res;
}

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

ll N;
ll rnd[18][256];

void func(string s, vector<map<ll, ll> >&v){
    for(ll i = 0; i < (1 << N); i++){
        ll hs = 0;
        int cnt = 0;
        for(ll j = 0, k = 1, front = 0, back = N - 1; j < N; j++, k <<= 1){
            if(i & k){
                hs ^= rnd[front][s[j]];
                front++;
                cnt++;
            }
            else{
                hs ^= rnd[back][s[j]];
                back--;
            }
        }
        v[cnt][hs]++;
    }
}

int main(){

    random_device rd;
    mt19937_64 mt(rd());
    for(int i = 0; i < 18; i++){
        for(int j = 'a'; j <= 'z'; j++){
            rnd[i][j] = mt();
        }
    }

    cin >> N;
    string s;
    cin >> s;

    string s1 = s.substr(0, N);
    string s2 = s.substr(N, N);
    reverse(s2.begin(), s2.end());
    
    vector<map<ll, ll> >v1(N + 1);
    vector<map<ll, ll> >v2(N + 1);

    func(s1, v1);
    func(s2, v2);

    ll ans = 0;
    for(int a = 0; a <= N; a++){
        for(map<ll, ll>::iterator it = v1[a].begin(); it != v1[a].end(); it++){
            ll key = (*it).first;
            ll value = (*it).second;
            ans += v2[a][key] * value;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N, vector<int>(M));
  REP(i, N) REP(j, M) cin >> A[i][j];
  vector<bool> held(M, true);
  int ans = N;
  REP(k, M) {
    vector<int> num(M);
    REP(i, N) {
      REP(j, M) {
        if(held[A[i][j]-1]) {
          num[A[i][j]-1]++;
          break;
        }
      }
    }
    int max = 0;
    int idx = -1;
    REP(i, M) {
      if(held[i] && num[i] > max) {
        max = num[i];
        idx = i;
      }
    }
    if(max < ans) ans = max;
    held[idx] = false;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
using System;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        string[] s;
        int W, H = 0;

        while((s = Console.ReadLine().Split()) != null)
        {
            H = int.Parse(s[0].ToString());
            W = int.Parse(s[1].ToString());

            if (H == 0 && W == 0) break;
            
            for(int i = 0; i < H; i++)
            {
                for(int j = 0; j < W; j++)
                {
                    if(i == 0 || i == H - 1 || j == 0 || j == W - 1)
                    {
                        Console.Write("#");
                    }
                    else
                    {
                        Console.Write(".");
                    }
                }
                Console.Write("\n");
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8720
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a[3];

  std::cin >> a[0] >> a[1] >> a[2];

  for ( ; a[0] >= 2 && a[1] >= 2 && a[2] >= 2; a[0] -= 2, a[1] -= 2, a[2] -= 2)
    ;

  std::sort(a, a + 3);

  for (int i = 0; ; i ++) {
    int x = i, y = a[2] + i - a[0], z = a[2] + i - a[1];

    if ((x + y + z) % 2 == 0) {
      std::cout << (x + y + z) / 2 << std::endl;

      break;
    }
  }
    
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int date[101][101] = { 0 };
	int r, c;
	int i, j;

	scanf("%d %d", &r, &c);

	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			scanf("%d",&date[i][j]);
		}
	}

	for (i = 0; i < r + 1; i++) {
		for (j = 0; j < c + 1; j++) {
			if (j != c) { date[i][c] += date[i][j]; }
			if (i != r) { date[r][j] += date[i][j]; }
			if (j == c) {
				if (i == r) {
					printf("%d\n", date[r][c] / 2);
				}
				else {
					printf("%d\n", date[i][j]);
				}
			}
			else{ printf("%d ", date[i][j]); }
		}
	}
	
	return 0;
}


Measured memory_bytes: 2100
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
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; }

int main() {
    ll M = 100,ans=0;
    ll X; cin >> X;

    while (M < X) {
        M += M / 100;
        ans++;
    }
    cout << ans << endl;
}




    


   









    


















































































































































































































































































































Measured memory_bytes: 3648
from math import factorial

N,K = map(int, input().split())

N += 1

ans = 0
head = sum(range(K-1))
tail = sum(range(N-K+1,N))

for i in range(K,N+1):
    head+=i-1
    tail+=N-i
    ans += tail - head +1

print(ans%(10**9+7))

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int n;
map<string,int>mp;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;cin>>s;
		mp[s]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
}

Measured memory_bytes: 3632
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define dbg(x) cerr<<"["<<#x<<" = "<<x<<"]"

int D;
vector<vector<int>> s;
vector<int> c;

int get_score(vector<int> &sc) {
    unordered_map<int, int> last;
    int S = 0;
    for (int i = 0; i < D; ++i) {
        S += s[i][sc[i] - 1];
        last[sc[i] - 1] = i + 1;
        for (int j = 0; j < 26; j++)S -= c[j] * (i + 1 - last[j]);
//        dbg(S) << endl;
    }
    return max(1000000 + S, 0ll);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    cin >> D;
    c = vector<int>(26);
    s = vector<vector<int>>(D, vector<int>(26));
    for (auto &i:c)cin >> i;
    for (auto &i:s) {
        for (auto &j:i)cin >> j;
    }

    vector<int> ans(D);
    for (auto &i:ans)cin >> i;
    unordered_map<int, int> last;
    int tm = 1 + rand() % 26;
    int S = s[0][tm - 1];
    ans[0] = tm;
    last[tm] = 1;

    for (int i = 1; i < D; ++i) {
        int cur = -1e18, pos = -1;
        for (int j = 0; j < 26; ++j) {
            int sc = S + s[i][j];

            for (int k = 0; k < 26; ++k) {
                if (k == j)continue;
                sc -= c[k] * (i + 1 - last[k]);
            }

            if (sc > cur) {
                cur = sc;
                pos = j;
            }
        }
        ans[i] = pos + 1;
        last[pos] = i + 1;
    }
    for (auto i:ans)cout << i << endl;

//    int score = get_score(ans);
//    dbg(score) << endl;
}

Measured memory_bytes: 3748
#include <stdio.h>

long long a[1000005];

long long c[1000005];

int main(){

    long long  b;

    scanf("%lld",&b);

    for(int i=1;i<=b;i++)

    {

            scanf("%lld",&a[i]);

            c[i]=c[i-1]+a[i];

    }

        long long sum =0;

    for(int i=1;i<=b;i++)

         sum+=a[i]*c[i-1];

        printf("%lld\n",sum);

    return 0;

}

Measured memory_bytes: 2176
from fractions import gcd
n = int(input())
a = [int(x) for x in input().split(' ')]

L=[0]
for i in range(n):
  L.append(gcd(L[i],a[i]))

R=[0]
for i in range(n):
  R.append(gcd(R[i],a[n-i-1]))
  
M=[0]
for i in range(n):
  M.append(gcd(L[i],R[n-i-1]))
  
print(max(M))

Measured memory_bytes: 16144
// Math = ♥️

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

/*-------------------------------------------------------------------------------------------------------------------------*/
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> ii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<ii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
/*-------------------------------------------------------------------------------------------------------------------------*/

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

    ll r, c, n;
    cin >> r >> c >> n;

    vector<ii> seg;

    for (int i = 0; i < n; i++)
    {
        ll x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        ll flag = 0;
        if (x1 == 0 || x1 == r || y1 == 0 || y1 == c)
            flag++;
        if (x2 == 0 || x2 == r || y2 == 0 || y2 == c)
            flag++;

        if (flag == 2)
        {
            if (x1 == 0)
                seg.pb({y1, i});
            else if (y1 == c)
                seg.pb({c + x1, i});
            else if (x1 == r)
                seg.pb({r + c + (c - y1), i});
            else if (y1 == 0)
                seg.pb({r + (2 * c) + (r - x1), i});

            if (x2 == 0)
                seg.pb({y2, i});
            else if (y2 == c)
                seg.pb({c + x2, i});
            else if (x2 == r)
                seg.pb({r + c + (c - y2), i});
            else if (y2 == 0)
                seg.pb({r + (2 * c) + (r - x2), i});
        }
    }

    sort(all(seg));
    stack<ll> s;
    
    for (auto it: seg)
    {
        if (!s.empty() && s.top() == it.ss)
            s.pop();
        else
            s.push(it.ss);
    }

    if (s.empty())
        cout << "YES\n";
    else
        cout << "NO\n";
}


Measured memory_bytes: 6512