akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define REP3(i,x,n) for(int i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll X;
    cin >> X;
    vector<ll> v;
    if(X == 1){v.push_back(1);}
    else{
        for(ll i = 1; i < sqrt(X);i++){
            if (X%i == 0){
                v.push_back(i);
                v.push_back(X/i);
                
            }
        }
    }
    for(auto x : v){
        for(ll a = 0;pow(a,4) < X; a++){
            ll b = a-x;
            if(pow(a,5)-pow(b,5)==X){
                cout << a << " " <<b << endl;
                break; 
            }
        }
    }
    return 0;
}

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

int main() {
  string a;
  cin >> a;
  if((a.at(0) == a.at(1) && a.at(0) == a.at(2)) || (a.at(1) == a.at(2) && a.at(1) == a.at(3))){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import itertools
INF = 1e10

N, A, B, C = map(int, input().split())
L = [int(input()) for _ in range(N)]

ans = INF
for prod in itertools.product('NABC', repeat=N):
    if not ('A' in prod and 'B' in prod and 'C' in prod):
        continue

    D = {'A': [], 'B': [], 'C': [], 'N': []}
    for i in range(N):
        D[prod[i]].append(L[i])

    tmp = (len(D['A']) - 1) * 10 + abs(sum(D['A']) - A)
    tmp += (len(D['B']) - 1) * 10 + abs(sum(D['B']) - B)
    tmp += (len(D['C']) - 1) * 10 + abs(sum(D['C']) - C)
    ans = min(ans, tmp)

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main() {
    int n, k, q, a[2001]{}, b[2001]{}, c[2001]{};
    cin >> n >> k >> q;
    REP(i, n) {
        cin >> a[i];
        c[i] = a[i];
    }
    REP(i, n - k + 1) {
        int amin = int(1e9) + 1;
        REP(j, k) amin = min(amin, a[i + j]);
        b[i] = amin;
    }
    sort(a, a + n);
    int ans = a[q - 1] - a[0];
    REP(i, n) {
        vector<int> ls;
        int l = 0, r = 0;
        REP(j, n - k + 2) {
            if (b[j] > a[i]) {
                r = j + 1;
            } else {
                if (r > l) {
                    vector<int> tmp;
                    FOR(m, l, r + k - 1) tmp.push_back(c[m]);
                    sort(tmp.begin(), tmp.end());
                    REP(m, r - l) ls.push_back(tmp[m]);
                }
                l = j + 1;
            }
        }
        if (ls.size() < q) break;
        sort(ls.begin(), ls.end());
        ans = min(ans, ls[q - 1] - ls[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//AtCoder ABC058 B - ∵∴∵
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    string O,E;
    cin>>O>>E;
    for(int i=0;i<O.size();++i){
        cout<<O[i];
        if (i<E.size()) cout<<E[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
//
//Created by just_sort 2016/10/1 14:00
//Copyright (c) 2016 just_sort.All Rights Reserved
//

#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e5+10;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(a[a[i]] == i) ans++;
    }
    printf("%d\n",ans/2);
}


Measured memory_bytes: 640
// Author - Sumit

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define int ll
#define ps push
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
#define mp make_pair
#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 all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pair<int,int>>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;


void solve(){
    int n,m;
    cin>>n>>m;
    char a[n][m];
    rep(i,0,n)
        rep(j,0,m)
            cin>>a[i][j];

    int dp[n][m];
    memset(dp,0,sizeof(dp));
    rep(i,0,m){
        if(a[0][i]=='#'){
            break;
        }
        dp[0][i] = 1;
    }
    rep(i,0,n){
        if(a[i][0]=='#'){
            break;
        }
        dp[i][0] = 1;
    }
    rep(i,1,n){
        rep(j,1,m){
            if(a[i][j]=='.')
                dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
        }
    }
    // rep(i,0,n){
    //     rep(j,0,m){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    debug(dp[n-1][m-1]);
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    // cin>>t;
    WL(t){
        solve();
    }    
}

Measured memory_bytes: 9088
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		boolean aa = false;
		// 奇数のみのときtrue
		boolean bb = true;
		for(int i=0; i<N; i++) {
			int a = Integer.parseInt(sc.next());
			if(a % 2 == 0) {
				bb = false;
				if(a % 3 == 0 || a% 5==0) {
					aa = true;
				} else {
					aa = false;
					break;
				}
			}
		}
		System.out.println(aa || bb ? "APPROVED": "DENIED");

	}
}


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

int main(){
  int S_length=0,count_a=0,count_b=0,count_c=0;
  char S[100001];
  scanf("%s",S);
  while (S[S_length]!='\0'){ S_length++; }


for (int i = 0; i < S_length; i++)
{
  switch (S[i])
  {
  case 'a':
    count_a++;
    break;
  case 'b':
    count_b++;
    break;
  case 'c':
    count_c++;
    break;
  }
}

if (abs(count_a-count_b)<2&&
    abs(count_a-count_c)<2&&
    abs(count_b-count_c)<2  )
{
  puts("YES");
}else
{
  puts("NO");
}

  return 0;
}

Measured memory_bytes: 1712
#include<iostream>
#include<algorithm>
using namespace std;
int dp[100010][3];
int a[100010][3];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for(int i = 0; i < 3; i++)
        dp[0][i] = a[0][i];
    for(int i = 1; i < n; i++)
    {
        dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = a[i][2] + max(dp[i-1][1], dp[i-1][0]);
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 2560
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

MOD = 10**9+7

n,m = get_nums_l()
if n%2 == 1:
    for l in range(1,m+1):
        r = n - l + 1
        print(l, r)
else:
    # n -= 1
    for l in range(1,m+1):
        r = n - l + 1
        if r-l <= n//2:
            r-=1
        print(l, r)


Measured memory_bytes: 75744
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }

void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}
#define P 1000000007
int a[200000];
int b[200000];
int al, bl;
int main(void){
	int n=nextint();
	int k=nextint();
	for(int i=0; i<n; i++){
		int s=nextint();
		if(s>=0){
			a[al++]=s;
		}else{
			b[bl++]=-s;
		}
	}
	rsorta_d32(a, al, 1, 0);
	rsorta_d32(b, bl, 1, 0);
	long ans=1;
	if(n==k){
		for(int i=0; i<al; i++){
			ans=ans*a[i]%P;
		}
		for(int i=0; i<bl; i++){
			ans=ans*b[i]%P;
		}
		if(bl%2==1) ans=-ans;
	}else if(k%2==1 && al==0){
		for(int i=0; i<k; i++){
			ans=ans*b[i]%P;
		}
		ans=-ans;
	}else{
		while(k>1){
			if(al<2){
				ans=ans*b[--bl]%P;
				ans=ans*b[--bl]%P;
				k-=2;
			}else if(bl<2){
				ans=ans*a[--al]%P;
				k--;
			}else if((long)a[al-1]*a[al-2]<(long)b[bl-1]*b[bl-2]){
				ans=ans*b[--bl]%P;
				ans=ans*b[--bl]%P;
				k-=2;
			}else{
				ans=ans*a[--al]%P;
				k--;
			}
		}
		if(k==1){
			ans=ans*a[--al]%P;
		}
	}
	ans=(ans+P)%P;
	printf("%ld\n", ans);
}


Measured memory_bytes: 2848
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (S == U)
        cout << A - 1 << " " << B << endl;
    else
        cout << A << " " << B - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        Rep (i, N) par[i] = i;
    }

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

    void unite (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same (ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

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

    ll N, K, L;
    cin >> N >> K >> L;
    UnionFind road(N), rail(N);
    while (K--) {
        ll p, q;
        cin >> p >> q;
        p--; q--;
        road.unite(p, q);
    }
    while (L--) {
        ll r, s;
        cin >> r >> s;
        r--; s--;
        rail.unite(r, s);
    }

    map<pair<ll, ll>, ll> m;
    Rep (i, N) {
        m[{road.root(i), rail.root(i)}]++;
    }
    
    Rep (i, N) {
        cout << m[{road.root(i), rail.root(i)}] << " \n"[i==N-1];
    }

}

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

char s[200010];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int flag=1;
	if(s[1]=='0'||s[n]=='1') flag=0;
	for(int i=1;i<n;i++) if(s[i]!=s[n-i]) flag=0;
	if(!flag)
	{
		puts("-1");
		return 0; 
	}
	int now=1;
	for(int i=2;i<=n;i++)
	{
		printf("%d %d\n",now,i);
		if(s[i-1]=='1') now=i;
	}
}

Measured memory_bytes: 3932
#include <stdio.h>

int main()
{
	int i, n, p[21], count = 0;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) scanf("%d", &(p[i]));
	for (i = 2; i < n; i++) if ((p[i] - p[i-1]) * (p[i+1] - p[i]) > 0) count++;
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1692
# -*- coding: utf-8 -*-
nontastyDetox, tastyDedox, tastyToxic = map(int, input().split())

if nontastyDetox + tastyDedox + 1 >= tastyToxic:
	print(tastyDedox + tastyToxic)
else:
	print(nontastyDetox + 2 * tastyDedox + 1)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <limits.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
#define INF LLONG_MAX/3
#define inf INT_MAX/3
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a % MOD;
	if (b % 2)return modpow(a, b - 1)*a%MOD;
	else return modpow(a, b / 2)*modpow(a, b / 2) % MOD;
}
int comb(int a, int b) {
	if (b == 0 || a == b)return 1;
	if (b == 1)return a % MOD;
	return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD;
}
// Library End !
int h, w, n, a, b[100000];
int sum = 1;
int main() {
	cin >> h >> w >> n;
	rep(i, n) {
		b[sum]++;
		cin >> a;
		sum += a;
	}
	for (int i = 1;i <= h * w;i++)b[i] += b[i - 1];
	rep(i, h) {
		rep(j, w - 1) {
			if (i % 2)cout << b[(i*w) + w - j] << " ";
			else cout << b[(i*w) + j + 1] << " ";
		}
		if (i % 2)cout << b[i*w + 1] << endl;
		else cout << b[(i + 1)*w] << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=510;
int mod;
inline void Add(int &x,int y) { x=(x%mod+mod)%mod,y=(y%mod+mod)%mod; x=(x+y)%mod; } //x+=y; if(x>=mod) x-=mod; }
inline void Dec(int &x,int y) { x=(x%mod+mod)%mod,y=(y%mod+mod)%mod; x=(x-y+mod)%mod; } //x-=y; if(x<0) x+=mod; }
int n;
int f[N],g[N];
int bel[N],id[N];
int getr(int x) { return bel[x]?f[x]:g[x]; }
bool cmp(int x,int y) {
	int h1=getr(x),h2=getr(y);
	if(h1==h2) return x>y; // ?!
	return h1<h2; 
}
int ans;
int dp[N][N];
void solve(int k) {
	memset(dp,0,sizeof(dp));
	dp[0][0]=getr(id[0])+1;
	if(bel[id[0]]&&k&&g[id[0]]+1-(2*n-k)>0) dp[0][1]=g[id[0]]+1-(2*n-k);
	for(int i=1;i<2*n;++i)
		for(int j=0;j<=i&&j<=k;++j) if(dp[i-1][j]) {
			if(getr(id[i])+1-(i-j)>0) Add(dp[i][j],dp[i-1][j]*(ll)(getr(id[i])+1-(i-j))%mod);
			if(bel[id[i]]&&j<k&&g[id[i]]+1-(2*n-k+j)>0) Add(dp[i][j+1],dp[i-1][j]*(ll)(g[id[i]]+1-(2*n-k+j))%mod);
		}
//	cout<<k<<":"<<endl;
//	for(int i=0;i<2*n;++i,puts(""))
//		for(int j=0;j<=k;++j) printf("%d ",dp[i][j]); 
//	cout<<k<<' '<<dp[2*n-1][k]<<endl;
	if((n-k)&1) Dec(ans,dp[2*n-1][k]);
	else Add(ans,dp[2*n-1][k]);
}
int main() {
	rd(n),rd(mod);
	for(int i=0;i<2*n;++i) {
		f[i]=i<n?(ceil(sqrt(n*n-i*i))-1):-1;
		g[i]=min(2*n-1,(int)floor(sqrt(4*n*n-i*i)));
		bel[i]=f[i]>=0;
		id[i]=i;
//		cout<<i<<':'<<' '<<f[i]<<' '<<g[i]<<endl;
	}
	sort(id,id+n*2,cmp);
//	for(int i=0;i<2*n;++i) printf("%d : %d %d %d\n",id[i],bel[id[i]],f[id[i]],g[id[i]]);
//	for(int i=0;i<2*n;++i) printf("%d ",id[i]); puts("");
	for(int i=0;i<=n;++i) solve(i);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <queue>
using namespace std;
int main(){
  int n,a=0,b=0;
  cin>>n;
  while(n--){
    string s1,s2;
    cin>>s1>>s2;
    if(s1>s2)a+=3;
    else if(s1<s2)b+=3;
    else {a++;b++;}
  }
  cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;

int main(){
	IOS
	int x, n, sums=0;
	cin >> x >> n;
	while(n--){
		int a;
		cin >> a;
		sums+=a;
	}
	if(sums>=x){
		cout << "Yes" << '\n';
	}
	else{
		cout << "No" << '\n';
	}
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string N;
    cin >> N;
    if(N[N.size()-1] == '2' || N[N.size()-1] == '4' || N[N.size()-1] == '5' || N[N.size()-1] == '7' || N[N.size()-1] == '9') cout << "hon" << endl;
    else if (N[N.size()-1] == '3') cout << "bon" << endl;
    else cout << "pon" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long> A(N);
    for(int i=0; i<N; i++){
        cin >> A.at(i);
    }

    int cnt = 0; //負の数が奇数のとき1になる

    for(int i=0; i<N; i++){
        if(A.at(i) < 0){
            cnt = 1 - cnt;
        }
    }
    long abs_sum=0;
    for(int i=0; i<N; i++){
            abs_sum = abs_sum + abs(A.at(i));
        }

    long ans;
    if(!cnt){
        ans = abs_sum;
    }
    else{ //絶対値のminを知りたい
    long abs_min=pow(10,9);
        for(int i=0; i<N; i++){
            abs_min = min( abs_min, abs(A.at(i)) );
        }
    ans = abs_sum - 2*abs_min;
    }
    cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

struct Edge {
  const int from, to, id;
  Edge(int from, int to, int id) : from(from), to(to), id(id) {}
};

const pair<vector<int>, vector<int>> EMPTY_PAIR = make_pair(vector<int>(), vector<int>());

pair<vector<int>, vector<int>> Solve() {
  int n, m;
  cin >> n >> m;
  vector<int> v_values(n);
  map<int, vector<int>> value_to_vs;
  for (int i = 0; i < n; i++) {
    cin >> v_values[i];
    value_to_vs[v_values[i]].push_back(i);
  }

  vector<vector<Edge>> graph(n);
  vector<Edge> edges;
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--;
    v2--;
    graph[v1].push_back(Edge(v1, v2, i));
    graph[v2].push_back(Edge(v2, v1, i));
    edges.push_back(Edge(v1, v2, i));
  }

  vector<int> edge_weights(m);
  for (int i = 0; i < m; i++) {
    edge_weights[i] = max(v_values[edges[i].from], v_values[edges[i].to]);
  }

  vector<int> colors(n, -1);
  for (int v = 0; v < n; v++) {
    bool valid = false;
    for (const auto& edge : graph[v]) {
      if (edge_weights[edge.id] == v_values[v]) {
        valid = true;
      }
    }
    if (!valid) return EMPTY_PAIR;
  }

  for (const auto& value_vs : value_to_vs) {
    int value;
    vector<int> vs;
    tie(value, vs) = value_vs;

    function<void(int)> dfs_fn = [&](int v) {
      for (const auto& edge : graph[v]) {
        if (v_values[edge.to] == value && colors[edge.to] < 0) {
          colors[edge.to] = 1 - colors[v];
          dfs_fn(edge.to);
        }
      }
    };

    for (int v : vs) {
      if (colors[v] < 0) {
        for (const auto& edge: graph[v]) {
          if (edge_weights[edge.id] == value && colors[edge.to] >= 0) {
            colors[v] = 1 - colors[edge.to];
            dfs_fn(v);
            break;
          }
        }
      }
    }
    for (int v : vs) {
      if (colors[v] < 0) {
        colors[v] = 0;
        dfs_fn(v);
      }
    }
  }

  for (int v = 0; v < n; v++) {
    if (colors[v] < 0) {
      cerr << "colors[v] < 0 at v = " << v << endl;
      exit(1);
    }
  }

  for (int v = 0; v < n; v++) {
    bool valid = false;
    for (const auto& edge : graph[v]) {
      if (edge_weights[edge.id] == v_values[v] && colors[edge.to] != colors[v]) {
        valid = true;
      }
    }
    if (!valid) {
      cerr << "Invalid at v = " << v << endl;
      exit(1);
    }
  }

  return make_pair(colors, edge_weights);
}

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

  vector<int> colors, edge_weights;
  tie(colors, edge_weights) = Solve();
  if (colors.empty()) {
    cout << -1 << endl;
  } else {
    for (int color: colors) {
      cout << "WB"[color];
    }
    cout << endl;
    for (int edge_weight : edge_weights) {
      cout << edge_weight << endl;
    }
  }
}

Measured memory_bytes: 25264
#グラフ上でのBFS
#s=始点 n=頂点数 e=隣接リスト
def glaph_bfs(s,n,e):
  Q=[s]
  visited={s}
  while Q:
    P=[]
    for i in Q:
      for j,_ in e[i]:
        if j in visited:continue
        visited.add(j)
        P.append(j)
    Q=P
  return visited
  

#負の閉路検出
#n=頂点数 e=[[a,b,c],[]...](a~bの距離がc)
def find_negative_loop(n,e):
	d=n*[10**20];d[0]=0
	for h in range(n):
		for i,j,k in e:
			if d[j]>d[i]+k:
				d[j]=d[i]+k
				if h==n-1:return True
	return False

#ベルマンフォード(d[i]=頂点sから頂点iの最短距離)
#単一始点最短経路(負の辺対応)
#s=始点 n=頂点数 e=[[a,b,c],[]...](a~bの距離がc)
def bellman_ford(s,n,e):
  inf=10**20;d=[inf]*n;d[s]=0
  while 1:
    f=True
    for i,j,k in e:
      if d[i]!=inf and d[j]>d[i]+k:d[j]=d[i]+k;f=False
    if f:break
  return d

n,m,p=map(int,input().split())
edge=[[]for _ in range(n)]
edger=[[]for _ in range(n)]
for _ in range(m):
  a,b,c=map(int,input().split())
  c-=p
  a-=1
  b-=1
  edge[a].append((b,c))
  edger[b].append((a,c))
visited=glaph_bfs(0,n,edge)
visitedr=glaph_bfs(n-1,n,edger)
for i in range(n):
  if not(i in visited and i in visitedr):edge[i]=[]
e=[]
for i in range(n):
  for j in range(len(edge[i])):e.append((i,edge[i][j][0],-edge[i][j][1]))
if find_negative_loop(n,e):print(-1);exit()
print(max(-bellman_ford(0,n,e)[n-1],0))

Measured memory_bytes: 54872
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>

long long INF=1000000000;
int H, W, sy, sx, ey, ex;

void bfs(std::vector<std::string> &m, std::vector<std::vector<int>> &cnt, std::deque<std::pair<int, int>> &deq)
{
    deq.push_front({sy, sx});
    cnt.at(sy).at(sx)=0;
    int dir[5]={1,0,-1,0,1};
    std::vector<std::pair<int, int>> warp = {{-2, -2},{-2, -1},{-2, 0},{-2, 1},{-2, 2},
                                            {-1, -2},{-1, -1},{-1, 1},{-1, 2},
                                            {0, -2},{0, 2},
                                            {1, -2},{1, -1},{1, 1},{1, 2},
                                            {2, -2},{2, -1},{2, 0},{2, 1},{2, 2}};

    while (!deq.empty())
    {
        int y,x;
        std::tie(y,x)=deq.front();
        deq.pop_front();

        
        for (int i=0; i<4; i++)
        {
            int ny=y+dir[i];
            int nx=x+dir[i+1];
            if (ny<0||ny>=H||nx<0||nx>=W) continue;
            if (m.at(ny).at(nx)=='#') continue;
            if (cnt.at(ny).at(nx)>cnt.at(y).at(x))
            {
                cnt.at(ny).at(nx)=cnt.at(y).at(x);
                deq.push_front({ny,nx});
            }
        }

        for (std::pair<int, int> &p: warp)
        {
            int i, j;
            std::tie(i,j)=p;

            int ny=y+i;
            int nx=x+j;
            if (ny<0||ny>=H||nx<0||nx>=W) continue;
            if (m.at(ny).at(nx)=='#') continue;
            if (cnt.at(ny).at(nx)>cnt.at(y).at(x)+1)
            {
                cnt.at(ny).at(nx)=cnt.at(y).at(x)+1;
                deq.push_back({ny,nx});
            }
        }

    } 
}

int main()
{
    std::cin>>H>>W>>sy>>sx>>ey>>ex;
    sy--, sx--, ey--, ex--;

    std::vector<std::string> m(H);
    // std::vector<std::vector<char>> m(H, std::vector<char>(W));
    std::vector<std::vector<int>> cnt(H, std::vector<int>(W,INF));
    std::deque<std::pair<int, int>> deq;

    for (int i=0; i<H; i++) std::cin>>m.at(i);
    // for (auto &s: m) std::cin>>s;
    // for (int i=0;i<H;i++)
    // {
    //     for (int j=0;j<W;j++)
    //     {
    //         std::cin>>m.at(i).at(j);
    //     }
    // }
    bfs(m, cnt, deq);
    if (cnt.at(ey).at(ex)==INF) 
        std::cout << -1 << std::endl;
    else 
        std::cout << cnt.at(ey).at(ex) << std::endl;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - FizzBuzz Sum
            long N = long.Parse(Console.ReadLine());
            long ans = 0;

            for(long i = 1; i <= N; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    ans += i;
                }
            }

            Console.WriteLine(ans);
        }
    }
}

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

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

class operation {
public:
  i64 max, value;
};

namespace std {
  std::istream& operator>>(std::istream& is, operation& self) {
    return is >> self.max >> self.value;
  }
}

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<i64> A;
  tools::read(A, N);
  std::vector<operation> operations;
  tools::read(operations, M);

  std::sort(A.begin(), A.end());
  std::sort(operations.begin(), operations.end(), [](const operation& x, const operation& y) {
    return x.value > y.value;
  });
  auto it1 = A.begin();
  auto it2 = operations.begin();
  while (it1 != A.end() && it2 != operations.end()) {
    for (i64 i = 0; i < it2->max && it1 != A.end(); ++i, ++it1) {
      if (*it1 < it2->value) {
        *it1 = it2->value;
      } else {
        goto FINISHED;
      }
    }
    ++it2;
  }
FINISHED:
  ;

  std::cout << std::accumulate(A.begin(), A.end(), static_cast<i64>(0)) << std::endl;
  return 0;
}

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

using namespace std;

typedef pair<int, int> point;

const int N = 1024;
point a[N], b[N];

bool cek(point p, point q) {
  return p.first < q.first && p.second < q.second;
}
int match[N], matched[N];
bool mark[N];
vector<int> g[N];

// The code below finds a augmenting path:
bool dfs(int v){// v is in X, it reaturns true if and only if there is an augmenting path starting from v
  if(mark[v])
    return false;
  mark[v] = true;
  for(auto &u : g[v])
    if(match[u] == -1 or dfs(match[u])) // match[i] = the vertex i is matched with in the current matching, initially -1
      return matched[v] = u, match[u] = v, true;
  return false;
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    a[i] = {x, y};
  }
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    b[i] = {x, y};
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (cek(a[i], b[j]))
        g[i].push_back(j);
  int ans = 0;
  memset(matched, -1, sizeof matched);
  memset(match, -1, sizeof match);
  while(true){
    memset(mark, false, sizeof mark);
    bool fnd = false;
    for(int i = 0; i < n; ++i) if(matched[i] == -1 && !mark[i])
      fnd |= dfs(i);
    if(!fnd)
      break;
  }
  for (int i = 0; i < n; ++i)
    ans += match[i] != -1;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

struct UnionFind {
	UnionFind(int n) {
		par = new int[n + 1];
		size = new int[n + 1];
		height = new int[n+1];
		for (int i = 0; i <= n; ++i) {
			par[i] = i;
			size[i] = 1;
			height[i] = 1;
		}
	}

	void unite(int a, int b) {
	  a = root(a);
		b = root(b);
		if (a == b) return;
		if (height[a] < height[b]) {
		  par[a] = b;
			size[b] += size[a];
		}
		else{
			par[b] = a;
			size[a] += size[b];
			if (height[a] == height[b]) {
				height[a]++;
			}
		}

	}

	int root(int a) {
		return par[a] == a ? a : par[a] = root(par[a]);
	}

	int getSize(int a) {
		return size[root(a)];
	}

	bool isSame(int a, int b) {
		return root(a) == root(b);
	}

	int* size;
	int* height;
	int* par;
};


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

	ll n, m;
	cin >> n >> m;

	vector<int> a(m), b(m);
	rep(i, m) {
	  int _a, _b;
	  cin >> _a >> _b;
	  a[i] = _a-1; 
		b[i] = _b-1;
	}

	vector<ll> ans(m);
	UnionFind uf(n);
  
	ans[m-1] = n*(n-1)/2;
	rrep(i, m) {
	  if (i == 0) break;

		if (uf.root(a[i]) != uf.root(b[i])) {
		  ans[i-1] = ans[i] - (ll) uf.getSize(a[i])*uf.getSize(b[i]);
			uf.unite(a[i], b[i]);
		}
		else ans[i-1] = ans[i];
	}

	rep(i,m) cout << ans[i] << endl;
}




Measured memory_bytes: 4096
<?php
$n = trim(fgets(STDIN));
$t_score = 0;
$h_score = 0;

for($i = 0; $i < $n; $i++){
    $card = explode(" ", trim(fgets(STDIN)));
    $t_card = substr($card[0],0);
    $h_card = substr($card[1],0);
    if($t_card > $h_card){
        $t_score += 3;
    }elseif ($t_card == $h_card) {
        $t_score += 1;
        $h_score += 1;
    }elseif ($t_card < $h_card) {
        $h_score += 3;
    }
}
printf("%d %d",$t_score,$h_score).PHP_EOL;
?>

Measured memory_bytes: 15176
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  Int a = in();
  Int b = in();

  if (a * b <= 0) {
    puts("Zero");
  } else if (a > 0) {
    puts("Positive");
  } else {
    puts((min(0LL, b) - a) % 2 == 1 ? "Positive" : "Negative");
  }

  return 0;
}


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

using namespace std;


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

	sort(A.begin(), A.end());
	
	for(int i = 0; i < N; i++){
		cout << A[i][1] <<" ";
	}
	cout << endl;

	
	return 0;
	
}


/*

for(int i = 0; i < N; i++){
	
}

for(int i = 0; i < N; i++){
	for(int j = 0; j < N; j++){
		
	}
}


*/


Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
 
#define CASES int t;cin>>t;while(t--)
#define REP(i, val, b) for (int i = val; i < b; ++i)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
int main() {
    fastio
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    REP(i,0,n) cin >> A[i];
    vector<int> B(n);
    B[0] = 0;
    B[1] = abs(A[1] - A[0]);
    REP(i,2,n) {
        int ans = 1e9;
        for (int j = max(0, i - k); j < i; j++) {
            ans = min(ans, B[j] + abs(A[i] - A[j]));
        }
        B[i] = ans;
    }
    cout << B[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  int ans=0;
  rep(i,n){
    int l,r; cin>>l>>r;
    ans+=r-l+1;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

m = (n-1) // 2
s = sum(a) // 2
x = [sum([a[(0+1 + j*2)%n] for j in range(m)]), sum([a[(1+1 + j*2)%n] for j in range(m)])]
ans = []
for i in range(n):
    index = i % 2
    ans.append(s - x[index])
    x[index] = x[index] - a[(i+1 + 0*2)%n] + a[(i+1 + m*2)%n]

print(" ".join([str(a*2) for a in ans]))


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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);


    int a;
    cin>>a;
    string s;
    cin>>s;
    
    if(a>=3200) cout<< s;
    else cout<< "red";

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i,n) for(int i=(int)(n);i>=0;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vector<vector<int>> g(N);
    rep(i, 0, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    auto dfs = [&](auto f, int v, int p) -> int {
        int cnt = 0;
        fore(w, g[v]) {
            if (w == p) continue;
            cnt += f(f, w, v);
        }
        if (cnt >= 2) return 2;
        return cnt != 1;
    };
    cout << (dfs(dfs, 0, -1) ? "First" : "Second") << endl;
    return (0^_^0);
}



Measured memory_bytes: 6400
bingo=[]
for _ in range(3):
    List=list(map(int,input().split()))
    bingo.append(List)

n=int(input())

for _ in range(n):
    k=int(input())
    i=0
    while i<3:
        j=0
        while j<3:
            if bingo[i][j]==k:
                bingo[i][j]=0
            j+=1
        i+=1

#yoko
for item in bingo:
    if item[0]==0 and item[1]==0 and item[2]==0:
        print("Yes")
        exit()

i=0
while i<3:
    if bingo[0][i]==0 and bingo[1][i]==0 and bingo[2][i]==0:
        print("Yes")
        exit()
    i+=1

#naname
if bingo[0][0]==0 and bingo[1][1]==0 and bingo[2][2]==0:
    print("Yes")
    exit()

if bingo[0][2]==0 and bingo[1][1]==0 and bingo[2][0]==0:
    print("Yes")
    exit()

print("No")


Measured memory_bytes: 38492
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[] ints = new int[n];
		for (int i=0; i<n; i++) {
			ints[i] = sc.nextInt();
		}
		
		int min = ints[0];
		int ans = Integer.MIN_VALUE;
		for (int i=1; i<n; i++) {
			ans = Math.max(ans,ints[i]-min);
			min = Math.min(min,ints[i]);
		}
		
		System.out.println(ans);
	}
}			


Measured memory_bytes: 100352
#include<bits/stdc++.h>
using namespace std;
int n,m;
int a[1000000];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>m;
		a[m]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" ";
	}
}

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

struct Node{
    int key, pri;
    Node* left;
    Node* right;
};

Node* _del(Node* t, int key);

Node* newNode(int k, int p){
    Node* ret = (Node*)(malloc(sizeof(Node)));
    ret->key = k;
    ret->pri = p;
    ret->left = NULL;
    ret->right = NULL;
    return ret;
}

Node* rightRotate(Node* t){
    Node* s = t->left;
    t->left = s->right;
    s->right = t;
    return s;
}

Node* leftRotate(Node* t){
    Node* s = t->right;
    t->right = s->left;
    s->left = t;
    return s;
}

Node* insert(Node* t, int key, int pri){
    if(t == NULL){
        return newNode(key, pri);
    }
    if(key == t->key){
        return t;
    }
    if(key < t->key){
        t->left = insert(t->left, key, pri);
        if(t->pri < t->left->pri)   t = rightRotate(t);
    }else{
        t->right = insert(t->right, key, pri);
        if(t->pri < t->right->pri)   t = leftRotate(t);
    }
    return t;
}

// 削除対象となるNodeを検索
Node* del(Node* t, int key){
    if(t == NULL){
        return NULL;
    }
    if(key < t->key){
        t->left = del(t->left, key);
    }else if(key > t->key){
        t->right = del(t->right, key);
    }else{
        return _del(t, key);
    }
    return t;
}

// 削除対象の節点
Node* _del(Node* t, int key){
    if(t->left == NULL && t->right == NULL){
        return NULL;
    }else if(t->left == NULL){
        t = leftRotate(t);
    }else if(t->right == NULL){
        t = rightRotate(t);
    }else{
        if(t->left->pri < t->right->pri){
            t = leftRotate(t);
        }else{
            t = rightRotate(t);
        }
    }
    return del(t, key);
}

void in(Node* t){
    if(t->left != NULL) in(t->left);
    cout << " " << t->key;
    if(t->right != NULL) in(t->right);
}

void pre(Node* t){
    cout << " " << t->key;
    if(t->left != NULL) pre(t->left);
    if(t->right != NULL) pre(t->right);
}

bool find(Node* t, int key){
    if(t == NULL)   return false;
    if(t->key == key)   return true;
    if(key < t->key)    return find(t->left, key);
    else                return find(t->right, key);
}

int main(){
    Node* root = NULL;
    int m;
    cin >> m;
    while(m-- > 0){
        string s;
        cin >> s;
        if(s == "insert"){
            int key, pri;
            cin >> key >> pri;
            root = insert(root, key, pri);
        }else if(s == "print"){
            in(root);   cout << endl;
            pre(root);  cout << endl;
        }else if(s == "delete"){
            int key;    cin >> key;
            root = del(root, key);
        }else if(s == "find"){
            int key;    cin >> key;
            cout << (find(root, key) ? "yes" : "no") << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9420
s = input()
t = s[::-1]
n = len(s)
resid = [0] * 2019
resid[0] = 1
csum = 0
powoften = 1
for i in range(n):
    csum = (csum + int(t[i]) * powoften) % 2019
    powoften = (10 * powoften) % 2019
    resid[csum] += 1
ans = 0
for i in range(2019):
    ans += resid[i] * (resid[i] - 1) // 2
print(ans)

Measured memory_bytes: 9204
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
ll memo[111][111];
int n, a[111], b[111];
ll rec(int l, int r){
    if(memo[l][r] != 1e9) return memo[l][r];
    if(l == r) return memo[l][r] = 0;
    if(r - l == 1){
      return memo[l][r] = a[l]*b[l]*b[r];
    }
    ll ret = 1e9;
    FOR(m, l, r){
      ret = min(ret, rec(l, m) + rec(m + 1, r) + a[l] * b[m] * b[r]);
    }
    return memo[l][r] = ret;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  FOR(i,0,n) cin >> a[i] >> b[i];
  FOR(i,0,111)FOR(j,0,111)memo[i][j]=1e9;
  cout << rec(0,n-1) << endl;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        if((n/100)==(n%10))
        cout<<"Yes";
        else
        cout<<"No";
    } 
    return 0;
}


Measured memory_bytes: 3608
//https://atcoder.jp/contests/abc164/tasks/abc164_a
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int s , w ;
  cin >> s >> w ;
  if(s <= w) cout << "unsafe\n";
  else cout << "safe\n";
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    if(a > b){
        swap(a, b);
    }

    cout << max((ll)0, b - a - W) << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        String s = scanner.next();

        int max = 0;
        String bef;
        String aft;

        for (int i = 0;i<a;i++) {
        	bef = s.substring(0, i+1);
        	aft = s.substring(i+1,s.length());
        	int cnt = 0;

        	String[] bef2 = bef.split("");
        	Set<String> hash_set = new HashSet<String>();

        	for(String tmp : bef2) {
        		hash_set.add(tmp);
        	}

        	/*
        	for(int j=0;j<bef2.length;j++) {
        		hash_set.add(bef2[j]);
        	}
        	*/
        	for(String tmp : hash_set){
        		if(aft.contains(tmp)) {
        			cnt++;
        		}
        	}
        	/*
        	Iterator<String> iterator = hash_set.iterator();
        	for (int k=0;k<hash_set.size();k++) {
        		if(aft.contains(iterator.next())) {
        			cnt++;
        		}
        	}
        	*/
        	if (cnt >= max) {
        		max = cnt;
        	}
        }
        System.out.println(max);

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 22868