akhauriyash/Code-Regression huggingface dataset:
/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					/first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

void start(){
      #ifndef ONLINE_JUDGE 
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}

void solve()
{
 	ll n;cin>>n;
 	ll a[n+3],b[n];
 	rep0(i,n+1){
 		cin>>a[i];
	 }
	 rep0(i,n){
	 	cin>>b[i];
	 }
	 ll cnt=0;
	 rep0(i,n){
	 	if(b[i]<=a[i]){
	 		cnt+=b[i];
		 }
		 else{
		 	cnt+=a[i];
		 	ll l=b[i]-a[i];
		 	if(l<=a[i+1]){
		 		a[i+1]-=l;
		 		cnt+=l;
			 }
			 else{
			 	cnt+=a[i+1];
			 	a[i+1]=0;
			 }
		 }
	 }
	 cout << cnt << nl;
}

int main(){
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";

		  solve();
	//}
	
	return 0;
}


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

int main() {
  int N, l, r, x;
  x = 0;
  cin >> N;
  
  for (int i = 0; i < N; i ++) {
    cin >> l >> r;
    x += r - l + 1; 
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
using namespace std;
template<typename T>inline void read(T&x)
{
	T f;register char ch;x=0;f=1;
	for(ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x*10)+(ch^48);
	x*=f;
}

const int MAXN=1e5+7;

static int n,a[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]);
}

const int mod=1e9+7;

inline int power(int u,int v)
{
	static int sm;
	for(sm=1;v;v>>=1,u=1ll*u*u%mod)if(v&1)
		sm=1ll*sm*u%mod;
	return sm;
}

static int inv[MAXN];

static int ans;

inline void solve()
{
	inv[1]=1;
	Rep(i,2,n)inv[i]=mod-1ll*mod/i*inv[mod%i]%mod;
	Rep(i,2,n)inv[i]=(1ll*inv[i]+inv[i-1])%mod;
	Rep(i,1,n)ans=(ans+1ll*(inv[i]+inv[n-i+1]-1)*a[i]%mod)%mod;
	Rep(i,2,n)ans=1ll*ans*i%mod;
	cout<<ans<<endl;
}

int main()
{
	init();
	solve();
	return 0;
}

Measured memory_bytes: 1024
loop do
    a,op,b = gets.split.map &:to_s

    break if op == "?"

    a = a.to_i
    b = b.to_i

    if op == "+"
        puts a + b

    elsif op == "-"
        puts a - b

    elsif op == "*"
        puts a * b

    elsif op == "/"
        puts a / b

    end
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int n; cin >> n;
    cout << "Christmas ";
    rep(i,max(0,24-n)) cout << "Eve ";
    if (n <=24) cout << "Eve" << endl;
    else cout << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b;
        a-=d;
        //cout<<c<<" "<<a<<endl;
    }
    if(c<1){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	char t[100][100];
	char temp;
	int H,W,i,j,loopch;
	
	while(scanf("%d %d",&H,&W)){
		if(H==0&&W==0)
		break;
		string s;
		cin.ignore();
		for(i=0;i<H;i++){
			getline(cin,s);
			for(j=0;j<W;j++){
				t[i][j] = s[j];
			}
		}
		i=0;
		j=0;
		loopch=0;
		while(t[i][j]!='.'){
			if(t[i][j]=='>'){
				t[i][j]='*';
				j++;
			}
			else if(t[i][j]=='<'){
				t[i][j]='*';
				j--;
			}
			else if(t[i][j]=='^'){
				t[i][j]='*';
				i--;
			}
			else if(t[i][j]=='v'){
				t[i][j]='*';
				i++;
			}
			else if(t[i][j]=='*'){
				loopch=1;
				break;
			}
		}
		if(loopch!=1)
		printf("%d %d\n",j,i);
		else
		printf("LOOP\n");
	}
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define str string
#define s_vec(data,name,vertical,horizontal) vector<vector<(data)>> (name)((vertical),vector<(data)>((horizontal)));


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

    vector<int> k(m);
    vector<vector<int>> s(m,vector<int>(n));
    vector<int> p(m);

    for(int i=0;i<m;i++){
        cin>>k.at(i);
        for(int j=0;j<k.at(i);j++){
            cin>>s.at(i).at(j);
        }
    }
    for(int i=0;i<m;i++){
        cin>>p.at(i);
    }

    //全探索

    int co=0,ans=0;
    bool jd = true;

    for(int bits=0;bits<(1<<n);bits++){
        jd = true;
        for(int i=0;i<m;i++){
            co=0;
            for(int j=0;j<k.at(i);j++){
                if(bits&(1<<(s.at(i).at(j)-1)))co++;
            }
            if((co&1)^p.at(i)){
                jd = false;
                break;
            }
        }
        if(jd)ans++;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=700;
    if(s.at(0)=='o'){ans+=100;}
    if(s.at(1)=='o'){ans+=100;}
    if(s.at(2)=='o'){ans+=100;}
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

ll r, d, x;

void solve() {
    for (int i =1; i <= 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }
}

void input() {
    cin >>r >> d >> x;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    solve();
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> num(n + 1, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        num[a]++;
    }
    multiset<int> cnt;
    for (int i = 1; i <= n; i++) {
        if (num[i] != 0)
            cnt.insert(num[i]);
    }
    int toremove = cnt.size() - k;


    if (toremove <= 0)
        cout << 0 << endl;
    else {
        int ans = 0;
        auto beg = cnt.begin();
        for (int i = 0; i < toremove; i++) {
            ans += *beg;
            beg++;
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	int N;
	getval(N);

	const char* ans = "";
	switch (N % 10) {
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		ans = "hon\n";
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		ans = "pon\n";
		break;
	case 3:
		ans = "bon\n";
		break;
	}
	printf(ans);
}


Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

typedef long long int ll;
const int INF =INT32_MAX;


int N;
int h[100005];

int dp[100005];

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

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
  int num=1,a=1,b=1;
  while(1){
    scanf("%d %d %d",&num,&a,&b);
    if(num==0 && a==0 && b==0){
      break;
    }else{
      int i;
      int point[num];
      for(i=1; i<=num; i++){
        scanf("%d",&point[i]);
      }
      int sa=0;
      int max=0;
      int ba=0;
      for(i=a;i<b+1;i++){
        int d=point[i];
        int c=point[i+1];
        sa=c-d;
        sa=sa*(-1);
        if(sa>=max){
          max=sa;
          ba=i;
        }
      }
      printf("%d\n",ba);
    }
  }
  return 0;
}




Measured memory_bytes: 2044
# 偶数回移動を行うことを繰り返して定常状態になったら終了
# ..RL..が谷, ..LR..が山
# 山から次の山までの区間の要素数が谷に集まる

s = input()
child = [0 for _ in s]
# 山と谷の位置を見つける
y, t = [-1], []
for i in range(len(s)-1):
    if s[i] == 'L' and s[i+1] == 'R':
        y.append(i)
    if s[i] == 'R' and s[i+1] == 'L':
        t.append(i)
y.append(len(s)-1)
# 偶奇に分けて谷に集まる子を数える
for i in range(len(t)):
    if (y[i+1]-y[i]) % 2 == 0:
        child[t[i]] = child[t[i]+1] = (y[i+1]-y[i])//2
    else:
        if (t[i]-y[i]) % 2 == 0:
            child[t[i]] = (y[i+1]-y[i]-1)//2
            child[t[i]+1] = (y[i+1]-y[i]+1)//2
        else:
            child[t[i]] = (y[i+1]-y[i]+1)//2
            child[t[i]+1] = (y[i+1]-y[i]-1)//2

print(' '.join(map(str, child)))


Measured memory_bytes: 14476
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)



n = int(input())
print(n*(n+1)//2)



Measured memory_bytes: 21516
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)

#define INF 1000000000000000000
#define MOD 1000000007

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

long N;
long h, n, w;
long ans = 0;

int compare_long(const void *a, const void *b) {
  return *(long*)a - *(long*)b;
}

int gcd(int a, int b) {
  int c;

  if (a < b) {
    a+=b; b=a-b; a-=b;
  }

  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int main() {
  long i, j, k;
  long step;
  long tmp;

  sl(N);
  
  for(h=1;h<=3500;h++) {
    if(1.0 / h >= 4.0 / N) continue;
    for(n=1;n<=3500;n++) {
      if(1.0 / h + 1.0 / n >= 4.0 / N) continue;
      tmp = 4 * h * n;
      step = N / gcd(tmp, N);
      for(w=step;w<=3500;w+=step) {
        if(tmp * w / N == n*w + h*w + h*n) {
          printf("%ld %ld %ld\n", h, n, w);
          return 0;
        }
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

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

int main(){
	int n;
	cin >> n;
	if(n == 1) {
		cout << "Hello World" << endl;
	} else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}


Measured memory_bytes: 256
var x = require('fs').readFileSync('/dev/stdin/', 'utf8');
var row = x.split("\n");
for (var index in row){
    var i = row[index].split(" ").map(Number);
    var a = i[0]; b = i[1];
    if (a === 0 && b === 0) break; 
    else {
        console.log(i.sort(function(a, b){return a - b}).join(" "));
    }
}



Measured memory_bytes: 20544
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath> //abs();
using namespace std;
 
int main(void)
{
    int a,b,c,x[10],cnt=1;
  
    cin >> a >> b >> c;
 
    if(a!=b){
        cnt++;
        if(a!=c && b!=c){
            cnt++;
        }
        cout << cnt;
        return 0;
    }
    if(a!=c){
        cnt++;
        cout << cnt;
        return 0;
    } 
    cout << cnt;
    return 0;
}

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

using namespace std;

int main(){

    int n;
    cin >> n;

    double x[n],y[n];
    for(int i=0;i<n;i++)cin >> x[i] >> y[i];

    double s=0;
    double l=1;
    double k=1;

    while(l<n){
        k*=(l+1);
        l++;
    }


    int  o[n];
    for(int i=0;i<n;i++)o[i]=i;

    do{
        for(int i=0;i<n-1;i++){
            s+= sqrt((x[o[i]]-x[o[i+1]])*(x[o[i]]-x[o[i+1]])+(y[o[i]]-y[o[i+1]])*(y[o[i]]-y[o[i+1]])); 
        }
    } while (next_permutation(o, o+n));

    s = s/k;

    printf("%f",s);



}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
 struct Card{
   char suit;
   char value;
 };
 void bubble(struct Card A[],int N){
  int i,j;
   for(i=0;i<N;i++){
     for(j=N-1;j>=i+1;j--){
       if(A[j].value<A[j-1].value){
        struct Card t=A[j];
         A[j]=A[j-1];
         A[j-1]=t;
       }
     }
   }
 }
 
void selection(struct Card A[],int N){
int i,j;
  for(i=0;i<N;i++){
    int minj=i;
    for(j=i;j<N;j++){
      if(A[j].value<A[minj].value)minj=j;
    }
struct Card t=A[i];
A[i]=A[minj];
A[minj]=t;
  }
}
 
void print(struct Card A[],int N){
int i;
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%c%c",A[i].suit,A[i].value);
  }
printf("\n");
}
bool isS(struct Card C1[],struct Card C2[],int N){
int i;
for(i=0;i<N;i++){
  if(C1[i].suit != C2[i].suit)return false;
}
return true;
}
 
int main(){
  struct Card C1[100],C2[100];
  int N,i;
  char ch;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c %c",&C1[i].suit,&C1[i].value);
  }
for(i=0;i<N;i++)C2[i]=C1[i];
bubble(C1,N);
selection(C2,N);
 
print(C1,N);
printf("Stable\n");
print(C2,N);
if(isS(C1,C2,N)){
  printf("Stable\n");
}
else{
  printf("Not stable\n");
}
return 0;
}



Measured memory_bytes: 2028
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = []
check = {}
key = -1
p = 0
c = 0
t = 0
while True:
    ans.append(p)
    check[p] = 0
    p = a[p]-1
    c += 1
    if c == k:
        print(p+1)
        t = 1
        break
    if p in check:
        key = ans.index(p)
        break
if t == 0:
    if len(ans) == 1:
        print(a[0])
    else:
        r = ans[key:]
        mod = (k-key)%len(r)
        if mod == 0:
            print(r[0]+1)
        else:
            print(r[mod]+1)
#print(r[mod]+1)

Measured memory_bytes: 114236
A,B=$<.read.split.map(&:to_i)

def g(x,i)
    n = 1<<i
    m = 1<<(i-1)
    r,q = (x+1).divmod(n)
    r*m + [m - (n-q),0].max
end

ret = 0
1.upto(40) do |i|
   b = g(B,i)
   a = g(A-1,i)
   if (b-a).odd?
     ret += 1<<(i-1)
   end
end
p ret

Measured memory_bytes: 14360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

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

  int ans = 0;
  rep(i, N) ans += s[i];
  sort(all(s));
  
  if (ans % 10 != 0) {
    cout << ans << endl;
    return 0;
  }

  rep(i, N) {
    if (s[i] % 10 != 0) {
      cout << ans - s[i] << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.BigInteger;
public class Main {
    public static void main(final String[] args){
        final Scanner sc = new Scanner(System.in);
        
        long H = sc.nextLong();
        long W = sc.nextLong();
        sc.close();

        if (H > 1 && W > 1) {
            BigInteger n1 = new BigInteger(String.valueOf((H - 1) / 2 + 1));
            BigInteger n2 = new BigInteger(String.valueOf(H / 2));

            n1 = n1.multiply(new BigInteger(String.valueOf(W / 2 + W % 2)));
            n2 = n2.multiply(new BigInteger(String.valueOf(W / 2)));

            BigInteger sum = new BigInteger("0");
            sum = sum.add(n1);
            sum = sum.add(n2);

            System.out.println(sum);
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

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

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}


void solv() {
	
	ll n,k;
	cin >> n >> k;
	ll w[100010];
	ll sum = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> w[i];
		sum += w[i];
	}

	ll lo = 1;
	ll high = sum;
	int count = 0;
	while (count++ <= 50)
	{
		ll mid = (lo + high) / 2;
		ll v = 0;
		bool ok = true;
		int c = 0;
		for (int i = 0; i < n; i++)
		{

			if (mid < w[i]) {
				ok = false;
				break;
			}

			if (v == 0 || v + w[i] > mid) {
				v = w[i];
				c++;
			}
			else {
				v += w[i];
			}
		}


		if (!ok || c > k) {
			lo = mid;
		}
		else {
			high = mid;
		}
	}
	cout << high << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
/*lcm(gcd(N1, M), gcd(N2, M), ..., gcd(Nk, M)) = gcd(lcm(N1, ..., Nk), M)
gcd(lcm(N1, M), lcm(N2, M), ..., lcm(Nk, M)) = lcm(gcd(N1, ..., Nk), M).

If gcd(N1, N2) = 1, then
gcd(N1·N2, M) = gcd(N1, M)·gcd(N2, M)
lcm(N1·N2, M) = lcm(N1, M)·lcm(N2, M)/M.

lcm(M, N, P) · gcd(M, N) · gcd(N, P) · gcd(P, M) = NMP · gcd(N, M, P).
*/
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    ll n;
    cin>>n;
    ll a[n];
    ll cnt=0;
    ll mn = MOD;
    REP(i,n)
    {
        cin>>a[i];
        if(a[i]<0)
        cnt++;
        mn=min(mn,abs(a[i]));
    }
    ll sum=0;
    REP(i,n)
    {
        sum+=abs(a[i]);
    }
    if(cnt & 1)
    {
        sum-=mn*2;
    }
    cout<<sum;
  }  
  return 0;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (int vs ll?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

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

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll money = 1000;

    int n;
    cin >> n;

    int a[n];
    rep(i, n)
    {
        cin >> a[i];
    }

    rep(i, n-1)
    {
        if(a[i]<a[i+1])
        {
            money = money/a[i]*a[i+1]+money%a[i];
        }
        
    }

    cout << money << endl;


    return 0;

}



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

int main()
{
	int n = 0, m = 0, k = 0, t = 0;

	cin >> n >> m >> k;

	if (n > m) {
		t = n;
		n = m;
		m = t;
	}

	if (m > k) {
		t = m;
		m = k;
		k = t;
	}

	if (n > m) {
		t = n;
		n = m;
		m = t;
	}

	cout << n << " " << m << " " << k << endl;

    return 0;
}

Measured memory_bytes: 3080
S = int(input())
mod = 10**9+7
memo = [-1]*(S+1)
memo[0] = 1
def redis(s):
  if memo[s] != -1:
    return memo[s]
  else:
    if s < 3:
      memo[s] = 0
      return 0
    elif s < 6:
      memo[s] = 1
      return 1
    else:
      tmp = 0
      for num in range(s-2):
        tmp += redis(num)%mod
      memo[s] = tmp
      return tmp%mod
print(redis(S))
    




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

int n, k;
map<int, int> mp;
vector<int> v;

int solve();

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++mp[a];
  }
  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(auto it = mp.begin(); it != mp.end(); ++it)
    v.push_back(it->second);
  sort(v.begin(), v.end());
  for(int i = 0; i < (int)v.size() - k; ++i) ans += v[i];
  return ans;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

ll h, w, par[160000], Size[160000][2];
char c[400][400];

ll root(ll x) {
    if(par[x] == x) return x;
    return par[x] = root(par[x]);
}

signed main() {
    cin >> h >> w;
    rep(i, h) rep(j, w) {
        cin >> c[i][j];
        par[i * w + j] = i * w + j;
        Size[i * w + j][c[i][j] == '#'] = 1;
        if(i && c[i - 1][j] != c[i][j] &&
           root(i * w + j) != root(i * w + j - w)) {
            ll x = root(i * w + j), y = root(i * w + j - w);
            par[x] = y;
            Size[y][0] += Size[x][0];
            Size[y][1] += Size[x][1];
            Size[x][0] = Size[x][1] = 0;
        }
        if(j && c[i][j - 1] != c[i][j] &&
           root(i * w + j) != root(i * w + j - 1)) {
            ll x = root(i * w + j), y = root(i * w + j - 1);
            par[x] = y;
            Size[y][0] += Size[x][0];
            Size[y][1] += Size[x][1];
            Size[x][0] = Size[x][1] = 0;
        }
    }
    ll ans = 0;
    rep(i, w * h) {
        if(par[i] == i) {
            ans += Size[i][0] * Size[i][1];
        }
    }
    cout << ans << endl;
}

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

using namespace std;
#define ll long long


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

    ll a,b;
    cin>>a>>b;

    if( (a*4 >= b) && (a*2 <=b) && (b%2 == 0))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
#define INF 100000000
#define BLACK 0
#define WHITE 1
#define N 101
 
int n,a[N][N];

int prim(void)
{
  int u,v,i,mincost,d[N],pi[N],total = 0,color[N];
 
  for(u = 1;u <= n;u++){
    d[u] = INF;
    pi[u] = -1;
    color[u] = WHITE;
  }
 
  d[1] = 0;
     
  while(1){
    mincost = INF;
    for(i = 1;i <= n;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
     
    if(mincost == INF) break;
    
    color[u] = BLACK;
     
    for(v = 1;v <= n;v++){
      if(color[v] != BLACK && a[u][v] < d[v]){
	pi[v] = u;
	d[v] = a[u][v];
      }
    }
    color[v] = BLACK;
  }
 
  for(i = 1;i <= n; i++){
    if(pi[i] != -1) total += a[i][pi[i]];
  }
 
  return total;
}

 
int main()
{
  int i,j;
 
  scanf("%d",&n);
 
  for(i = 1;i <= n;i++){
    for(j = 1;j <= n;j++){
      scanf("%d",&a[i][j]);
      if(a[i][j] == -1) a[i][j] = INF;
    }
  }
 
   printf("%d\n",prim());
    
   return 0;
 
}
 

Measured memory_bytes: 2684
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou(bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  vector<int> kazu;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    kazu = vector<int>(n,1);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
      kazu.at(rx) += kazu.at(ry);
    }
    else{
      par.at(rx) = ry;
      kazu.at(ry) += kazu.at(rx);
    }
  }
  void newkazu(){
    int n = kazu.size();
    for(int i=0;i<n;i++){
      kazu.at(i) = kazu.at(root(i));
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<int> a(m),b(m);
  vector<int> c(k),d(k);
  for(int i=0;i<m;i++){
    cin >> a.at(i) >> b.at(i);
    a.at(i)--;b.at(i)--;
  }
  for(int i=0;i<k;i++){
    cin >> c.at(i) >> d.at(i);
    c.at(i)--;d.at(i)--;
  }
  vector<vector<int>> fr(n);
  for(int i=0;i<m;i++){
    int aa = a.at(i),bb = b.at(i);
    fr.at(aa).push_back(bb);
    fr.at(bb).push_back(aa);
  }
  unionfind tree(n);
  for(int i=0;i<m;i++){
    tree.unite(a.at(i),b.at(i));
  }
  tree.newkazu();
  for(int i=0;i<k;i++){
    int cc = c.at(i),dd = d.at(i);
    if(tree.same(cc,dd)){
      tree.kazu.at(cc)--;tree.kazu.at(dd)--;
    }
  }
  for(int i=0;i<n;i++){
    cout << tree.kazu.at(i) - fr.at(i).size() - 1 << ' ';
  }
  cout << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

inline int64 sumd(int64 x) {
	int64 res = 0;
	while(x) res += x%10, x/=10;
	return res;
}

bool cmp(int64 a, int64 b) {
	return a*sumd(b) < b*sumd(a);
}

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

	int64 K;
	cin >> K;
	vector<int64> v;
	int64 pow10 = 1;
	REP(i, 15){
		FOR(j, 1, 1000) {
			v.push_back(pow10-1+pow10*j);
		}
		pow10*=10;
	}
	sort(all(v));
	stable_sort(all(v), cmp);
	int64 maxi = 0;
	int64 cnt = 0, idx = 0;
	while(cnt < K) {
		if (maxi < v[idx]) {
			cout << v[idx] << endl;
			cnt++;
		}
		chmax(maxi, v[idx++]);
	}
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int n, sum, maxn;
string s; 
int main()
{
	cin >> n >> s;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'I') sum++;
		else sum--;
		maxn = max(maxn, sum);
	}
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=5e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int a[110];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=1;i<=(n-2);i++)
  {
    for(int j=i+1;j<=(n-1);j++)
    {
      for(int k=j+1;k<=n;k++)
      {
        int x=a[i],y=a[j],z=a[k];
        if(x!=y && y!=z && z!=x)
        {
          if((x+y)>z && (y+z)>x && (z+x)>y)
          {
            ++ans;
            // cout<<x<<" "<<y<<" "<<z<<endl;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
    static Map<Long, Long> mp = new HashMap<>();
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        long K = sc.nextLong();
        long sum = 0;
        for(long i=1;i<=K;i++){
            for(long j=1;j<=K;j++){
                for(long k=1;k<=K;k++){
                    sum += gcd(gcd(i,j),k);
                }
            }
        }
        System.out.println(sum);
    }


    private static long gcd(long a, long b){
        if(a < b){
            long tmp = a;
            a = b;
            b = tmp;
        }
        long key = a*1000+b;
        if(mp.containsKey(key)){
            return mp.get(key);
        }
        if(a % b == 0){
            return b;
        }
        long ans = gcd(b, a-b);;
        mp.put(key, ans);
        return ans;
    }
}


Measured memory_bytes: 59988
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    row_n = [0 for _ in range(h)]
    col_n = [0 for _ in range(w)]
    for t in targets:
        row_n[t[0] - 1] += 1
        col_n[t[1] - 1] += 1
    max_r = max(row_n)
    max_c = max(col_n)
    mrow = [i for i in range(h) if row_n[i] == max_r]
    mcol = [i for i in range(w) if col_n[i] == max_c]
    for i in mrow:
        for j in mcol:
            if not i * h + j in tgs:
                print(max_r + max_c)
                exit()
    print max_r + max_c - 1
    return





h, w, m = RA()
targets = [RA() for _ in range(m)]
tgs = [(i[0]-1) * h + (i[1]-1) for i in targets]
tgs = set(tgs)
solve()


Measured memory_bytes: 170912
N = int(input())
ans = [0] * (N + 1)   

for i in range(1, 100):
    for j in range(1, 100):
        for k in range(1, 100):
            a = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if a <= N:
                ans[a]+=1
                
for i in range(1, N+1):
    print(ans[i])

Measured memory_bytes: 9060
import java.util.Scanner;

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

		char[] firstList = sc.next().toCharArray();
		char[] secondList = sc.next().toCharArray();
		char[] thirdList = sc.next().toCharArray();
		System.out.print(firstList[0]);
		System.out.print(secondList[1]);
		System.out.print(thirdList[2]);

	}
}


Measured memory_bytes: 23252
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy

ans = "" 
ans += 'U' * dy + 'R' * dx 
ans += 'D' * dy + 'L' * dx
ans += 'L'
ans += 'U' * (dy + 1) + 'R' * (dx + 1)
ans += 'D'
ans += 'R'
ans += 'D' * (dy + 1) + 'L' * (dx + 1)
ans += 'U'

print(ans)

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

int main() {
    int H, W;
    cin >> H >> W;
    if (H>50 || W>50) exit(0);
    
    string S[60];
    for (int i=1; i<H+1; i++) {
        cin >> S[i];
        S[i] = "." + S[i]+".";
    }
    S[0] = S[H+1] = "";

    int M[60][60];
    for (int i=0; i<H+2; i++) {
        for (int j=0; j<W+2; j++) {
            if ((S[i])[j] == '#')M[i][j]=1;
            else M[i][j] = 0;
        }
    }
    
    int L[60][60];
    for (int i=1; i<H+1; i++) {
        for (int j=1; j<W+1; j++) {
            if (M[i][j]==0) {
            L[i][j] = M[i][j-1]+M[i][j+1]+M[i-1][j-1]+M[i-1][j]+M[i-1][j+1]+M[i+1][j-1]+M[i+1][j]+M[i+1][j+1];
            }
        }
    }
    
    for (int i=1; i<H+1; i++) {
        for (int j=1; j<W+1; j++) {
            if ((S[i])[j] == '#') cout << (S[i])[j];
            else cout << L[i][j];
            
            if (j==W) cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def sumdigit(n)
  if n < 10
    return n
  else
    return sumdigit(n / 10) + n % 10
  end
end
while (arg = gets)
  arg = arg.split(" ").map(&:to_i)
  puts sumdigit((arg[0] % arg[1] * 10 ** arg[2]) / arg[1])
end

Measured memory_bytes: 6120
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace GoToJail
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int zoromeCounter = 0;
            for (int i = 0; i < N; i++)
            {
                int[] dice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (dice[0] == dice[1])
                {
                    zoromeCounter++;
                    if (zoromeCounter == 3)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                }
                else
                {
                    zoromeCounter = 0;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 28244
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N-1)]

# 鉄道種類ループ
for i in range(N):
    T = 0
    # 鉄道乗り継ぎループ
    for j in range(i, N-1):
        if T < CSF[j][1]:
            T = CSF[j][1]
        else:
            if T % CSF[j][2] != 0:
                T += (CSF[j][2] - T % CSF[j][2])
        T += CSF[j][0]
    print(T)



Measured memory_bytes: 3188
while(<>){
	chomp;
	@a = split(//, $_) if($. == 1);
	@b = split(//, $_) if($. == 2);
	@c = split(//, $_) if($. == 3);
}

$f = shift(@a);
$r = "";
while(1){
	if($f eq 'a'){
		if(scalar(@a) == 0){
			$r = "A";
			last;
		}
		$f = shift(@a);
	}elsif($f eq 'b'){
		if(scalar(@b) == 0){
			$r = "B";
			last;
		}
		$f = shift(@b);
	}else{
		if(scalar(@c) == 0){
			$r = "C";
			last;
		}
		$f = shift(@c);
	}
}

print "$r\n";


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)
#define all(x) x.begin(), x.end()
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;

int32_t main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    int d[k + 1];
    memset(d, -1, sizeof(int) * (k + 1));
    FOR(i, 0, n) {
        cin >> a[i];
        d[a[i]] = 1;
    }
    d[0] = 0;
    FOR(i, 1, k + 1) {
        if(d[i] != -1) {
            continue;
        }
        d[i] = 0;
        FOR(j, 0, n) {
            if (i - a[j] >= 0 && d[i - a[j]] == 0) {
                d[i] = 1;
                break;
            }
        }
    }
    if (d[k]) {
        cout << "First";
    }
    else {
        cout << "Second";
    }
    return 0;
}

Measured memory_bytes: 4252
#include <stdio.h>
int main(void){
  int x,y,k,s,i,j,n;
  n = 0;
  scanf("%d %d",&k,&s);
  for(i=0;i<=k;i++){
    x=i;
    for(j=0;j<=k;j++){
      y=j;
      if((s-x-y)<=k && (s-x-y)>=0 ){
	n++;
      }
    }
  }
  printf("%d",n);
}


Measured memory_bytes: 128
S = gets.chomp
Q = gets.to_i

flip_cnt = 0

head = []
tail = []

Q.times do
  t, f, c = gets.chomp.split

  if t == '1'
    flip_cnt += 1
  else
    if f == '1'
      if flip_cnt % 2 == 0
        head.unshift(c)
      else
        tail.push(c)
      end
    else
      if flip_cnt % 2 == 0
        tail.push(c)
      else
        head.unshift(c)
      end
    end
  end
end

if flip_cnt % 2 == 0
  puts head.join + S + tail.join
else
  puts (head.join + S + tail.join).reverse
end


Measured memory_bytes: 17276
//BISMILLAHIR RAHMANIR RAHIM

#include <bits/stdc++.h>
#define loop(i,n) for(int i=0;i<n;i++)
#define pi acos(-1.00)

using namespace std;



int main()
{
long long int a[4],i,count=0,p=0;
for(i=0;i<3;i++)
    cin>>a[i];
for(i=0;i<3;i++)
{
    if(a[i]==5)
        count++;
    else if(a[i]==7)
        p++;
}
if(count==2&&p==1)
    cout<<"YES"<<endl;
else
    cout<<"NO"<<endl;
}



Measured memory_bytes: 3552
#include <iostream>
using namespace std;
struct T{
    int parent,right,left,degree,sibling,depth,height;
};
void maketree(T tree[]){
    int node,l,r;
    cin>>node>>l>>r;
    tree[node].left=l;
    tree[node].right=r;
    tree[l].parent=node;
    tree[r].parent=node;
    tree[l].sibling=r;
    tree[r].sibling=l;
}
void depth(int i,T tree[]){
    if(tree[i].parent==-1){
        tree[i].depth=0;
        return;
    }
    if(tree[i].depth==-1){
        depth(tree[i].parent,tree);
        tree[i].depth=tree[tree[i].parent].depth+1;
    }
}
void height(int x,T tree[]){
    int l=tree[x].left;
    int r=tree[x].right;
    if(tree[x].degree==0){
        tree[x].height=0;
        return;
    }
    if(tree[x].height==-1){
        if(l!=-1){
          height(l,tree);
          tree[x].height=max(tree[x].height,tree[l].height+1);
        }
        if(r!=-1){
          height(r,tree);
          tree[x].height=max(tree[x].height,tree[r].height+1);
        }
    }
}
int main(){
    int n;
    T tree[100000];
    cin>>n;
    for(int i=0;i<n;i++){
        tree[i].parent=-1;
        tree[i].right=-1;
        tree[i].left=-1;
        tree[i].sibling=-1;
        tree[i].degree=0;
        tree[i].depth=-1;
        tree[i].height=-1;
    }
    for(int i=0;i<n;i++){
        maketree(tree);
    }
    for(int i=0;i<n;i++){
        if(tree[i].left==-1 && tree[i].right==-1){
            tree[i].degree=0;
        }
        else if(tree[i].left!=-1 && tree[i].right!=-1){
            tree[i].degree=2;
        }
        else{
            tree[i].degree=1;
        }
    }
    for(int i=0;i<n;i++){
        depth(i,tree);
        height(i,tree);
    }
    for(int i=0;i<n;i++){
        cout<<"node "<<i<<": "<<"parent = "<<tree[i].parent<<", sibling = "<<tree[i].sibling<<", degree = "<<tree[i].degree<<", depth = "<<tree[i].depth<<", height = "<<tree[i].height;
        if(tree[i].depth==0){
            cout<<", root"<<endl;
        }
        else if(tree[i].height==0){
            cout<<", leaf"<<endl;
        }
        else{
            cout<<", internal node"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3128
#include <stdio.h>
int main (void)
{
	int a[10000], min, max, n, i;
	long long sum = 0;
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		sum += a[i];
	}
	max = min = a[0];
	for(i = 1; i < n; i++)
	{
		if(a[i] > max)max = a[i];
		if(a[i] < min)min = a[i];
	}
	printf("%d %d %lld\n", min, max, sum);
	
	return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
using namespace std;

int main(){
    long long x;
    cin >> x;

    set<long long> T;

    for(long long i = 1; i <= 100; i++){
        for(long long j = 2; j <= 10; j++){
            long long a = (long long)pow(i, j);
            if(a <= x){
                T.insert(a);
            }
        }
    }

    set<long long>::iterator it;
    it = T.end();
    it--;
    cout << *it << endl;

    return 0;
}

Measured memory_bytes: 384
from collections import Counter
import sys
def zur(z, xx):
    c = 0
    k = 0
    i = 0
    while True:
        i += 1
        if i in xx:
            c += 1
        else:
            k += 1
        if k == z:
            return z + c

def xxxxx(z, xx):
    if z not in xx:
        return z
    while True:
        z -= 1
        if z == 0:
            print(-1)
            sys.exit()
        if z not in xx:
            return z

def mkxp(xs):
    xp = {}
    for i, x in enumerate(xs):
        i = i+1
        if x > i:
            print(-1)
            sys.exit()
        if x not in xp:
            xp[x] = list()
        xp[x].append(i)
    return xp

i = input()
xs = [int(x) for x in input().strip().split(" ")]
xp = mkxp(xs)


x = max(xs)
xo = []
xx = set()

while True:
    last = len(xs)
    if x == 0:
        break
    nxx = set()
    if x in xp:
        for i in xp[x]:
            xxx = zur(x + last - i, xx)
            xo.append((xxx, x))
            nxx.add(xxx)
        last -= len(xp[x])
    xx = nxx | xx
    xs = [int(i) for i in xs if i != x]
    xp = mkxp(xs)
    x -= 1

for i, x in sorted(xo, key=lambda x:x[0]):
    print(x)


Measured memory_bytes: 3316