akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;
const int mod1=998244353;


struct UnionFind{
	vector<int> data;
	
	UnionFind(int sz){
		data.assign(sz,-1);
	}
	
	bool unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return(false);
		if(data[x]>data[y]) swap(x,y);
		data[x]+=data[y];
		data[y]=x;
		return(true);
	}
	
	int find(int k){
		if(data[k]<0) return(k);
		return(data[k]=find(data[k]));
	}
	
	int size(int k){
		return(-data[find(k)]);
	}
};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> x(m),y(m),z(m);
	rep(i,m){
		cin >> x.at(i) >> y.at(i) >> z.at(i);
		x.at(i)--;
		y.at(i)--;
	}
	UnionFind uf=UnionFind(n);
	rep(i,m){
		uf.unite(x.at(i),y.at(i));
	}
	vector<bool> a(n);
	int ans=0;
	rep(i,n){
		if(!a.at(uf.find(i))){
			ans++;
			a.at(uf.find(i))=true;
		}
	}
	cout << ans << endl;
}


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

int main(int argc, const char * argv[]) {
    int r, g, b;
    
    cin >> r >> g >> b;
    
    int res = r * 100 + g * 10 + b;
    if (res % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
a, b, c, d,e = map(int, input().split())
if a == 0:
    print(1)
else:
    if b==0:
        print(2)
    else:
        if c==0:
            print(3)
        else:
            if d==0:
                print(4)
            else:
                print(5)

Measured memory_bytes: 9172
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main(){
	string w;
	int m;
	for(;;){
		cin >> w;
		if(w[0]=='-') break;
		cin >> m;
		for(int i=0; i<m; i++){
			int h;
			cin >> h;

			string s1 = w.substr(0, h);
			string s2 = w.substr(h, w.length());
			w = s2+s1;
		}
		cout << w << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
def main():
    coin_500 = int(input())
    coin_100 = int(input())
    coin_50 = int(input())
    target_val = int(input())

    ans_num = 0

    for c_500 in range(coin_500+1):
        for c_100 in range(coin_100+1):
            for c_50 in range(coin_50+1):
                if c_500 * 500 + c_100*100 + c_50*50 == target_val:
                    ans_num += 1
    print(ans_num)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void){
	int i,j,tmp,max,sum,n[100];
	char s[100];
	while(scanf("%s",s)!=EOF){
		for(i=0;s[i]!='\0';i++){
			switch(s[i]){
				case 'I':
					n[i]=1;
					break;
				case 'V':
					n[i]=5;
					break;
				case 'X':
					n[i]=10;
					break;
				case 'L':
					n[i]=50;
					break;
				case 'C':
					n[i]=100;
					break;
				case 'D':
					n[i]=500;
					break;
				case 'M':
					n[i]=1000;
					break;
			}
		}
		max=i;
		for(i=0;i<max-1;i++){
			if(n[i]<n[i+1]){
				n[i]*=(-1);
			}
		}
		sum=n[0];
		for(i=1;i<max;i++){
			sum+=n[i];
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 100005;

int n;
vector < pair <int, int> > adj[N];
int paint[N];

void dfs(int u, int p, int col) {
  paint[u] = col;
  for (auto v : adj[u]) {
    if (v.first == p) continue;
    if (v.second & 1) {
      dfs(v.first, u, col ^ 1);
    } else {
      dfs(v.first, u, col);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    adj[x].push_back({y, z});
    adj[y].push_back({x, z});
  }
  dfs(1, -1, 0);
  for (int i = 1; i <= n; i++) {
    cout << paint[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 9216
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
    int N, H, H_max; cin >> N;
    REP0(i,N) {
        cin >> H; 
        if (i==0 && (H_max = H)) continue;
        if (H_max - H >= 2) {
            cout << "No" << endl;
            return;
        }
        H_max = max(H, H_max);
    }
    cout << "Yes" << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 256
from copy import deepcopy

n, m = [int(i) for i in input().split()]

#switch[a][b] a番のスイッチがb番の電球とつながっているなら1
switch = [[0]*(m+1) for i in range(n+1)]

for i in range(1,m+1):
    s = [int(j) for j in input().split()]
    del(s[0])

    for j in s:
        switch[j][i] = 1

p = [0] + [int(i) for i in input().split()]

count = 0

for bit in range(1 << n):
    sc = deepcopy(p)
    for i in range(n):
        if bit >> i & 1:
            for j in range(1,m+1):
                sc[j] += switch[i+1][j]

    if all([k % 2 == 0 for k in sc]):
        count += 1

print(count)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[2011];
int l[2011][2];
int j[2011];

long long x,y,z,mod=1000000007;
//string r;
char r[2010][2111];

P u[1];
priority_queue<P> q;
//stack<P> s;

vector<int> v;

bool as(P a,P b)
{
  return a.x<b.x;
}

int f(int n)
{
  if(j[n]==n) return n;
  return j[n]=f(j[n]);
}

int main()
{
  scanf("%d %d",&a,&b);
  for(int t=1;t<=a;t++)
    scanf("%s",r[t]+1);
  k=max(a,b);
  for(int h=1;h<=b;h++)
  {
    for(int t=2;t<=a;t++)
    if(o[t]>1) o[t]--;
    else
    {
      o[t]=0;
      for(int i=h;i<=b;i++)
      if((r[t-1][h]==r[t][h])==(r[t-1][i]==r[t][i])) o[t]++;
      else break;
    }
    //if(h==4)
    //for(int t=1;t<=a;t++)
    //printf("%d\n",o[t]);
    iota(j+1,j+a+1,1);
    l[1][0]=l[1][1]=1;
    for(int t=2;t<=a;l[t][0]=l[t][1]=t,t++)
    q.push({t,o[t]});
    for(;q.size();q.pop())
    {
      l[f(q.top().x-1)][1]=l[f(q.top().x)][1];
      //printf("%d %d %d\n",l[f(q.top().x-1)][1],h,q.top().y*(l[f(q.top().x-1)][1]-l[f(q.top().x-1)][0]+1));
      k=max(k,q.top().y*(l[f(q.top().x-1)][1]-l[f(q.top().x-1)][0]+1));
      j[f(q.top().x)]=f(q.top().x-1);
    }
    
  }
  printf("%d",k);
}
//3




Measured memory_bytes: 4608
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(ReadLine());
        }

        public static long[] Reads()
        {
            return ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x,long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }

        public static long C(long n,long k)
        {
            long x=1;
            for (long i = 1; i <=k; i++)
            {
                x *= n - i + 1;
                x /= i;
            }
            return x;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var q = Reads();
            var w = q[0];
            var h = q[1];
            var x = q[2];
            var y = q[3];
            if ((decimal)w/2 == x && (decimal)h/2  == y)
                WriteLine("{0} {1}", w * h / 2.0, 1);
            else
                WriteLine("{0} {1}", w * h / 2.0, 0);



            Console.Out.Flush();
        }
    }
}


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

// headers {{{
using namespace std;
// using namespace rel_ops;
 
const double pi=acos(-1.0);
const double eps=1e-11;
const int INF=0x7FFFFFFF;
template<class T> inline bool checkmin(T &a,T b){return b<a?a=b,1:0;}
template<class T> inline bool checkmax(T &a,T b){return b>a?a=b,1:0;}
template<class T> inline T sqr(T x){return x*x;}
template<class T> inline bool bit(T a, int b) {return (a>>b)&1;}
inline int popcount(int n) { return __builtin_popcount(n); }
inline int popcount(long long n) { return __builtin_popcountll(n); }
typedef long long int64;
typedef unsigned long long uint64;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define eb(args...) emplace_back(args)
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ff first
#define ss second
#define sz(g) int(g.size())
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
#ifdef LOCAL
#define dout cerr 
void out() { dout << endl; }
template<typename A, typename... B> void out(A a, B... b) { dout << ' ' << a; out(b...); }
#define dbg(args...) dout << __LINE__ << ":(" << #args << ") -> ", out(args)
template<class T>void show(T a, int n){for(int i=0; i<n; ++i) cout<<a[i]<<' '; cout<<endl;}
template<class T>void show(T a, int r, int l){for(int i=0; i<r; ++i)show(a[i],l);cout<<endl;}
constexpr bool local = true;
#else
#define dbg(...)
#define dout if(true);else cerr
#define out(...)
#define show(...)
constexpr bool local = false;
#endif
// }}}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    int n;
    while (cin >> n) {
        for (int i = 1; i<=360; i++) {
            if (i * n % 360 == 0) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3636
#include <functional>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string, int, function<bool(const string&, const string&)>> m(
        [](const string& a, const string& b) {
            return a.size() == b.size() ? a < b : a.size() < b.size();
        });
    for (int i = 0; i < n; ++i) {
        string s;
        int number;
        cin >> s >> number;
        m[s] += number;
    }
    for (auto&& i : m) {
        cout << i.first << ' ' << i.second << endl;
    }
}


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


int main(){
    string n;
    cin>>n;

    if(n.find('9') != string::npos) cout<< "Yes"<<endl;
    else cout<< "No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;
    int a, b;
    cin >> a >> b;

    cout << max({a + b, a - b, a * b}) << endl;

}

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

Measured memory_bytes: 256
#include <iostream>;

using::std::cin;
using::std::cout;
using::std::endl;

const int DATA_MAX = 32;
const int data[DATA_MAX] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
  	int i = 0;
	cin >> i;
  	if (0 < i and i <= DATA_MAX) {
    	cout << data[i-1] << endl;
    }
  	return 0;
}

Measured memory_bytes: 256
n=int(input())
edge=[]
for i in range(n-1):
    a,b=map(int,input().split())
    edge.append([a,b])
c=list(map(int,input().split()))
c.sort(reverse=True)
node=[0]*n
weight=[-1]*n
edges=[[] for _ in range(n)]
for a,b in edge:
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    node[a-1]=node[a-1]+1
    node[b-1]=node[b-1]+1
s=node.index(max(node))
#print(edges,node)
#print(edges,node)
stack=[]
stack.append(s)
weight[s]=c.pop(0)
while stack:
    #print(stack)
    buf=stack.pop(-1)
    for e in edges[buf]:
        if weight[e]==-1:
            weight[e]=c.pop(0)
            stack.append(e)
w=0
for a,b in edge:
    if(weight[a-1]>weight[b-1]):
        w+=weight[b-1]
    else:
        w+=weight[a-1]
print(w)
for i in range(n):
    print(weight[i])

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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


void solve() {
	int n, x, y;
	cin >> n >> x >> y;
	if (x > y) swap(x, y);
	vector<int> dist(n + 1);
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int cur = j - i;
			cur = min(cur, abs(x - i) + 1 + abs(y - j));
			dist[cur]++;
		}
	}

	for (int i = 1; i < n; i++) cout << dist[i] << endl;

}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a, b, c, d, e, f = LI()

x = f // (100*a)
y = f // (100*b)

max_ = -1
max__ = 1
for i in range(x + 1):
    for j in range(y + 1):
        E = min((a*i + b*j) * e, f - (100*a*i + 100*b*j))
        min_ = inf
        for k in range(E // c + 1):
            for l in range(E // d + 1):
                if c*k + d*l > E:
                    continue
                min_ = min(min_, E - c*k - d*l)
        E -= min_
        if max_ * (a*i + b*j) < E * max__:
            max_ = E
            max__ = a*i + b*j
            ans1 = (a*i + b*j) * 100 + E
            ans2 = E
print(ans1, ans2)

Measured memory_bytes: 74232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(int i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 1e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
ll dp[2][N];
pll val[N];
ll pre[N];
int main()
{
       string s;
       cin>>s;
       fri(i,0,3){
              if(s[i]==s[i+1]){
                     cout<<"Bad";
                     return 0;
              }
       }
       cout<<"Good";
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <unordered_set>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> As(n + 1);
    vector<int> Bs(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> As[i];
    }
    vector<unordered_set<int>> divisor(n + 1);
    // n*sqrt(n)
    for (int i = 1; i <= n; i++) {
        for (int div = 1; div*div <= i; div++) {
            if (i % div == 0) {
                divisor[i].insert(div);
                divisor[i].insert(i / div);
            }
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     cout << i << ": ";
    //     for (auto div: divisor[i]) {
    //         cout << div << ", ";
    //     }
    //     cout << endl;
    // }

    int k = n;
    // log(n) * n/2 * 2sqrt(n)
    while (k != 0) {
        // cout << "k " << k << endl;
        for (int i = (k / 2 + 1); i <= k; i++) {
            Bs[i] = As[i];

            // sqrt(n)
            for (auto div: divisor[i]) {
                As[div] = As[div] ^ Bs[i];
            }
        }
        k = k / 2;
    }

    // cout << "B:";
    // for (int i = 1; i <= n; i++) {
    //     cout << Bs[i] << ", ";
    // }
    // cout << endl;
    int m = accumulate(Bs.begin() + 1, Bs.end(), 0);
    cout << m << endl;
    if (m != 0) {
        string s;
        for (int i = 1; i <= n; i++) {
            if (Bs[i] == 1) {
                cout << i;
                m--;
                if (m == 0) {
                    cout << endl;
                    break;
                } else {
                    cout << " ";
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 122496
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x, n, p[1000], i, ans=1000, mp[1000]={0};
    cin >> x >> n;
    for(i=0;i<n;i++){
        cin >> p[i];
        mp[p[i]]++;
    }
    for(i=0;i<=1000;i++){
        if(mp[i]==0 && abs(x-i)<abs(x-ans)) ans=i;
    }
    cout << ans <<endl;
    return 0;

}


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

int main(){
	int N,K;
	cin >> N >> K;
	vector<int>sum(1001,0);
	vector<int>p(N+1);
	for(int i = 1; i<=N;i++){
		cin >> p[i] ;
	}
	for(int i = 1;i<=1000;i++){
		sum[i] = sum[i-1]+i;
		//cout << sum[i] << endl;
	}
	vector<double>E(N+1,0);
	for(int i = 1; i <= N; i++){
		E[i] = (double)(sum[p[i]])/(double)(p[i]);
	}

	vector<double> E_sum(N+1,0);
	double ans = 0.0;
	for(int i = 1; i<=N;i++){
		if(i <= K){
			E_sum[i] = E_sum[i-1] + E[i];
		}
		else{
			E_sum[i] = E_sum[i-1]+ E[i] - E[i-K];
		}
		ans = max(ans,E_sum[i]);
		//cout << i <<":"<< E[i]<<":"<<E[i-K] << ":"<< E_sum[i] << endl;
	}
	printf("%.12f\n",ans);

	return 0;
}

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

int main(){
    string s; cin >> s;
    char c = s.at(0);
    int cnt = 1;
    for(int ix=0;ix<s.size();ix++){
        if(c != s.at(ix)){
            cnt++;
            c = s.at(ix);
        }
    }
    cout << cnt-1 << endl;
}

Measured memory_bytes: 3688
//============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int x,y;
	while(1){
		cin>>x>>y;

		if (x==0 && y==0)break;

		if (x>y){
			cout<<y<<" "<<x<<endl;
		}
		if (x<=y){
			cout<<x<<" "<<y<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3064
import sys
x=int(input())
ok=[]
for i in range(x+1):
  ok.append(False)
ok[1]=True
for b in range(2, x+1):
  y=b*b
  while y<=x:
    ok[y]=True
    y*=b
for i in range(x):
  if ok[x-i]:
    print(x-i)
    sys.exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  char A[4];
  string ans;
  cin >> A;
  if ((A[0]==A[1] && A[1]==A[2]) || (A[1]==A[2] && A[2]==A[3]))
  ans = "Yes";
  else
  ans = "No";
  
  cout << ans << endl;
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (n); i < (a); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int x;cin>>x;
  cout<<(x==3 ||x==5 ||x==7 ? "YES":"NO")<<endl;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7,inv3=333333336;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e6+5;
int inv[N],bin[N],n,res;
int main(){
	scanf("%d",&n);
	inv[0]=bin[0]=inv[1]=1,bin[1]=inv3;
	fp(i,2,n){
		inv[i]=mul(P-P/i,inv[P%i]);
		bin[i]=mul(bin[i-1],inv3);
	}
	fp(i,1,n)upd(res,mul(bin[i],inv[n-i+1]));
	res=mul(res,inv[n]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
 
int main(){
    int N,M;
    vector<int> T,P,X;
 
    cin >> N;

    for(int i = 0; i < N; i++){
        int t;
        cin >> t;
        T.push_back(t);
    }

    cin >> M;

    for(int i = 0; i < M; i++){
        int p,x;
        cin >> p >> x;
        P.push_back(p);
        X.push_back(x);
    }

    int sum = accumulate(T.begin(), T.end(), 0);

    for(int i = 0; i < M; i++){
        cout << sum + X[i] -T[P[i]-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let k: i32 = read();
    let s: i32 = read();
    let mut sum: i32;
    let mut count = 0;
    for i in 0..k+1{
	sum = s-i;
	if sum < 0 {
	    break;
	}
	if k >= sum {
	    count += sum+1;
	}else if k*2 >= sum{
	    count += k*2+1-sum;
	}
    }
    println!("{}",count);
}


Measured memory_bytes: 4352
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))

ans = 0
for comb in combinations(L, 3):
    l1,l2,l3 = comb
    if l1 != l2 and l2 != l3 and l1 != l3:
        if sum(comb) - max(comb) > max(comb):
            ans += 1

print(ans)


Measured memory_bytes: 68832
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple

ll M = 998244353;
double ep = 1e-6;
const int N = 1e4 + 5;
//ll ans[N][];

int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int h,n; cin>>h>>n;
	vector < pair <ll,ll> > v;
	for(int i=0;i<n;i++)
	{
	    ll p,q; cin>>p>>q; 
	    //q = -q;
	    v.pb(mp(p,q));
	}
	ll ans[h+1][n+1];
	for(int i=1;i<=h;i++) ans[i][0] = 1e9;
	//for(auto it:v) cout<<it.first<<' '<<it.second<<endl;
	for(int i=1;i<=h;i++)
	{
	    //ans[i] = -1e9;
	    for(int j=1;j<=n;j++)
	    {
	        if(v[j-1].first<=i)
	        {
	            //if( ans[i-v[j].first]+v[j].second > 0 )
	            //if( ans[i-v[j].first]==0 ) continue;
	            ans[i][j]=min( ans[i][j-1],ans[i-v[j-1].first][j]+v[j-1].second );
	        }
	        else ans[i][j] = min(ans[i][j-1],v[j-1].second);
	    }
	    //if(ans[i]==-1e9) ans[i]=0;
	}
	//for(int i=h-1;i<2*h;i++) cout<<ans[i]<<' '; cout<<endl;
	
// 	ll k=ans[h-1]; int id=h;
// 	while( ans[id]==k ) id++;
// 	k = ans[id];
// 	for(int i=id;i<N;i++)
// 	{
// 	    k=max( k,ans[i] );
// 	}
	
	cout<<ans[h][n];
	
	
	return 0;
}


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


int main(){
    int64_t A,res,b;
    string B;
    cin>>A>>B;
    b=stoi(B.substr(0,1))*100+stoi(B.substr(2,2));
    res=(A/100)*b;
    res+=((A%100)*b)/100;
    cout<<res<<endl;
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	for i, v := range S {
		if (i+1)%2 == 0 {
			if v == 'L' || v == 'U' || v == 'D' {
				continue
			} else {
				fmt.Println("No")
				return
			}
		}
		if (i+1)%2 == 1 {
			if v == 'R' || v == 'U' || v == 'D' {
				continue
			} else {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


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

using namespace std;

#define INF 1000007

int main(){
   long long int N,x;
   cin >> N >> x;
   vector<long long int> a(N);
   for(int i=0;i<N;i++)cin >> a[i];
   sort(a.begin(),a.end());
   int ans = 0;
   for(int i=0;i<N;i++){
      if(i == N-1){
         if(x == a[i]){
            cout << ans+1;
         }
         else{
            cout << ans;
         }
         return 0;
      }
      if(x >= a[i]){
         x -= a[i];
         ans++;
      }
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int D;
  cin>>D;
  vector<ll> c(26);
  vector<vector<ll>> s(D,vector<ll>(26));
  for(int i=0;i<26;i++){
    cin>>c.at(i);
  }
  for(int i=0;i<365;i++){
    ll M=0;
    for(int j=0;j<26;j++){
      cin>>s.at(i).at(j);
      M=max(M,s.at(i).at(j));
    }
    for(int j=0;j<26;j++){
      if(M==s.at(i).at(j)){cout<<j+1<<endl;break;}
    }
  }
}

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

int main (void)
{
    int n;
    int a[(int)10e5];
    int i, m = 0, c, d = (int)10e9;

    scanf("%d", &n);
    for(i = 0; i < n; ++i){
        scanf("%d", &a[i]);
        if(m < a[i]) {
            m = a[i];
        }
    }
    c = m;
    for(i = 0; i < n; ++i){
        if(abs(m / 2 - a[i]) < d || m == c) {
            c = a[i];
            d = abs(m / 2 - a[i]);
        }
    }
    printf("%d %d\n", m, c);
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const ll N = 1e5+5;
ll n;
ll d[N], dp[N];

int main(){
	cin >> n;
	for(ll i = 0; i < n; i++) cin >> d[i];
	memset(dp, 0, sizeof dp);
	dp[n-2] = dp[n-1] + abs(d[n-2]-d[n-1]);
	for(int i = n-3; i >= 0; i--)
		dp[i] = min(dp[i+1]+abs(d[i]-d[i+1]), dp[i+2]+abs(d[i]-d[i+2]));
	cout << dp[0] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    string s;
    cin >> s;
    ll ans = 0;

    uint max = pow(2,s.size()-1) - 1;

    for(uint i = 0;i <= max;i++){
        uint last_cut = 0;
        uint cnt = 0;
        for(uint j = 1;j<= max;j*=2){
            if(i & j){
                string sub = s.substr(last_cut,cnt - last_cut + 1);
                last_cut = cnt + 1;
                ans += stoll(sub);
            }
            cnt++;
        }
        string sub = s.substr(last_cut);
        ans += stoll(sub);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
a, b, C = list(map(int, input().split()))
h = b * math.sin(math.radians(C))
S = a * h / 2.0
L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(C)))
print(S)
print(L)
print(h)



Measured memory_bytes: 5712
#!/usr/bin/env python3

N = int(input().split()[0])
c_list = []
c_dict = {}
cc_dict = {}
max_v = -float("inf")

for _ in range(N):
    c = input()
    c_list.append(c)
    if c in c_dict:
        v = c_dict[c] + 1
        c_dict[c] = v
    else:
        v = 0
        c_dict[c] = 0
        # cc_dict[0] = c
    if v in cc_dict:
        cc_dict[v].append(c)
    else:
        cc_dict[v] = [c]

    if max_v < v:
        max_v = v

k_list = cc_dict[max_v]
k_list = list(sorted(k_list))
ans = "\n".join(k_list)

print(ans)


Measured memory_bytes: 54816
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;
// ll a[MAX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0), cout.tie(0);
    ll n;cin>>n;
    string s="";
    while(n)
    {
    	n--;
    	s+='a'+n%26;
		n/=26;
	}
//	cout<<endl;
	reverse(s.begin(),s.end());
    cout<<s;
    
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a, b) for (int i = (a); i < (b); i++ )

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

const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {
    int N;
    cin >> N;
    int A[N];
    rep(i,0,N) {
        cin >> A[i];
    }
    int d = 0;
    int ans = 1;
    int now = A[0];
    rep(i,0,N) {
        if (now==A[i]) {
            now = A[i];
            continue;
        }
        else if (A[i]-now>0 && d >= 0) {
            d = 1;
            now = A[i];
            continue;
        }
        else if (A[i]-now<0 && d<=0) {
            d = -1;
            now = A[i];
            continue;
        }
        else {
            now = A[i];
            ans++;
            d = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=998244353
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N,S=map(int,input().split())
A=tuple(map(int,input().split()))
dp=[[0]*3001 for _ in range(N+1)]
dp[0][0]=1
for i in range(N):
    for j in range(3001):
        dp[i+1][j]+=dp[i][j]*2
        dp[i+1][j]%=MOD
        if j-A[i]>=0:
            dp[i+1][j]+=dp[i][j-A[i]]
            dp[i+1][j]%=MOD
print(dp[-1][S])

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

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

int a[100005],ac[100005],wa[100005];
int c,p;
string ver[100005];

int main(void){
	int N,M;
	cin >> N >> M;
	REP(i,M){
		cin >> a[i] >> ver[i];
		a[i]--;
		if(ver[i][0] == 'W')
			wa[a[i]]++;
		if(ver[i][0] == 'A'){
			ac[a[i]] = 1;
			if(wa[a[i]] >= 0)
			p += wa[a[i]];
			wa[a[i]] = -1000000;
		}
	}
	REP(i,N)
		c += ac[i];
	cout << c << ' ' << p << endl;
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>

using namespace std;

int stuw[10] , answ = 0;
int stuk[10] , ansk = 0;

int main(){

	for(int i = 0; i < 10; i++){
		cin >> stuw[i];
	}

	for(int i = 0; i < 10; i++){
		cin >> stuk[i];
	}

	sort(stuw , stuw + 10 , greater<int>());
	sort(stuk , stuk + 10 , greater<int>());

	for(int i = 0; i < 3; i++){
		answ += stuw[i];
		ansk += stuk[i];
	}

	cout << answ << " " << ansk << endl;

	return 0;
}

Measured memory_bytes: 1180
import java.util.Scanner;


public class Main {
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		while(true){
			int r = sn.nextInt(), c = sn.nextInt();
			if(r+c == 0) break;
			System.out.println(r%2==1 && c%2 == 1? "no": "yes");
		}
	}
}

Measured memory_bytes: 21040
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;
inline int read(){
    int re = 0,ch = getchar();
    while(!isdigit(ch))ch = getchar();
    while(isdigit(ch))re = (re<<1)+(re<<3)+ch-'0',ch = getchar();
    return re;
}
const int maxn = 200010;
struct edge{
    int v,w,nxt;
}e[maxn];
int h[maxn],cnt;
inline void add(int u,int v,int w){
    e[++cnt].v = v;
    e[cnt].w = w;
    e[cnt].nxt = h[u];
    h[u] = cnt;
}
inline int color(int c){
    if(c >= 3)c -= 3;
    if(c < 0)c += 3;
    return c;
}
int col[maxn],cnum[3],nsz,esz;
bool flag = 1,vis[maxn];
void coloring(int u){
    cnum[col[u]]++;nsz++;vis[u] = 1;
    for(int i = h[u];i;i = e[i].nxt){
        int v = e[i].v;
        if(e[i].w == 1)esz++;
        if(!vis[v]) col[v] = color(col[u] + e[i].w),coloring(v);
        else if(col[v] != color(col[u] + e[i].w)) flag = 0;
    }
}
int n,m;
long long ans;
int main(){
    n = read(),m = read();
    int u,v;
    for(int i = 1;i <= m;i++){
        u = read(),v = read();
        add(u,v,1);
        add(v,u,-1);
    }
    for(int i = 1;i <= n;i++){
        if(vis[i])continue;
        memset(cnum,0,sizeof(cnum));
        nsz = 0,esz = 0,flag = 1;
        coloring(i);
        if(!flag) ans += (long long)nsz * nsz;
        else if(cnum[0] && cnum[1] && cnum[2]) 
            ans += (long long)cnum[0] * cnum[1]
             + (long long)cnum[1] * cnum[2] + (long long)cnum[2] * cnum[0];
        else ans += esz;
    }
    printf("%lld",ans);
    return 0;
} 

Measured memory_bytes: 6656
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
S=[[d for d in input()] for i in range(H)]
ans=[[0 for j in range(W)] for i in range(H)]
t=0
for i in range(H):
 p=0
 for j in range(W):
  if S[i][j]==".":
   p+=1
  else:
   p=0
  ans[i][j]+=p
for i in range(H):
 p=0
 for j in range(W)[::-1]:
  if S[i][j]==".":
   p+=1
  else:
   p=0
  ans[i][j]+=p
for j in range(W):
 p=0
 for i in range(H):
  if S[i][j]==".":
   p+=1
  else:
   p=0
  ans[i][j]+=p
for j in range(W):
 p=0
 for i in range(H)[::-1]:
  if S[i][j]==".":
   p+=1
  else:
   p=0
  ans[i][j]+=p
  t=max(t,ans[i][j])
print(t-3)

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

using namespace std;


typedef long long LL;


map <vector<int>, int> mp;


vector <int> a;


int n;


char str[11];


int main()
{
	scanf("%d", &n);
	
	a.resize(26);
	
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", str);
		int len = strlen(str);
		for (int j = 0; j < len; j++)
			a[str[j]-'a']++;
		mp[a]++;
		for (int j = 0; j < len; j++)
			a[str[j]-'a'] = 0;
	}
	
	long long Ans = 0;
	for (auto v : mp)
		Ans += 1LL * v.second * (v.second-1) / 2LL;
	
	printf("%lld\n", Ans);
	
	return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s,t;

    cin>>s>>t;

    if(s.size()!=t.size()){


        for(int i=0;i<s.size()-1;i++){
            cout<<s[i];
            cout<<t[i];
        }
        if(s.size()!=t.size()){
            cout<<s[s.size()-1];
        }
    
    }else{
        for(int i=0;i<s.size();i++){
            cout<<s[i]<<t[i];
        }
    }

    cout<<endl;
}

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

typedef long long ll;
const int maxn=67;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
//#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,k;
int x[maxn],y[maxn],c[maxn];
long double r[maxn];

const long double eps=(1e-10);

int check2(long double X,long double Y)
{
    int cnt=0;
    for (int i=1;i<=n;i++)
        cnt+=(hypot(X-x[i],Y-y[i])<=r[i]+eps);
    return cnt>=k;
}

void get_intersection(int X,int Y,vector<pair<long double,long double> > &v)
{
    long double dist=hypot(x[X]-x[Y],y[X]-y[Y]);
    if (dist>r[X]+r[Y]||dist<abs(r[X]-r[Y])) return;

    long double costheta=(r[X]*r[X]+dist*dist-r[Y]*r[Y])/(2*r[X]*dist);
    long double sintheta=sqrt(1.0-costheta*costheta);

    long double xx=(x[Y]-x[X])*(r[X]/dist),yy=(y[Y]-y[X])*(r[X]/dist);

    v.pb(mkp(x[X]+xx*costheta-yy*sintheta,y[X]+xx*sintheta+yy*costheta));
    v.pb(mkp(x[X]+xx*costheta+yy*sintheta,y[X]+xx*sintheta-yy*costheta));
}

bool check(long double X)
{
    for (int i=1;i<=n;i++) r[i]=X/c[i];

    vector<pair<long double,long double> > v;

    int ok=0;
    for (int i=1;i<=n;i++) ok=max(ok,check2(x[i],y[i]));
    for (int i=1;i<=n;i++)
        for (int j=i+1;j<=n;j++)
    {
        v.clear();
        get_intersection(i,j,v);
        for (auto l:v) ok=max(ok,check2(l.F,l.S));
    }
    return ok;
}

int32_t main()
{
    IOS
    cin>>n>>k;
    for (int i=1;i<=n;i++) cin>>x[i]>>y[i]>>c[i];

    long double L=0.0,R=500000.0;
    for (int _=1;_<=80;_++)
    {
        long double M=(L+R)/2;
        if (check(M)) R=M;
        else L=M;
    }
    cout<<fixed<<setprecision(15)<<R<<endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int main(){
    ll n,ans = 0;
    cin>>n;
    vector<P>a(n);
    rep(i,n)cin>>a[i].first>>a[i].second;
    sort(all(a),[&](P a, P b){return a.first+a.second > b.first+b.second;});
    rep(i,n){
        if(i%2 == 0)ans += a[i].first;
        else ans -= a[i].second;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  map<ll,ll> mp;
  ll n;
  cin>>n;
  vin a(n);
  ll sum=0;
  rep(i,n) {
    cin>>a[i];
  sum+=a[i];
    mp[i]=sum;
  }
  /////////
  
  ll ans=INF;
  ll cnt_s=0;
  for(int i=0;i<n-1;i++){//i番目までたす
    ll sa;
    sa=abs(mp[i]-(sum-mp[i]));
    ans=min(ans,sa);
  }
 
 
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 13568
import string

s=list(input())
k=int(input())

str=string.ascii_lowercase
abc=str+str

s_len=len(s)
for i in range(s_len):
  si_inx=abc.index(s[i])

  if i==s_len-1:
    k%=26
    s[i]=abc[si_inx+k]
    break

  if s[i]=='a':
    continue

  if k>=26-si_inx:
    k-=26-si_inx
    s[i]='a'
  else:
    continue

  if k<=0:
    break

print(''.join(s))

Measured memory_bytes: 4676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
map<int,double>mp;
main()
{
     int n,i,j;
     cin>>n;
     double p[n+1],ans=0;
     for(i=1;i<=n;i++)
     {
         scanf("%lf",&p[i]);
     }
     mp[1]=p[1];mp[0]=1-p[1];mp[-1]=0;
     for(i=2;i<=n;i++)
     {
        for(j=i;j>=0;j--)
        {
            mp[j]=mp[j]*(1-p[i])+mp[j-1]*p[i];
        }
        //cout<<mp[0]<<" "<<mp[1]<<" "<<mp[2]<<" "<<mp[3]<<endl;
     }
     for(i=n/2+1;i<=n;i++)
     {
         ans+=mp[i];
         //cout<<i<<" "<<mp[i]<<endl;
     }
     printf("%.10lf\n",ans);
     //cout<<ans<<endl;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
typedef long long ll;
string s;
int main() {
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if(s[i] == 'R') {
            int j = i;
            while (j < 3 && s[j] == 'R') j++;
            cnt = max(cnt, j - i);
        }
    }
    printf("%d\n", cnt);
}


Measured memory_bytes: 3760
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int A, B;
        cin >> A >> B;

        string S;
        cin >> S;

        for (int i = 0; i < S.size(); i++)
        {
                if (i == A)
                {
                        if (S[i] != '-')
                        {
                                cout << "No" << endl;
                                return 0;
                        }
                }
                else
                {
                        if (S[i] == '-')
                        {
                                cout << "No" << endl;
                                return 0;
                        }
                }
        }
        cout << "Yes" << endl;
        return 0;

        return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        boolean[] ary = new boolean[53];
        for (int i = 0; i < n; i++) {
            ary[convert(sc.next(), sc.nextInt())] = true;
        }
        
        for (int i = 1; i < 53; i++) {
            if (ary[i] == false) {
                String[] s = convert(i);
                System.out.println(s[0] + " " + s[1]);
            }
        }
    }
    
    public static int convert(String p, int n) {
        int res = 0;
        if (p.equals("H")) {
            res += 13;
        } else if (p.equals("C")) {
            res += 26;
        } else if (p.equals("D")) {
            res += 39;
        }
        
        return res + n;
    }
    
    public static String[] convert(int n) {
        String[] res = new String[2];
        if (0 < n && n <= 13) {
            res[0] = "S";
        } else if (13 < n && n <= 26) {
            res[0] = "H";
        } else if (26 < n && n <= 39) {
            res[0] = "C";
        } else if (39 < n && n <= 52) {
            res[0] = "D";
        }
        
        int i = (n%13 == 0) ? 13 : n%13;
        
        res[1] = new Integer(i).toString();
        return res;
    }
}

Measured memory_bytes: 26376
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	ll N, K, R, S, P;
	string T;
	cin >> N >> K;
	cin >> R >> S >> P;
	cin >> T;
	ll ans = 0;
	rep(k, K) {
		int i = k;
		vl DP_prev(3, 0);
		vl DP_new(3, 0);
		while (1) {
			char t = T[i];
			rep(d, 3) {
				DP_new[d] = 0;
			}
			if (t == 'r') {
				DP_new[0] = max(DP_new[0], DP_prev[1] + P);
				DP_new[0] = max(DP_new[0], DP_prev[2] + P);
				DP_new[1] = max(DP_new[1], DP_prev[0]);
				DP_new[1] = max(DP_new[1], DP_prev[2]);
				DP_new[2] = max(DP_new[2], DP_prev[0]);
				DP_new[2] = max(DP_new[2], DP_prev[1]);
			}
			if (t == 's') {
				DP_new[1] = max(DP_new[1], DP_prev[2] + R);
				DP_new[1] = max(DP_new[1], DP_prev[0] + R);
				DP_new[2] = max(DP_new[2], DP_prev[1]);
				DP_new[2] = max(DP_new[2], DP_prev[0]);
				DP_new[0] = max(DP_new[0], DP_prev[2]);
				DP_new[0] = max(DP_new[0], DP_prev[1]);
			}
			if (t == 'p') {
				DP_new[2] = max(DP_new[2], DP_prev[0] + S);
				DP_new[2] = max(DP_new[2], DP_prev[1] + S);
				DP_new[0] = max(DP_new[0], DP_prev[2]);
				DP_new[0] = max(DP_new[0], DP_prev[1]);
				DP_new[1] = max(DP_new[1], DP_prev[0]);
				DP_new[1] = max(DP_new[1], DP_prev[2]);
			}
			DP_prev = DP_new;
			i += K;
			if (i >= N)
				break;
		}
		ll anstmp = 0;
		rep(d, 3) {
			anstmp = max(anstmp, DP_prev[d]);
		}
		ans += anstmp;
	}

	cout << ans << endl;

	return 0;
}

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

const long long MOD=pow(10,9)+7;
int main(){
  int N;cin>>N;
  long long ans=1;
  for(int i=0;i<N;i++){
    ans*=i+1;
    ans%=MOD;
  }
  cout <<ans<<endl;
}

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

int main() {
    string S;
    cin >> S;
    int ans=0;
    int n=S.size();

    //dp[i]:右端から[i+1]桁までの数mod2019,ten[i]:10^(i+1)mod2019
    vector<int> dp(n,0), m(2019,0), ten(n,0);

    //初期化
    dp[0] = S[n-1]-'0';
    ten[0] = 10;
    m[dp[0]]++;
    m[0]++;

    for(int i=1;i<n;i++){
        ten[i] = (ten[i-1]*10)%2019;
    }

    for(int i=1;i<n;i++){
        dp[i] = (dp[i-1]+ten[i-1]*(S[n-i-1]-'0'))%2019;
        m[dp[i]]++;
    }

    for(int i=0;i<2019;i++){
        ans += m[i]*(m[i]-1)/2;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {


	int n; cin>>n;
	string arr[n];
	int AC=0,WA=0,TLE=0,RE=0;
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		if(arr[i]=="AC")
			AC++;
		else if(arr[i]=="WA")
			WA++;
		else if(arr[i]=="TLE")
			TLE++;
		else
			RE++;
	}
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
	return 0;
}


Measured memory_bytes: 6704
#include <cstdio>

using namespace std;

int main()
{
	int n;
	int pt[201][3];
	int sum[201] = {0};
	
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++){
		scanf("%d %d %d", &pt[i][0], &pt[i][1], &pt[i][2]);
	}
	
	for (int i = 0; i < 3; i++){
		for (int j = 0; j < n; j++){
			int flag = 0;
			for (int k = 0; k < n; k++){
				if (pt[j][i] == pt[k][i]){
					flag++;
				}
			}
			if (flag == 1){
				sum[j] += pt[j][i];
			}
		}
	}
	
	for (int i = 0; i < n; i++){
		printf("%d\n", sum[i]);
	}
	
	return (0);
}

Measured memory_bytes: 1028