akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

long mod = 1000000007;
/* C++の構造体 メンバがpublicなclass */
typedef struct mint
{
    ll x;
    mint(ll x = 0) : x(x % mod) {} //コンストラクタ
    /* 演算子オーバーロード */
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
} mint_t;

ll intpow(mint_t m, int n)
{
    if (n == 0) return 1;
    mint_t ans(1);
    while (n >= 1)
    {
        if ((n % 2) == 0){
            m *= m.x;
            n /= 2;
        }else {
            ans *= m.x;
            n -= 1;
        }
    }
    return ans.x;
}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
int main()
{
    int x, y;
    cin >> x >> y;

    // choose(n, m)を算出
    if (((x + y) % 3) != 0 || x*2 < y || y*2 < x){
        puts("0");
        return 0;
    }
    int n = (x + y) / 3;
    int m = (x*2 - y) / 3;
    combination c(n);
    cout << c(n, m).x << endl;
}



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

namespace ALDS1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine();
            var values = v.Split(' ').Select(s => int.Parse(s)).ToList();
            InsertionSort(values, values.Count);
        }

        public static void InsertionSort(List<int>targetArray,int arrayLength)
        {
            for(int i = 1; i < arrayLength; i++)
            {
                OutputList(targetArray);
                var v = targetArray[i];
                int j = i - 1;
                while(j >= 0 && targetArray[j] > v)
                {
                    targetArray[j + 1] = targetArray[j];
                    j--;
                }
                targetArray[j + 1] = v;
            }
            OutputList(targetArray);
        }
        public static void OutputList(List<int>targetArray)
        {
            for(int i = 0; i < targetArray.Count; i++)
            {
                if(i == targetArray.Count - 1)
                {
                    Console.WriteLine(targetArray[i]);
                }
                else
                {
                    Console.Write(targetArray[i]);
                    Console.Write(' ');
                }
            }
            return;
        }
    }
}



Measured memory_bytes: 16288
#include<stdio.h>
#define MAX 500000


void buildMaxHeap();
void maxHeapify(int);

int a[MAX],h;
int main(){
  int i;
 

  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }

  buildMaxHeap();

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

  return 0;
}

void maxHeapify(int i){
  int l,r,largest,temp;
  l=2*i;
  r=2*i+1;
  if(l<=h && a[l]>a[i]){
    largest=l;
  }else{
    largest=i;
  }

  if(r<=h && a[r]>a[largest]){
    largest=r;
  }

  if(largest!=i){
    temp=a[i];
    a[i]=a[largest];
    a[largest]=temp;
    maxHeapify(largest);
  }

}


void buildMaxHeap(){
  int i;
  for(i=h/2;i>0;i--)
    maxHeapify(i);
}



Measured memory_bytes: 3636
import java.util.Scanner;
public class Main
{
  public static void main(String[]args)
  {
    Scanner input=new Scanner(System.in);
    int h=0,j=0;
    while(true)
    {int a=input.nextInt();
    int b=input.nextInt();
    if(a==0 && b==0)
      break;
   for(int p=1;p<=a;p++)
     {
       for(int i=1;i<=b;i++)
       {System.out.print("#");}
      System.out.println();}
       System.out.println();
     }
    }
     }


Measured memory_bytes: 34724
#include <stdio.h>

int main(void)
{
    int n = -1,x = -1;
    int p1 = 1, p2 = 2, p3 = 3;
    int cnt = 0;
    
    while (n != 0 || x != 0)
    {
        scanf("%d %d", &n, &x);
        if (n == 0 && x == 0)
            break;
        cnt = 0;
        for (p1 = 1; p1 <= n; p1 ++) {
            for (p2 = p1 + 1; p2 <= n; p2 ++) {
                for (p3 = p2 + 1; p3 <= n; p3 ++) {
                    if (p1 + p2 + p3 == x) {
                        cnt++;
                    }
                }
            }
        }
        printf("%d\n", cnt);
    }
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  string flag="No";
  for(int i=1;i<=9;i++){
   for(int j=1;j<=9;j++){
     if(i*j==N){flag="Yes";break;}
   }
  }
   cout<<flag<<endl;
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=1e5+2;
const LL INF=1e12;
PLL dp[MAX_N];
int main(){
    int N;cin>>N;
    string s;cin>>s;
    if(N>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

signed main(void) {
  int i,j;
  int n;
  cin>>n;
  int m=n*3;
  vi a(m);
  rep(i,m)cin>>a[i];
  vi t(3*n,0);

  priority_queue<int> x,y;
  int sumx=0,sumy=0;
  rep(i,n){
    sumx+=a[i];
    x.push(-a[i]); 
  }
  for(i=2*n;i<m;i++){
    sumy+=a[i];
    y.push(a[i]);
  }
  t[n-1]+=sumx;
  t[2*n-1]-=sumy;
  for(i=n;i<2*n;i++){
    if(abs(x.top())<a[i]){
      sumx+=x.top();
      x.pop();
      sumx+=a[i];
      x.push(-a[i]);
    }
    t[i]+=sumx;
    //    cout<<"A"<<i<<" "<<t[i]<<endl;
  }
  for(i=2*n-1;i>=n;i--){
    if(y.top()>a[i]){
      sumy-=y.top();
      y.pop();
      sumy+=a[i];
      y.push(a[i]);
    }
    // cout<<"B"<<i-1<<" "<<t[i-1]<<endl;
    t[i-1]-=sumy;
  }
  ll ans=-1000000000000000LL;
  for(i=n-1;i<2*n;i++)
    ans=max(ans,t[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 7284
def main(x, y, s):
    ans = []
    for i in range(1, s):
        for k in range(1, s):
            if i + (x * i) // 100 + k + (k * x) // 100 == s:
                ans.append((i, k))
    tmp = 0
    for i, k in ans:
        tmp = max(tmp, i + (y * i) // 100 + k + (k * y) // 100)
    print(tmp)


while 1:
    x, y, s = map(int, input().split())
    if x == y == s == 0:
        break
    main(x, y, s)



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

struct Dinic{
    struct edge{
        int to,cap,rev;
        edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
    };

    const int INF=1001001001;

    vector<vector<edge>>G;
    vector<int>level,iter;

    Dinic(int v):G(v),level(v),iter(v){}

    void addEdge(int from,int to,int cap){
        G[from].push_back(edge(to,cap,G[to].size()));
        G[to].push_back(edge(from,0,G[from].size()-1));
    }

    void bfs(int s){
        fill(level.begin(),level.end(),-1);
        queue<int>que;
        level[s]=0;
        que.push(s);

        while(que.size()){
            int v=que.front();
            que.pop();
            for(auto &e:G[v]){
                if(e.cap==0||level[e.to]!=-1)continue;
                level[e.to]=level[v]+1;
                que.push(e.to);
            }
        }
    }

    int dfs(int v,int t,int f){
        if(v==t)return f;
        for(int &i=iter[v];i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap==0||level[v]+1!=level[e.to])continue;
            int d=dfs(e.to,t,min(f,e.cap));
            if(d==0)continue;
            e.cap-=d;
            G[e.to][e.rev].cap+=d;
            return d;
        }
        return 0;
    }

    int maxFlow(int s,int t){
        int flow=0;
        while(true){
            bfs(s);
            if(level[t]<0)return flow;
            fill(iter.begin(),iter.end(),0);
            int f;
            while((f=dfs(s,t,INF))>0)flow+=f;
        }
    }
};

signed main(){
    int V,E;
    scanf("%lld%lld",&V,&E);

    Dinic di(V);
    rep(i,E){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        di.addEdge(a,b,c);
    }
    cout<<di.maxFlow(0,V-1)<<endl;
    return 0;
}

Measured memory_bytes: 3248
using System;

class Program{
    static void Main(){
        int n = Int32.Parse(Console.ReadLine());
        int h = Int32.Parse(Console.ReadLine());
        int w = Int32.Parse(Console.ReadLine());
        int ret = (n-h+1)*(n-w+1);
        Console.Write("{0}",ret);
    }
}

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

int main() {
  int a, b, c, d, l;
  cin >> l >> a >> b >> c >> d;

  int k = (a + c - 1) / c, s = (b + d - 1) / d;
  cout << l - max(k, s) << endl;
  return 0;
} 

Measured memory_bytes: 1160
X=int(input())
Y=X
Z=X
F=0
while F==0 and (Y>=0 or Z>=0):
	Y-=4
	Z-=7
	if Y%7==0 and (Y>=7 or Y==0):
		F=1
		break
	if Z%4==0 and (Z>=4 or Z==0):
		F=1
		break
if F==1:
	print("Yes")
else:
	print("No")

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename P, typename Q>
istream& operator >> (istream& is, pair<P, Q>& p)
{
  is >> p.first >> p.second;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v)
{
  each (i, v) is >> i;
  return is;
}

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

  int a, b;
  while (cin >> a >> b) {
    const int N = 1000;
    lli c[N];
    c[0] = 0;
    for (int i = 1; i < N; ++i) {
      c[i] = c[i - 1] + i;
    }
    for (int i = 0; i + 1 < N; ++i) {
      if (b - a == c[i + 1] - c[i]) {
        cout << c[i] - a << endl;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int n;
	cin >> n;
	for(int i = 1; i < 10; i++) {
		if(n % i == 0 && n / i < 10) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0543
{
    public class Program

    {
        public static void Main(string[] args)
        {            
            while (true)
            {
                int n = ReadInt();
                if (n == 0) break;

                int sum = 0;
                for (int i = 0 ; i < 9 ; i++)
                {
                    sum += ReadInt();
                }
                Console.WriteLine(n - sum);
            }           
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 13828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll a1=a*c;
  ll a2=b*d;
  ll a3=a*d;
  ll a4=b*c;
  cout<<max(max(a1,a2),max(a3,a4));
  return 0;
}
  

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

int main() {
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  int cnt = 0;
  for(int i=0; i<n-2; i++) {
    for(int j=i+1; j<n-1; j++) {
      for(int k=j+1; k<n; k++) {
        if(v[i]!=v[j] && v[j]!=v[k] && v[k]!=v[i] && abs(v[i]-v[j])<v[k] && v[k]<v[i]+v[j]) cnt++;
      }
    }
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int n,m;
bool red[N];
int num[N];
int main()
{
    scanf("%d%d",&n,&m);
    int x,y;
    for(int i=1;i<=n;i++)
    {
        num[i]=1;
    }
    red[1]=1;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        num[x]--;
        num[y]++;
        if(red[x])
        {
            if(!num[x])
            {
                red[x]=0;
                red[y]=1;
            }
            else
            {
                red[y]=1;
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    if(red[i])
    {
        ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 768
//************************
//*  Date: 30.7.2018     *
//*  Problem: 013B       *
//*  Writer: xuziyuan    * 
//************************

#include <bits/stdc++.h>

using namespace std;

int n,m;
vector <int> apath,bpath,g[100010];
bool vis[100010];

void dfs(int i)
{
	bpath.push_back(i);
	vis[i]=true;
	for(int j=0;j<g[i].size();j++)
	{
		if(!vis[g[i][j]])
		{
			dfs(g[i][j]);
			return;
		}
	}
}

int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(1);
	swap(apath,bpath);
	dfs(1);
	printf("%d\n",apath.size()+bpath.size()-1);
	for(int i=apath.size()-1;i>0;i--) printf("%d ",apath[i]);
	for(int i=0;i<bpath.size();i++) printf("%d ",bpath[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 9720
from collections import Counter

def main():
    n = int(input())
    sn = []
    for _ in range(n):
        sn.append(input())

    sn_counter = Counter(sn)
    ans = sn_counter.most_common()
    max_num = sn_counter.most_common()[0][1]
    
    cut_num = 0
    for it in range(len(ans)):
        if ans[it][1] == max_num:
            cut_num += 1
        else:
            break
    
    ans = ans[:cut_num]
    ans.sort()

    for s in ans:
        print(s[0])

if __name__ == "__main__":
    main()

Measured memory_bytes: 59364
#include<stdio.h>
int main()
{
  int a,b,c,k;
  scanf("%d %d %d %d",&a,&b,&c,&k); 
 if(a>=k)
 {
   printf("%d",k);
   }
   else if((a+b)>=k)
   {
     printf("%d",a);
   }
  else
  {
    printf("%d",a*2-k+b);
  }
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n;
	cin >> n;
	VI b(n - 1);
	REP(i, n - 1)
		cin >> b[i];
	ll ans = b[0] + b[n - 2];
	REP(i, n - 2) {
		ans += min(b[i], b[i + 1]);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        int n;
        scanf("%d", &n);
        string s=to_string(n);
        map<pii, lint> mp;
        For(i, 1, 10)For(j, 1, 10){
                lint cnt=0;
                if(i==j){
                        if(i<=n) ++cnt;
                }
                For(k, 2, 20){
                        if(k>s.size() || (k==s.size() && i>s[0]-'0')) break;
                        if(k==s.size() && s[0]-'0'==i){
                                lint tmp=0;
                                For(l, 1, (int)s.size()-1){
                                        tmp*=10;
                                        tmp+=s[l]-'0';
                                }
                                cnt+=tmp+1;
                                if(s[s.size()-1]-'0'<j) --cnt;
                        }
                        else{
                                lint tmp=1;
                                rep(l, k-2) tmp*=10;
                                cnt+=tmp;
                        }
                }
                mp[{i, j}]=cnt;
        }

        lint ans=0;
        For(i, 1, 10)For(j, 1, 10){
                ans+=mp[{i, j}]*mp[{j, i}];
        }
        printf("%lld\n", ans);
        //for(auto p: mp) printf("(%d %d) %d\n", p.fi.fi, p.fi.se, p.se);
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#pragma GCC optimize(2)

#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstring>

#include <set>
#include <queue>
#include <complex>
#include <algorithm>

int read(void){
	int res = 0, sign = 1;
	char ch = std::getchar();
	while(!std::isdigit(ch)){
		if(ch == '-')
			sign = -1;
		ch = std::getchar();
	}
	while(std::isdigit(ch))
		res = res * 10 + ch - 48, ch = std::getchar();
	return sign * res;
}

template<class Tp>
	void write(const Tp &x){
		if(x > 9)
			write(x / 10);
		std::putchar(x % 10 + 48);
	}

typedef long long ll;
typedef unsigned long long ull;
typedef double rl;
typedef long double RL;

const rl PI = 3.1415926535898, E = 2.71828182845904;

const int MAXN = 18;

ll ans[MAXN];
int dist[MAXN];

int n;
int x[MAXN], y[MAXN], p[MAXN];
int in[MAXN];

int main(){
	n = read();
	for(int i = 1; i <= n; ++i)
		x[i] = read(), y[i] = read(), p[i] = read();
	for(int i = 0; i <= n; ++i)
		ans[i] = 1e18;
	for(int i = 0; i < (1 << n); ++i){
		int cnt = 0;
		for(int j = 1; j <= n; ++j)
			if(i & (1 << (j - 1)))
				in[++cnt] = j;
		for(int j = 0; j < (1 << cnt); ++j){
			for(int p = 1; p <= n; ++p)
				dist[p] = std::min(int(std::abs(x[p])), int(std::abs(y[p])));
			for(int k = 1; k <= cnt; ++k)
				if(j & (1 << (k - 1)))
					for(int p = 1; p <= n; ++p)
						dist[p] = std::min(dist[p], int(std::abs(x[p] - x[in[k]])));
				else
					for(int p = 1; p <= n; ++p)
						dist[p] = std::min(dist[p], int(std::abs(y[p] - y[in[k]])));
			ll s = 0ll;
			for(int j = 1; j <= n; ++j)
				s += (ll)dist[j] * p[j];
			ans[cnt] = std::min(ans[cnt], s);
		}
	}
	for(int i = 0; i <= n; ++i)
		std::printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 1580
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d,x;
  double da,db;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  cin >> a >> b >> c;
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  int result3 = std::max({a, b, c});
//--------------------------------------------------------------------------------

//  if(a>=13) ans = b;
//  else ans = 0;

  cout << a+b+c-result3 << endl;

}

Measured memory_bytes: 256
def solve():
    tmp = 0
    a_sum = [0]
    for a in A:
        tmp += a
        a_sum.append(tmp)

    tmp = 0
    b_sum = [0]
    for b in B:
        tmp += b
        b_sum.append(tmp)

    b_idx = 0
    a_idx = N
    ret = 0
    while 0 <= a_idx:
        if K < a_sum[a_idx]:
            a_idx -= 1
            continue
        while b_idx < M and a_sum[a_idx] + b_sum[b_idx + 1] <= K:
            b_idx += 1
        ret = max(ret, a_idx + b_idx)
        a_idx -= 1
    print(ret)

if __name__ == "__main__":
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    solve()


Measured memory_bytes: 47536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();

		/*if((a+b)%3==0 || a%3==0 || b%3==0) {
			System.out.println("Possible");
		}else {
			System.out.println("Impossible");
		}*/
		System.out.println((n-1)*(m-1));
	}
}




Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  int A=0;
  vector<int> V(N), C(N), d(N);
    
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> V.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> C.at(i);
  }
  
  for(int i=0;i<N;i++){
   d.at(i) = V.at(i) - C.at(i); 
  }
  
  for(int i=0;i<N;i++){
    
    if(d.at(i)>0){
      A += d.at(i);
      }
    
  }
   
  cout << A <<endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

const int MAX = 100010;
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
   fac[0] = fac[1] = 1;
   finv[0] = finv[1] = 1;
   inv[1] = 1;
   for (int i = 2; i < MAX; i++){
       fac[i] = fac[i - 1] * i % mod;
       inv[i] = mod - inv[mod%i] * (mod / i) % mod;
       finv[i] = finv[i - 1] * inv[i] % mod;
   }
}
 
long long COM(int n, int k){
   if (n < k) return 0;
   if (n < 0 || k < 0) return 0;
   return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main ()
{
  prep();
  int n;
  cin >> n;
  COMinit();
  int arr[n+1];
  int same[n+1] = {0};
  int num = 0;
  for (int i=0; i<n+1; i++){
      cin >> arr[i];
      same[arr[i]]++;
      if (same[arr[i]] == 2){
          num = arr[i];
      }
  }
  int distbefore = 0;
  int distafter = 0;
  bool did = false;
  for (int i=0; i<n+1; i++){
      if (arr[i] == num && !did){
          did = true;
          distbefore = i;
      }else if (arr[i] == num){
          distafter = n-i;
          break;
      }
  }
  
  for (int i=1; i<=n+1; i++){
      
      cout << mymod(COM(n+1, i)-COM(distbefore+distafter, i-1)) << '\n';
  }
  return 0; 
}

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

int main()
{
  ll n; cin >> n;
  vector<ll> d(n, 0);
  for (int i=0; i<n-1; i++){
    ll a; cin >> a; a--;
    d[a]++;
  }
  for (auto v:d) cout << v << endl;

  return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <string.h>

using namespace std;

int main(){
	int N;
	int K;
	int L[55];

	cin >> N >> K;
	for (int i = 0; i < N; ++i)
		cin >> L[i];

	sort(L, L + N);
	int l = 0;
	for (int i = 0; i < K; ++i)
		l += L[N - 1 - i];
	cout << l << endl;

	return 0;
}


Measured memory_bytes: 256
import bisect

n= int(input())
l = list(map(int,input().split()))
ans = 0
L = sorted(l)

for i in range(n-2): # max
    for j in range(i+1, n-1): # second max
        index = bisect.bisect_left(L[j+1:], L[i]+L[j])
        ans += index
    
print(ans)

Measured memory_bytes: 51668
($H, $W) = split(/[ \n]+/, <>);

$num_o = ($H < 2) ? 1 : int($W/2 + 0.5);
$num_e = int($W/2);

$row_o = int($H/2 + 0.5);
$row_e = int($H/2);

printf "%d\n", (($H < 2) || ($W < 2)) ? 1 : $row_o * $num_o + $row_e * $num_e;


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

long long int gcd(long long int a, long long int b) {
  if (b==0)
    return a;
  return gcd(b, a%b);
}

unsigned long long int lcm(long long int a, long long int b) {
  return a*b/gcd(a, b);
}

int main(){
  long long int a, b;
  int c, d;
  unsigned long long int e;
  long long int c1=0, c2=0, c3=0, c4;
  long long int d1=0, d2=0, d3=0, d4;
  cin >> a >> b >> c >> d;
  long long int sum=b-a+1;
  e=lcm(c, d);
  
  c1=b/c;
  c2=b/d;
  c3=b/e;
  c4=b-(c1+c2-c3);
 
  d1=(a-1)/c;
  d2=(a-1)/d;
  d3=(a-1)/e;
  d4=(a-1)-(d1+d2-d3);  
  
  cout <<c4-d4<< endl;
}

Measured memory_bytes: 256
(lambda ft: print(ft.reduce(lambda p, c: (p[0] < 0 or (lambda t, d: (d > t or d % 2 != t % 2))(c[0] - p[0], abs(c[1] - p[1]) + abs(c[2] - p[2]))) and [-1, -1, -1] or c, [list(map(int, input().split())) for _ in range(int(input()))], [0, 0, 0])[0] < 0 and "No" or "Yes"))(__import__("functools"))

Measured memory_bytes: 27860
import Control.Monad
import Data.List

f ps = sum $ zipWith (\[x, y] [xx, yy] -> (sqrt $ (xx-x)**2 + (yy-y)**2)) ps $ tail ps

solve :: Int -> [[Double]] -> Double
solve n ps = flip (/) (fromIntegral $ product [1..n]) $ sum $ map f $ permutations ps

main = do
    n <- readLn
    ps <- replicateM n (map read . words <$> getLine)
    print $ solve n ps

Measured memory_bytes: 1916
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> W(N);
    int S1 = 0, S2 = 0;
    REP(i, N) {
        cin >> W[i];
        S2 += W[i];
    }
    int res = S2;
    REP(i, N) {
        S1 += W[i];
        S2 -= W[i];
        amin(res, abs(S1 - S2));
    }
    cout << res << endl;
    return 0;
}


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


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

	ll t=1;	//cin>>t;
	while(t--){
		ll n; cin>>n;ll sum=0,p;
		vector<int> a(n), c(n-1);
		for(int i=0; i<n; i++)cin>>a[i];
		for(int i=0; i<n; i++){
			cin>>p;
			sum+=p;
		}
		//cout<<sum;
		for(int i=0; i<n-1; i++)cin>>c[i];
		for(int i=0; i<n-1; i++){
			if(a[i+1]-a[i]==1)sum+=c[a[i]-1];
		}
		cout<<sum;
	}

	
 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
#define ll long long

using namespace std;


#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

const ll inf =1000000007;
typedef pair<ll,ll> Pair;


typedef vector<ll> vl;

void asolve(){
    rep(i,5){
        ll a;
        cin >>a;
        if(a==0){
            kaku(i+1);
        }
    }

}

void bsolve(){
    ll x,y;
    cin >> x >>y;
    if(y%2==0 && y<=4*x && y>=2*x){
        cout <<"Yes"<< endl;
    }
    else {
        cout <<"No" << endl;
    }

}

void csolve(){
    ll x,n;
    cin >> x >>n;
    map<ll,ll> mp;
    rep(i,n){
        ll a;
        cin >>a;
        mp[a]=1;
    }
    ll c=1;//minus
    ll t=0;
    for(ll i=x;i<10000;t++){
        if(mp.find(i)==mp.end()){
            kaku(i);
            break;
        }
        else{
            if(c==-1) {
                c=1;
                ll u=x-i;
                i=x+u;
            }
            else {
                c=-1;
                ll u=i-x;
                i=x-u-1;
            }

        }
    }
}

void dsolve(){

}

int main(){
    csolve();
}

Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))

import fractions

L = [A[0]]
R = [A[-1]]

for i in range(1, N):
    L.append(fractions.gcd(L[i-1], A[i]))
    R.append(fractions.gcd(R[i-1], A[-(i+1)]))

R.reverse()


ans = 0

for i in range(N):
    if i == 0:
        ans = max(ans, R[1])
    elif i == N-1:
        ans = max(ans, L[-2])
    else:
        ans = max(ans, fractions.gcd(L[i-1], R[i+1]))
    
print(ans)

Measured memory_bytes: 14488
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INf=1001001001;

int main(){
  int a,b;cin>>a>>b;
  if(a>b){
    rep(i,a){
      cout<<b;
    }
  }
  else{
    rep(i,b){
      cout<<a;
    }
  }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, c, d;
	ll k;
	//string s, t;
	ll l_ans = 0;
	string s_ans = "NG";

	cin >> a >> b;

	l_ans = (a + b) % 24;

	cout << l_ans << "\n";

	return;
}


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

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3608
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
bool compare(const pair<int , int>&a , const pair<int,int>&b){
	return a.fi<b.fi ; 
}
void solve()
{
	int mat[3][3] ; 
	bool vis[3][3] ;
	rep(i , 3){
		rep(j , 3){
			cin>>mat[i][j] ;
			vis[i][j] = false ;
		}
	}
	int n ;
	cin>>n ;
	rep(i , n){
		int b ; 
		cin>>b ; 
		rep(j ,3){
			rep(k ,3){
				if(mat[j][k] == b){
					vis[j][k] = true ;
				}
			}
		}
	}
	bool bingo = false ;
	int dc0 = 0 , dc1 = 0 ;
	rep(i , 3){
		int oc = 0 , oc1 = 0;
		rep(j , 3){
			if(vis[i][j]){
				oc++;
			}
			if(vis[j][i]){
				oc1++;
			}
		}
		if(oc==3 || oc1 == 3){
			bingo = true ;
		}
		if(vis[i][i]){
			dc0++;
		}
		if(vis[i][2-i]){
			dc1++;
		}
	}
	if(dc1==3 || dc0 == 3){
		bingo  = true ;
	}
	if(bingo){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}

}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int D;
    int[] X;
    int [] Y;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.D = sc.nextInt();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        this.X =new int[N];
        this.Y = new int[N];
        
        for (int i=0; i<N; i++) {
        	X[i] = sc.nextInt();
        	Y[i] = sc.nextInt();
        	double p = Math.pow(X[i], 2);
        	double q = Math.pow(Y[i], 2);
        	double distance = Math.sqrt(p + q);
        	if (distance <= D) {
        		count++;
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 61240
S = input()
if S[0] == 'A' and S[2:-1].count('C') == 1:
    i = S.index('C')
    jj = S[1:i]+S[i+1:]
    if jj.islower() == True:
        print('AC')
    else:
        print('WA')
else:
    print('WA')

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    int p = b / a;
    int ans = 0;
    while(b >= a){
        ans ++;
        b -= a;
        if(ans == c)
            break;
    }
    printf("%d\n",ans);
    return 0;
}

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

typedef long long ll;

int main(){	
	long long C;
	long long N;
	scanf("%lld",&N);
	vector<long long> t(N-1+1);
	vector<long long> c(N-1+1);
	vector<long long> s(N-1+1);
	scanf("%lld",&C);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&s[i]);
		scanf("%lld",&t[i]);
		scanf("%lld",&c[i]);
	}

	vector< pair<ll, ll> > v(N);
	for (int i = 0; i < N; i++) {
		v[i].first = s[i];
		v[i].second = t[i]; 
	}
	sort(v.begin(), v.end());

	vector<ll> a(C);
	for (int i = 0; i < C; i++) {
		a[i] = 0;
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < C; j++) {
			if (a[j] < v[i].first) {
				a[j] = v[i].second;
				break;
			}
		}
	}

	ll res = 0;
	for (int i = 0; i < C; i++) {
		if (a[i] != 0) res++;
	}

	cout << res << endl;

	return 0;
}



Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,b,i;
  list<int>a;
  cin>>n;
  string s;
  list<int>::iterator it;
  while(n--){
    cin>>s;
    if(s.size()<=6){
      cin>>b;
      if(s[0]=='i')a.push_front(b);
      else{
        it=a.begin();
        while(it!=a.end()){
          if(*it==b){a.erase(it);break;}
          it++;
        }
      }
    }
    else{
      if(s[6]=='F')a.pop_front();
      else a.pop_back();
    }
  }
  it=a.begin();
  for(i=0;it!=a.end();it++,i++){
    if(i)cout<<' ';
    cout<<(*it);
  }
  cout<<endl;
}



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


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

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

    int sum = 0;
    int sum2;
    int ans = 100000000; //最小値を取りたいので最初は大きい値で始める
    
    //sumの右端がiまで
    for(int i = 0; i < n; i++){
        //左側の和に加える
        sum += a[i];

        sum2 = 0; //左の和が変わるたびに初期化

        //左側の和を求める
        //左側の和(sum)の右端がiまでなので、その一つ先から数え始める
        for(int j = i+1; j < n; j++){
            sum2+=a[j];
        }
        
        //毎回ansと大小を比較する
        //abs(a-b)は(a-b)の絶対値
        ans = min(ans, abs(sum2-sum));
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int x = sc.nextInt();

    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      int j = 0;
      while (((j * a) + 1) <= d) {
        x++;
        j++;
      }
    }

    System.out.println(x);

  }
}

Measured memory_bytes: 35780
def resolve():
	s=input()
	if s.count('A')!=1 or s.count('C')!=1 or s[0]!='A':
		print('WA')
	elif 'C' not in s or s.index('C')<2 or s[-1]=='C':
		print('WA')
	elif s.replace('A','').replace('C','')!=(s.replace('A','').replace('C','')).lower():
		print('WA')
	else:
		print('AC')
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;

int main(){
	string s;
  	cin >> s;
  	int n = s.size();
  	rep(i,(n-1)/2){
      if(s[i]!=s[n-i-1]){
		cout << "No" << endl;
        return 0;
      }
    }
  	rep(i,((n-1)/2-1)/2){
		if(s[i]!=s[(n-1)/2-1-i]){
			cout << "No" << endl;
          	return 0;
        }
    }
  	for(int i =(n+3)/2-1;i<(n+(n+3)/2)/2-1;i++){
		if(s[i]!=s[n+(n+3)/2-i-2]){
			cout << "No" << endl;
          	return 0;
        }
    }
  	cout << "Yes" << endl;
}
      


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool cmp(const pair<pair<string, int>, int> &a, const pair<pair<string, int>, int> &b){
	if(a.first.first<b.first.first){
		return true;
	}
	else if(a.first.first>b.first.first){
		return false;
	}
	return a.first.second>b.first.second;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n;
	pair<pair<string, int>, int> p[114];
	cin>>n;
	REP(i, n){
		cin>>p[i].first.first>>p[i].first.second;
		p[i].second=i;
	}
	sort(p, p+n, cmp);
	REP(i, n){
		cout<<p[i].second+1<<'\n';
	}
	return 0;
}


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

int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++){
        int a; cin >> a;
        if(a%2==0 && a%3!=0 && a%5!=0){
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


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

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

    int n;
    cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }
    long long int answer = 0;
    for (auto &p : mp) {
        int s = p.second;
        answer += (long long int)s * (s - 1) / 2;
    }
    cout << answer << endl;
}

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

const int f = 1e5+7;
int a[f];
int main(){
	long long n,x;
	long long ans = 0;
	
	cin >> n >> x;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 0;i < n-1;i++){
		if(a[i]+a[i+1]>x){
			ans+=(a[i]+a[i+1]-x);
			if(a[i]<=x) a[i+1] = x-a[i];
			else a[i+1] = 0;
		}
	}
	cout << ans;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  char vowel[5]={'a','e','i','o','u'};
  char c[1];
  cin>>c[0];
  bool found=false;
  rep(i,5){
    if(c[0]==vowel[i]){found=true;}
  }
  cout<<(found?"vowel":"consonant")<<endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<deque<ll>> items(N);
    rep(i, N) {
        rep(j, N - 1) {
            int a;
            scanf("%d", &a);
            items[i].push_back(a);
        }
    }

    ll ans = 0;

    while (true) {
        vector<bool> visited(N+1, false);
        bool flag = false;
        bool all_done = true;
        rep(j, N) {
            if (visited[j+1]) {
                continue;
            }
            if (!items[j].empty()) {
                ll t = items[j].front();
                if (!visited[t] && !items[t - 1].empty() && j + 1 == items[t - 1].front()) {
                    visited[j+1] = true;
                    visited[t] = true;
                    items[j].pop_front();
                    items[t - 1].pop_front();
                    flag = true;
                }
            }
            if (!items[j].empty()){
                all_done = false;
            }
        }
        if (flag) {
            ans++;
        }else{
            cout << -1 << endl;
            return;
        }
        if (all_done) {
            cout << ans << endl;
            break;
        }
        if (ans > 1e4/2){
            cout << N*(N-1)/2 << endl;
            return;
        }

    }

}

int main() {
    Main();
}


Measured memory_bytes: 8960
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    for i in range(n-1):
        a[i+1] += a[i]
    for i in reversed(range(n-1)):
        b[i] += b[i+1]
    ans = 0
    for i in range(n):
        ans = max(ans, a[i]+b[i])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
int main()
{
    int K;
    int ans;

    scanf("%d",&K);

    if(K%2 == 0){
        ans = (K / 2)*(K / 2);
    }else{
        ans = ((K + 1)/2)*((K + 1)/2 - 1);
    }

    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128