akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
int a,b,c,d,i,n,e;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&a,&b,&c);
if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){
printf("YES\n");
}
else{
printf("NO\n");
}
}
return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    FOR(h,1,3501){
      FOR(w,1,3501){
        //cout<<(n*h*w)<<' '<<(4*h*w-n*w-n*h)<<'\n';
        if((4*h*w-n*w-n*h)!=0 && (n*h*w)%(4*h*w-n*w-n*h)==0 && (n*h*w)/(4*h*w-n*w-n*h)>0){
          cout<<h<<' '<<w<<' '<<(n*h*w)/(4*h*w-n*w-n*h)<<endl;
          return 0;
        }
      }
    }
}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val n = readLine()!!.toInt()
	val s = readLine()!!
	var list : MutableList<String> = mutableListOf()
	var count : Int = 0
	for (i in s) {
		list.add(i.toString())
	}
	for (i in 0..n - 3) {
		if (list[i] == "A" && list[i + 1] == "B" && list[i + 2] == "C") {
			count++
		} else {
			continue
		}
	}
	println("${count}")
}

Measured memory_bytes: 33688
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n ;
int arr[500005] ;
string str ;

void solve()
{
    cin >> str ;
    if(str[str.size()-1] == 's')
        str += "es" ;
    else
        str += "s" ;
    cout << str ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 3660
d, n = map(int, input().split())
if d == 0:
    count = 0
    for i in range(1, 110):
        if i % 100 != 0:
            count += 1
            if count == n:
                print(i)
                break
        else:
            continue
        

if d == 1:
    count = 0
    for i in range(100, 20000, 100):
        if i % 100 == 0 and i % 10000 != 0:
            count+=1
            if count == n:
                print(i)
                break
        else:
            continue
        

if d == 2:
    count = 0
    for i in range(10000, 2000000, 10000):
        if i % 10000 == 0 and i % 1000000 != 0:
            count+=1
            if count == n:
                print(i)
                break
        else:
            continue




Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=1e5+5;
int mul(int a,int b){return (long long)a*b;}
typedef long long ll;
int n,x[N],y[N],d[N];
const double inf=1e20;
double getans(double mid)
{
    double mnx=inf,mxx=-inf,mny=inf,mxy=-inf;
    for(int i=1;i<=n;i++)
    {
        double xx=x[i],yy=y[i];
        if(d[i]==1) xx-=mid;
        if(d[i]==2) xx+=mid;
        if(d[i]==3) yy+=mid;
        if(d[i]==4) yy-=mid;
        mnx=min(mnx,xx);
        mxx=max(mxx,xx);
        mny=min(mny,yy);
        mxy=max(mxy,yy);
    }
    return (mxx-mnx)*(mxy-mny);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char s[5];
        scanf("%d%d%s",&x[i],&y[i],s);
        if(s[0]=='L') d[i]=1;
        else if(s[0]=='R') d[i]=2;
        else if(s[0]=='U') d[i]=3;
        else d[i]=4;
    }
    double l=0,r=1e10;
    for(int i=1;i<=1000;i++)
    {
        double mid=l+(r-l)/3,midmid=l+(r-l)/3*2;
        if(getans(mid)<getans(midmid)) r=midmid;
        else l=mid;
    }
    printf("%f\n",getans(l));
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans=0x3ffff;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        int t=0;
        while(x%2==0){
            x=x/2;
            t++;
        }
        ans=min(ans,t);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

struct SegmentTree{
private:
    int n;
    vector<pair<int,int>> node;
public:
    SegmentTree(const vector<pair<int,int>>& v){
        int sz=(int)v.size();
        n=1;
        while(n<sz)n*=2;
        node.resize(2*n-1);
        for(int i=0;i<n;i++){
            if(i<sz)node[i+n-1]=v[i];
            else node[i+n-1]={INF,INF};
        }
        for(int i=n-2;i>=0;i--){
            node[i]=min(node[2*i+1],node[2*i+2]);
        }
    }
    pair<int,int> get(int a,int b,int k=0,int l=0,int r=-1){
        if(r==-1)r=n;
        if(b<=l||r<=a)return {INF,INF};
        if(a<=l&&r<=b){
            return node[k];
        }
        else{
            return min(get(a,b,2*k+1,l,(l+r)/2),get(a,b,2*k+2,(l+r)/2,r));
        }
    }
};

struct EulerTour{
private:
    int k;
    void dfs(int v,int p,int dep){
        depth[v]=dep;
        par[v]=p;
        for(int u:tree[v]){
            if(u!=p){
                dwn[u]=k++;
                dfs(u,v,dep+1);
                up[u]=k;
            }
        }
    }
public:
    vector<int> dwn,up,depth,par;
    vector<vector<int>> tree;
    EulerTour(int n){
        dwn.resize(n);
        dwn[0]=-1;
        up.resize(n);
        up[0]=-1;
        tree.resize(n);
        depth.resize(n);
        par.resize(n);
    }
    void add_edge(int u,int v){
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    void build(int root){
        k=0;
        dfs(root,-1,0);
    }
};

int main(){
    int n,u,v;
    cin>>n>>u>>v;
    --u,--v;
    EulerTour et(n);
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        --a,--b;
        et.add_edge(a,b);
    }
    et.build(0);
    vector<pair<int,int>> vec(n-1);
    for(int i=1;i<n;i++){
        vec[et.dwn[i]]={et.depth[i],i};
    }
    SegmentTree seg(vec);
    int ans=-1;
    for(int i=0;i<n;i++){
        int tlca;
        if(i==u)tlca=u;
        else tlca=et.par[seg.get(min(et.dwn[u],et.dwn[i])+1,max(et.dwn[u],et.dwn[i])+1).second];
        int tdist=et.depth[u]+et.depth[i]-2*et.depth[tlca];
        int alca;
        if(i==v)alca=v;
        else alca=et.par[seg.get(min(et.dwn[i],et.dwn[v])+1,max(et.dwn[i],et.dwn[v])+1).second];
        int adist=et.depth[i]+et.depth[v]-2*et.depth[alca];
        if(tdist<adist){
            ans=max(ans,adist-1);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13184
N,M = map(int, input().split())

mod = 10**9+7

x = max(N, M)
y = min(N, M)
if x-y <= 1:
    ans = 1
    for i in range(1, x+1):
        ans *= i
        ans %= mod
    for i in range(1, y+1):
        ans *= i
        ans %= mod
    if x == y:
        ans *= 2
        ans %= mod
else:
    ans = 0
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 9999999999999999
#define MOD 1000000007

void func()
{
    string s;
    cin>>s;
    if(s=="ABC")
        cout<<"ARC"<<"\n";
    else
        cout<<"ABC"<<"\n";
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r" , stdin);
    // freopen("output.txt", "w" , stdout);
    // #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3612
S = input()
S=S[::-1]

s = ['dream','dreamer','erase','eraser'] 
s = [_[::-1] for _ in s]

idx = 0
ans='YES'
while idx < len(S):
    if S[idx] == 'm':
        if S[idx:idx+5] == s[0]:
            idx=idx+5
        else:
            ans='NO'
            break
        
    elif S[idx] == 'e':
        if S[idx:idx+5] == s[2]:
            idx=idx+5
        else:
            ans='NO'
            break
        
    elif S[idx] == 'r':
        if S[idx:idx+7] == s[1]:
            idx=idx+7
        elif S[idx:idx+6] == s[3]:
            idx=idx+6
        else:
            ans='NO'
            break
        
    else:
        ans='NO'
        break
        
print(ans)


Measured memory_bytes: 9204
#include<stdio.h>
int main(){
    int h,w,i,j;

    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0) break;

        for(i=1;i<=h;i++){
            for(j=1;j<=w;j++){
                if(i%2==0){
                    if(j%2==0)
                        printf("#");
                    else printf(".");
                }
                if(i%2!=0){
                    if(j%2==0)
                        printf(".");
                    else printf("#");
                }
            }printf("\n");
        }printf("\n");
    }

    return 0;
}




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

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

using ll = long long;
using P = pair<int,int>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll N,Z,W;
vector<ll> a;
ll dp[2][2005];
bool seen[2][2005];
ll f(ll x,ll z){
  if(seen[x][z]) return dp[x][z];
  seen[x][z] = true;
  if(z==N-1) dp[x][z] = abs(a[N]-a[N-1]);
  if(x==0){
    for(int i = z+1;i<N; i++) chmax(dp[x][z],f(1,i));
    chmax(dp[x][z],abs(a[N]-a[z]));
  }
  else{
    for(int i = z+1;i<N;i++) chmin(dp[x][z],f(0,i));
    chmin(dp[x][z],abs(a[N]-a[z]));
  }
  return dp[x][z];
}

int main(){
  cin>>N>>Z>>W;
  a.resize(N+1);
  a[0] = W;
  rep(i,2){
    rep(j,2005){
        if(i==0) dp[i][j]=0;
        else dp[i][j] = INF;
    }
  }
  rep(i,N) cin>>a[i+1];
  ll ans = 0;
  rep(i,N-1){
    chmax(ans,f(1,i+1));
  }
  chmax(ans,abs(W-a[N]));
  cout<<ans<<endl;
}

Measured memory_bytes: 3756
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
s = 0
for i in range(0,n-1):
    if a[i+1]- a[i] == 1:
        s += c[a[i]-1]
print(sum(b)+s)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

using namespace std;
typedef long long ll;

int DAYS;
const int TYPES = 26;
mt19937 engine(random_device{}());

vector<int> c;
vector<vector<ll>> s;

ll point;
vector<ll> penalty;

chrono::system_clock::time_point startTime, endTime;
int elapsed = 0;

void simulate(vector<int> &t) {
    vector<int> last(TYPES, -1);
    point = 0, penalty.assign(TYPES, 0);
    for (int i = 0; i < DAYS; i++) {
        point += s[i][t[i]], last[t[i]] = i;
        for (int j = 0; j < TYPES; j++) {
            penalty[j] += c[j] * (i - last[j]);
        }
    }
}

void update(vector<int> &t, int x, int y) {
    int lastx = -1, lasty = -1;
    penalty[x] = 0, penalty[y] = 0;
    for (int i = 0; i < DAYS; i++) {
        if (t[i] == x)lastx = i;
        if (t[i] == y)lasty = i;

        penalty[x] += c[x] * (i - lastx), penalty[y] += c[y] * (i - lasty);
    }
}

ll scoring() {
    ll ret = point;
    for (auto &x:penalty)ret -= x;
    return ret;
}


ll mod_rnd(ll mod) { return engine() % mod; }

int main() {
    startTime = chrono::system_clock::now();

    cin >> DAYS;
    c.resize(TYPES);
    for (int i = 0; i < TYPES; i++)cin >> c[i];
    s.assign(DAYS, vector<ll>(TYPES));
    for (int i = 0; i < DAYS; i++) {
        for (int j = 0; j < TYPES; j++) {
            cin >> s[i][j];
        }
    }

    vector<int> t(DAYS);
    for (int i = 0; i < DAYS; i++) t[i] = i % TYPES;

    simulate(t);
    ll currentScore = scoring();

    while (elapsed < 1975) {
        int ope = mod_rnd(elapsed / 18 + 5);
        int day1 = -1, day2 = -1;
        int type1 = -1, type2 = -1;

        if (ope == 0) {
            do {
                day1 = mod_rnd(DAYS), type2 = mod_rnd(TYPES);
            } while (t[day1] == type2);

            type1 = t[day1];
            t[day1] = type2;
            point -= s[day1][type1], point += s[day1][type2];
        } else {
            do {
                day1 = mod_rnd(DAYS), day2 = mod_rnd(DAYS);
            } while (day1 == day2);

            type1 = t[day1], type2 = t[day2];
            point -= s[day1][type1], point -= s[day2][type2];
            swap(t[day1], t[day2]);
            point += s[day1][type2], point += s[day2][type1];
        }

        update(t, type1, type2);
        ll changedScore = scoring();

        ll add = max(0, (1800 - elapsed) * 2);
        if (currentScore < changedScore + add)currentScore = changedScore;
        else {
            if (ope == 0) {
                t[day1] = type1;
                point += s[day1][type1], point -= s[day1][type2];
            } else {
                point -= s[day1][type2], point -= s[day2][type1];
                swap(t[day1], t[day2]);
                point += s[day1][type1], point += s[day2][type2];
            }
            update(t, type1, type2);
        }

        endTime = chrono::system_clock::now();
        elapsed = chrono::duration_cast<chrono::milliseconds>(endTime - startTime).count();
    }

    for (auto &x:t)cout << x + 1 << endl;
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-6
#define endl '\n'
long long mod = 1e9 + 7;
const int N = 1e5 + 5;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll n ,k , arr[N] , ans , i;
int main()
{
    em3
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++)
        cin >> arr[i];
    while(i < n)
    {
        if(i + k - 1 < n - 1)
            ans++ , i = i + k - 1;
        else
        {
            ans++;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
from collections import deque, defaultdict, Counter

n, k, q = map(int,input().split())

A = [int(input()) for i in range(q)]

cntA = Counter(A)

for i in range(1, n +1):
    if (k - q + cntA[i] >= 1 ):
        print('Yes')
    else :
        print('No')

Measured memory_bytes: 11900
#include <stdio.h>
#include <math.h>
int main(){
	int A,B,C,D,P,R;
	scanf("%d%d%d%d%d",&A,&B,&C,&D,&P);
	//printf("\n%d%d%d%d%d",A,B,C,D,P);
	if(P > C){
		B = B + D * (P-C);
	}
	printf("%d\n",(int)fmin(B,A*P));
	return 0;
}

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

int main(){

    int a,b,c;cin >> a >> b >> c;
    int sum = max(max(a,b),c)*10;

    if(max(max(a,b),c)==a){
        sum += b+c;
    }else if(max(max(a,b),c)==b){
        sum += a+c;
    }else if(max(max(a,b),c)==c){
        sum += a+b;
    }

    cout << sum << endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int dp[20001];

int main () {
  int h, n;
  cin >> h >> n;
  vi a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }

  rep(i,20001) dp[i] = INF;
  dp[0] = 0;
  rep(i,h+1) {
    rep(j,n) {
      if (dp[i] == INF) continue;
      chmin(dp[i+a[j]], dp[i]+b[j]); 
    }
  }

  int ans = INF;
  for (int i = h; i < h+*max_element(rng(a)); ++i) {
    chmin(ans, dp[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)

ll n, m, h, k;
vector<ll> f;
vector<ll> b;
vector<ll> srcx, srcy;
vector<ll> s;

int main() {
    while (cin >> n >> m >> h >> k && n) {
        s.resize(n);
        for (size_t i = 0; i < n; i++) {
            cin >> s[i];
        }
        b.resize(m);
        vector<pair<int, int>> p(m);
        for (size_t i = 0; i < m; i++) {
            int x, y;
            cin >> x >> y;
            p[i] = make_pair(y, x);
        }
        sort(p.begin(), p.end());
        for (size_t i = 0; i < m; i++) {
            b[i] = p[i].second - 1;
        }
        vector<int> cur(n);
        for (size_t i = 0; i < n; i++) {
            cur[i] = i;
        }
        srcx.resize(m); srcy.resize(m);
        for (size_t i = 0; i < m; i++) {
            srcx[i] = cur[b[i]];
            srcy[i] = cur[b[i] + 1];
            swap(cur[b[i]], cur[b[i] + 1]);
        }
        vector<int> dst(n);
        for (size_t i = 0; i < n; i++) {
            dst[cur[i]] = i;
        }
        ll org = 0;
        for (size_t i = 0; i < k; i++) {
            org += s[dst[i]];
        }
        ll ans = org;
        for (size_t i = 0; i < m; i++) {
            int a = srcx[i];
            int b = srcy[i];
            if (a > b) swap(a, b);
            if (a < k && b >= k) {
                ans = min(ans, org - s[dst[a]] + s[dst[b]]);
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 6264
#include<stdio.h>
 int main()
 { int x, y; 
char sig; 
scanf("%d %c %d",&x,&sig,&y); 
if(sig=='+')
 printf("%d\n",x+y); 
if(sig=='-') 
printf("%d\n",x-y);
 return 0; 
}

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

#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define bg begin()
#define ed end()
#define pii pair<int,int>
const ll mod = 1e9+7;
int main(){
	int n,m;
	while(cin >> n >> m){
		vector<int>hh[n+5],vv[m+5];
		f1(n){
			hh[i].pb(0);
		}
		f1(m){
			vv[i].pb(0);
		}
		f1(n){
			string s;
			cin >> s;
			fr(j,1,m+1){
				if(s[j-1]=='#'){
					hh[i].pb(j);
					vv[j].pb(i);
				}
			}
		}
		f1(n){
			hh[i].pb(m+1);
		}
		f1(m){
			vv[i].pb(n+1);
		}
		int mx = 0;
		f1(n){
			fr(j,1,m+1){
				if(*lower_bound(hh[i].begin(),hh[i].end(),j)==j)continue;
				int n1=*lower_bound(hh[i].begin(),hh[i].end(),j)-(*(--lower_bound(hh[i].begin(),hh[i].end(),j)));
				int n2=*lower_bound(vv[j].begin(),vv[j].end(),i)-(*(--lower_bound(vv[j].begin(),vv[j].end(),i)));
				mx=max(mx,n1+n2-3);
			}
		}
		cout << mx << endl;
	}
}

Measured memory_bytes: 34304
#include<stdio.h>

int main()
{
    int i, n, cnt = 0, sum = 0;
    while(1){
        scanf("%d", &n);
        if( n == 0 ) break;

        for ( i = 0; i < n; i++ , sum = 0){
            int j = i + 1;
            while(sum < n){
                sum += j++;
            }
            if( sum > n ) continue;
            cnt++;
        }
        printf("%d\n", cnt - 1); //??£?¶???????????????????????????????????????????????????????n)
        cnt = 0;
    }
    return 0;
}

Measured memory_bytes: 2568
import java.util.*;
import java.awt.Frame;
import java.io.*;

public class Main {
	// static ArrayList<Integer>[] g;

	static pair[] a;
	static int[][] memo;

	static int dp(int l, int r) {
		if (l > r)
			return 0;
		if (memo[l][r] != -1)
			return memo[l][r];
		int ans = dp(l + 1, r);
		ans = Math.max(ans, dp(l, r - 1));
		for (int idx : startAt[l]) {
			if (a[idx].y >= r)
				continue;
			int inc = exist[a[idx].y + 1][r] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}
		for (int idx : endAt[r]) {
			if (a[idx].x <= l)
				continue;
			int inc = exist[l][a[idx].x - 1] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}

		return memo[l][r] = ans;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];
		StringTokenizer st = new StringTokenizer(br.readLine());
		for (int i = 0; i < a.length; i++) {
			a[i] = Integer.parseInt(st.nextToken());
		}
		Arrays.sort(a);
		int ans = 0;
		for (int i = 0; i < a.length; i++) {
			for (int j = i + 1; j < a.length; j++) {
				for (int k = j + 1; k < a.length; k++) {
					if (a[i] + a[j] > a[k] && a[i]!=a[j] && a[j]!=a[k]) {
						ans++;
					}
				}
			}
		}
		pw.println(ans);

		pw.flush();
		pw.close();

	}

	static int maxSize;
	static boolean[][] exist;
	static ArrayList<Integer>[] startAt, endAt;

	static void compress(pair[] arr) {
		TreeSet<Integer> tr = new TreeSet<>();
		for (int i = 0; i < arr.length; i++) {
			tr.add(arr[i].x);
			tr.add(arr[i].y);
		}
		tr.add(0);
		tr.add((int) 1e9);
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : tr)
			hm.put(x, hm.size());
		for (int i = 0; i < arr.length; i++) {
			arr[i].x = hm.get(arr[i].x);
			arr[i].y = hm.get(arr[i].y);
		}
		maxSize = hm.size();
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			int x1 = y - x;
			int x2 = o.y - o.x;
			return x1 - x2;
		}

	}

}

Measured memory_bytes: 33664
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;


int main()
{
    idfc;

    stack<char> st;
  string s;
  cin>>s;
    int n;
    n=s.length();
    char e;
int i=0;
    while(n--)
    {
        e=s[i]; i++;
        if((!st.empty())&&(e=='T')&&((st.top())=='S'))st.pop();
        else st.push(e);
    }
    cout<<st.size();
    return 0;
}

Measured memory_bytes: 3836
'use strict'

class Main {
  solve() {
    let n = input.nextIntArr()[0];
    const pairs = [];
    if (n % 2) pairs.push([n]);
    let m = n % 2 ? n - 1 : n;
    for (let i = 0; i < m/2; ++i) {
      pairs.push([i+1,m-i]);
    }
    let ret = [];
    for (let i = 0; i < pairs.length - 1; ++i) {
      pairs[i].forEach((e1) => ret = ret.concat(pairs[(i+1)%pairs.length].map((e2) => [e1,e2])));
    }
    if (n >= 5) {
      let i = pairs.length - 1;
      pairs[i].forEach((e1) => ret = ret.concat(pairs[(i+1)%pairs.length].map((e2) => [e1,e2])));
    }
    console.log(ret.length);
    console.log(ret.map((e)=>e.join(' ')).join('\n'));
  }
}

class Input {
  constructor() {
    this.cursor = 0;
    this.inputAll();
  }

  inputAll() {
    this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
    return this.data;
  }

  /* 1行 or 複数行文字列 */
  nextLine(n) {
    if (n) {
      const ret = this.data.slice(this.cursor, this.cursor + n);
      this.cursor += n;
      return ret;
    }
    return this.data[this.cursor++];
  }
  /* 一行文字配列 */
  nextStrArr() { return this.nextLine().split(' '); } 
  /* 一行整数配列 */
  nextIntArr() { return this.nextStrArr().map((e) => parseInt(e)); }
  /* 一行浮動小数点配列 */
  nextFloatArr() { return this.nextStrArr().map((e) => parseFloat(e)); }
  /* 複数行整数配列 */
  nextIntLine(n) { return this.nextLine(n).map((e) => parseInt(e)) }
  /* 複数行浮動小数点配列 */
  nextFloatLine(n) { return this.nextLine(n).map((e) => parseFloat(e)) }
  /* 複数行文字列二次元配列 */
  nextStrRange(n) { return this.nextLine(n).map((line) => line.split(' ')); }
  /* 複数行整数二次元配列 */
  nextIntRange(n) {
    return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e)));
  }
  /* 複数行浮動小数点数二次元配列 */
  nextFloatRange(n) {
    return this.nextLine(n).map((line) => line.split(' ').map((e) => parseFloat(e)));
  }
} 
const input = new Input();
(new Main()).solve();


Measured memory_bytes: 9420
# coding: utf-8
# Your code here!
N,M = map(int,input().split())
dp = [-1] * (N + 10)
dp[0] = 1
dp[1] = 1
#print(dp[0])
#print(dp[1])
for i in range(M):
    dp[int(input())] = 0

for i in range(2, N + 1):
    if dp[i] == 0:
        #print(dp[i])
        continue
    
    else:
        dp[i] = dp[i - 2] + dp[i - 1]
        #print("i = " + str(i))
        #print(dp[i])

print(dp[N] % 1000000007)

Measured memory_bytes: 470520
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int C = sc.nextInt();
		int[][] a = new int[C][100000];
		for (int i = 0; i < N; ++i) {
			int s = sc.nextInt() - 1;
			int t = sc.nextInt() - 1;
			int c = sc.nextInt() - 1;
			for (int j = s; j <= t; ++j)
				if (a[c][j] == 0)
					a[c][j]++;
		}
 
		int ans = 0;
		for (int i = 0; i < 100000; ++i) {
			int tmp = 0;
			for (int j = 0; j < C; ++j) {
				tmp += a[j][i];
			}
			ans = Math.max(ans, tmp);
		}
		System.out.println(ans);
	}
}

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

int main() {
  int N,ans=0;
  cin >> N;
  vector<int> A(N);
  for (int i=0;i<N;i++){
  cin >> A.at(i);
  }
  for (int j=0;j<30;j++){
  for (int i=0;i<N;i++){
   if (A.at(i)%2==0){
   A.at(i)/=2;
   }
   else {
   goto out;
   }
  }
    ans++;
  }
  out:
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    int n; cin >> n;
    int p[100];
    int ans = 0;
    for (int i = 0;i < n;i++){
        cin >> p[i];
    }
    for (int i = 1;i < n-1;i++){
        if((p[i] > p[i-1] && p[i] < p[i+1])||(p[i] < p[i-1] && p[i] > p[i+1])) ans++;
    }
    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

#include<bits/stdc++.h>
using namespace std;

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     mt           make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1e2+5,K=1e5+5;

int dp[N][K];       // (index, candies)

vector<int> v,pre(K,0);

void solve()
{
    mem(dp,0);

    int n,k;
    cin>>n>>k;

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

    for(int i=0;i<=v[0];++i)
        dp[0][i]=1;

    for(int i=1;i<n;++i)
    {
        pre[0]=0;
        for(int j=0;j<=k;++j)
            pre[j+1]=(pre[j]+dp[i-1][j])%M;

        for(int j=0;j<=k;++j)
            dp[i][j]=(pre[j+1]-pre[max(j-v[i],0ll)]+M)%M;

    }

//    for(int i=0;i<n;++i)
//    {
//        for(int j=0;j<=k;++j)
//            cout<<dp[i][j]<<" ";
//        cout<<"\n";
//    }

    cout<<dp[n-1][k];
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 83072
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <bitset>

using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>v(n+1,0);
	vector<int>cost(n+1,0);
	for(int i=1;i<n+1;++i){
		cin>>v[i];
		}
	cost[1]=0;
	cost[2]=cost[1]+abs(v[1]-v[2]);
	for(int i=3;i<n+1;++i){
		cost[i]=min(cost[i-2]+abs(v[i-2]-v[i]),cost[i-1]+abs(v[i-1]-v[i]));
	}
	cout << cost[n];
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	K, _ := strconv.Atoi(sc.Text())
	ans := (N - 1) / (K - 1)
	if (N-1)%(K-1) > 0 {
		ans++
	}
	fmt.Printf(`%d`, ans)
}


Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    int s = 0;
    int ret = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            ret += s / 2;
            s = 0;
        } else {
            s += A[i];
        }
    }
    ret += s / 2;
    cout <<ret << endl;

    return 0;
}

Measured memory_bytes: 1024
n=int(input())
a=sorted([int(i) for i in input().split()])
minus=0
for i in range(n):
    if a[i]<0:
        minus+=1
if minus%2==0:
    ans=0
    for i in range(n):
        ans+=abs(a[i])
    print(ans)
else:
    for i in range(n):
        a[i]=abs(a[i])
    
    print(sum(a)-min(a)*2)

Measured memory_bytes: 14412
MOD = 10**9 + 7

n, a, b = map(int, input().split())

ans = pow(2, n, MOD) - 1

# invs[x]: xの逆元 (x:0～n)
def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs

invs = getInvs(2*10**5, MOD)

def f(n, k):
    num = 1
    for i in range(n-k+1, n+1):
        num *= i
        num %= MOD
    for i in range(k+1):
        num *= invs[i]
        num %= MOD
    return num

numA = f(n, a)
numB = f(n, b)
#print('numA:', numA, '/ numB:', numB)

print((ans - numA - numB) % MOD)


Measured memory_bytes: 10904
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    input! {
        n: usize, m: usize,
        edges: [(Usize1, Usize1); m]
    };

    let mut graph = vec![Vec::new(); n];
    let mut indegree = vec![0; n];
    for (u, v) in edges {
        graph[u].push(v);
        indegree[v] += 1;
    }
    let mut que = VecDeque::new();
    for i in 0..n {
        if indegree[i] == 0 {
            que.push_back(i);
        }
    }
    let mut dp = vec![0; n];
    while let Some(u) = que.pop_front() {
        for &v in &graph[u] {
            indegree[v] -= 1;
            if indegree[v] == 0 {
                dp[v] = dp[u] + 1;
                que.push_back(v);
            }
        }
    }
    let res = dp.into_iter().max().unwrap();
    println!("{}", res);
}


Measured memory_bytes: 10412
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto n = readln.chomp.to!int;
    auto as = readln.split.to!(int[]);
    sort(as);
    auto x = as[$-1];
    as = as[0..$-1];
    int y, d = int.max;
    foreach (a; as) {
        auto e = abs((x+1)/2 - a);
        if (e < d) {
            y = a;
            d = e;
        }
    }
    writefln("%d %d", x, y);
}

Measured memory_bytes: 4244
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>n>>k;
    
    
    cout<<n-k+1<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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


int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())
#define rSORT(v) std::sort(v.begin(), v.end(),std::greater<int>())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<ll>> dp(100010, vector<ll>(3, 0)), a(100010, vector<ll>(3, 0));
    for (int i = 0; i < N; ++i) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= 2; ++j) {
            for (int k = 0; k <= 2; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 3; ++i) chmax(ans, dp[N][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>

//#define PI 3.141592653589

using namespace std;


int main()
{
	string input;
	map<char, int> table;
	int num;
	
	table['I'] = 1;
	table['V'] = 5;
	table['X'] = 10;
	table['L'] = 50;
	table['C'] = 100;
	table['D'] = 500;
	table['M'] = 1000;
	
	//cout << table["M"] << endl;
	
	while (cin >> input)
	{
		num = 0;
		//cout << input[0] << endl;
		
		for (int i=0; i<input.length()-1; i++)
		{
			//cout << input[i] << endl;
			//cout << table[ input[i] ] << endl;
			
			if (table[input[i]] < table[input[i+1]])
			{
				num -= table[input[i]];
			} else {
				num += table[input[i]];
			}
			
		}
		num += table[input[input.length()-1]];
		cout << num << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  int count=0;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

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

int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> A(M);
	int costL = 0;
	int costR = 0;
	for (int i = 0; i < M; i++)
	{
		cin >> A[i];
		if (A[i] < X)
			costL++;
		if (A[i] > X)
			costR++;
	}
	if (costL < costR)
		cout << costL << endl;
	else
		cout << costR << endl;
	return 0;
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
A = {}

for i in range(H):
    row = list(map(int, input().split()))
    for j in range(W):
        A[row[j]] = [i+1, j+1]

Q = int(input())
ANS = [0] * (H * W + 1)

for i in range(D+1, H * W +1):
    ANS[i] = ANS[i-D] + abs(A[i][0] - A[i-D][0]) + abs(A[i][1] - A[i-D][1])

for _ in range(Q):
    L, R = map(int, input().split())
    print(ANS[R] - ANS[L])


Measured memory_bytes: 72108
#include <iostream>
#include <vector>
#include <set>

using namespace std;

unsigned int xor32(){
    static unsigned int y = 2463534242;
    y = y ^ (y << 13); y = y ^ (y >> 17);
    return y = y ^ (y << 5);
}

int main(){
    int D; cin >> D;
    vector<int> c(26, 0);
    for(auto& t : c) cin >> t;
    vector s(D, vector(26, 0));
    for(auto& v : s){
        for(auto& t : v) cin >> t;
    }
    vector<int> last(26, 0);
    vector<set<int>> days(26);
    for(int i=0;i<26;i++){
        days[i].insert(0);
        days[i].insert(D+1);
    }
    vector<int> select(D+1, -1);
    long long score = 0;
    for(int i=1;i<=D;i++){
        int t = -1;
        long long best = 0;
        for(int j=0;j<26;j++){
            long long cur = s[i-1][j];
            for(int k=0;k<26;k++){
                if(j==k) continue;
                cur -= c[k] * (i - last[k]);
            }
            if(t == -1 || best < cur){
                t = j;
                best = cur;
            }
        }
        days[t].insert(i);
        select[i] = t;
        last[t] = i;
        score += best;
    }
    for(int i=0;i<10000000;i++){
        int d = xor32()%D + 1;
        int q = xor32()%26;
        long long sub = 0;
        sub -= s[d-1][select[d]];
        sub += s[d-1][q];
        auto it = days[select[d]].find(d);
        --it;
        auto pre = *it;
        ++it; ++it;
        auto next = *it;
        sub += ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[select[d]];
        sub -= (next-pre)*(next-pre-1)/2 * c[select[d]];
        it = days[q].lower_bound(d);
        next = *it;
        --it;
        pre = *it;
        sub -= ((d-pre)*(d-pre-1)/2 + (next-d)*(next-d-1)/2) * c[q];
        sub += (next-pre)*(next-pre-1)/2 * c[q];
        if(sub > 0){
            days[select[d]].erase(d);
            days[q].insert(d);
            select[d] = q;
            score += sub;
        }
    }
    for(int i=1;i<=D;i++) cout << select[i]+1 << endl;
}

Measured memory_bytes: 3704
require("fs").readFileSync("/dev/stdin","utf8").split('\n\n').map(function(i){l=/1.*1/.exec(i.replace(/\s/g,''))[0].length%10;console.log(l?l==5?'B':l==4?'C':l==6?'D':l==1?'E':l==9?'G':'F':'A')})

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

typedef long long lint;
typedef unsigned long long ulint;
#define MOD 1000000007

int main(){
    lint N;
    lint a[200001];
    cin >> N;

    lint sum[200001];
    sum[0]=0;
    for(int i=1;i<=N;i++){
        cin >> a[i];
        sum[i]=sum[i-1]+a[i];
    }
    lint min=100000000000000000;
    for(int i=1;i<N;i++){
        if(abs(sum[N]-2*sum[i])<min) min=abs(sum[N]-2*sum[i]);
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int INF = 1e9 + 7;

string YorN(bool P) { if (P)return "YES"; else return "NO"; }

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int>r(R), A(M), B(M), C(M);
    for (int i = 0; i < R; i++)cin >> r[i];

    //頂点から頂点への距離を格納
    //d[i][i]==0;
    vector<vector<int>>d(N+1,vector<int>(N+1,INF));
    for (int i = 1; i <= N; i++) { d[i][i] = 0; }
    for (int i = 0; i < M; i++) {
        int A, B, C;
        cin >> A >> B >> C;
        d[A][B] = C;
        d[B][A] = C;
    }

    //ワーシャルフロイド法によって頂点iと頂点jの最短経路を求める
    for (int i = 1; i <= N; i++) {//経由する頂点
        for (int j = 1; j <= N; j++) {//from
            for (int k = 1; k <= N; k++) {//to
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }

    //全ての通り順を試して一番小さいコストを求める
    long long ans = INF;
    sort(r.begin(), r.end());
    do{
        long long cost = 0;
        for (int i = 0; i < R-1; i++) {
            cost += d[r[i]][r[i + 1]];
        }
        ans = min(ans, cost);
    } while (next_permutation(r.begin(), r.end()));

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
     cin>>arr[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
  }
  cout<<dp[n-1];
  
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	int x=a+b,y=a-b,z=a*b;
	if(x>=y&&x>=z) cout<<x;
	else if(x<=y&&y>=z) cout<<y;
	else if(x<=z&&z>=z) cout<<z;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[2]*10+a[1]+a[0]<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int K;
	long sum = 0;
	int min;
	int tmp;
	
	scanf("%d", &K);
	
	for(int a = 1; a <= K; a++) {
		for(int b = 1; b <= K; b++) {
			for(int c = 1; c <= K; c++) {
				min = a;
				if( min > b ) min = b;
				if( min > c ) min = c;	
				
				for(int i = 1; i <= min; i++) {
					if( (a % i) != 0 )	continue;
					if( (b % i) != 0 )	continue;
					if( (c % i) != 0 )	continue;
					
					tmp = i;
				}
				
				sum += tmp;
			}
		}
	}
	
	printf("%ld\n", sum);
	
	return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
    using namespace std;
    #define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
     
    typedef long long ll;
     
    int main() {FIN
    	
    	ll a, n;
    	double b;
    	cin >> a >> b;
    	n = (ll)(b * 100 + 0.01);
    	cout << (a * n) / 100 << "\n";
    	return 0;
    }

Measured memory_bytes: 3736
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>

using namespace std;


int main() {
    int n, a, t[4] = {};
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> a;
        t[a]++;
    }
    double dp[n+1][n+1][n+1];
    dp[0][0][0] = 0.0;
    for(int z=0; z<=t[3]; z++) {
        for(int y=0; y<=n; y++) {
            for(int x=0; x<=n; x++) {
                if((x|y|z) && x+y+z <= n) {
                    dp[x][y][z] = n;
                    if(x) dp[x][y][z] += x * dp[x-1][y][z];
                    if(y) dp[x][y][z] += y * dp[x+1][y-1][z];
                    if(z) dp[x][y][z] += z * dp[x][y+1][z-1];
                    dp[x][y][z] /= (x+y+z);
                }
            }
        }
    }
    cout << setprecision(15) << fixed << dp[t[1]][t[2]][t[3]] << endl;
    
}

Measured memory_bytes: 213120
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,n=0,m=0;
            int[][] card=null;
            int[] mat=null;
            while ((line = br.readLine()) != null) {
            	if(first){
            		String[] str=line.split(" ");
            		n=Integer.parseInt(str[0]);
            		m=Integer.parseInt(str[1]);
            		card=new int[n][m];
            		mat=new int[m];
            		first=false;
            	}else{
            		if(i<n){
            		String[] str=line.split(" ");
            		for(int j=0;j<m;j++){
            			card[i][j]=Integer.parseInt(str[j]);
            		}
            		i++;
            		}else{
            			mat[i-n]=Integer.parseInt(line);
            			i++;
	            		if(i==n+m){
	            			for(int j=0;j<n;j++){
	            				int sum=0;
	            				for(int l=0;l<m;l++){
	            					sum+=(mat[l]*card[j][l]);
	            				}
	            				System.out.println(sum);
	            			}
	            			break;
	            		}
            		}
            	}
            }
        }
    }

}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll n;
    string s1,s2;
    cin >> n >> s1 >> s2;

    ll ans = 1;
    ll i;

    if(s1.at(0) == s2.at(0)){
        ans *= 3;
        i = 1;
    }else{
        ans *= 6;
        i = 2;
    }

    while(i < s1.size()){
        if(s1.at(i-1) == s2.at(i-1) && s1.at(i) == s2.at(i)){
            ans *= 2;
            i ++;
        }else if(s1.at(i-1) == s2.at(i-1) && s1.at(i) != s2.at(i)){
            ans *= 2;
            i += 2;
        }else if(s1.at(i-1) != s2.at(i-1) && s1.at(i) == s2.at(i)){
            i ++;
        }else{
            ans *= 3;
            i += 2;
        }

        ans %= 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256