akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    string s; cin>>s;
    vector<int> l(n,0),r(n,0);
    rep(i,n-1){
        l[i+1]=l[i];
        if(s[i]=='W') l[i+1]++;
        r[n-i-2]=r[n-i-1];
        if(s[n-i-1]=='E') r[n-i-2]++;
    }
    int ans=inf;
    rep(i,n) ans=min(ans,l[i]+r[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

#define MAX_N 1000000000

unsigned long long int GCD(unsigned long long int a,unsigned long long int b){
	if( a < b){
		return GCD(b,a);
	}
	if( b == 0) return a;
	if( b == 1) return 1;
	return GCD(b,a%b);
}

int main()
{
	int N;
	unsigned long long int a,g;
	cin>>N;
	cin>>a;
	for(int i = 1; i < N; i++){
		unsigned long long int b;
		cin>>b;
		a = GCD(a,b);
	}
	cout<<a<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<vector<ll>> matrix;

string g[305];
char ret[305][305];

void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> g[i];
  int ans = 0;
  for(int plus = 0; plus < n; plus++) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        ret[i][(j+plus)%n] = g[i][j];
      }
    }
    bool good = true;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < i; j++) {
        if(ret[i][j] != ret[j][i]) {
          good = false;
        }
      }
    }
    if(good) ans += n;
  }
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
}


Measured memory_bytes: 512
#include<iostream>
#include<cassert>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int N,Y,x,y,z;
	cin>>N>>Y;
	for(x=0;x<=Y/10000;x++)
{
	for(y=0;y<=Y/5000;y++)
	{
		int k=N-x-y;
		if(k>=0&&x*10000+y*5000+k*1000==Y)
		{
			cout<<x<<' '<<y<<' '<<k;
            return 0;
	    }
	}
}
	cout<<"-1 -1 -1";
	return 0;
}

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()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=min((a), (b))

const int MOD=1000000007;
#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)

int POW(int a, int b){
	int ans=1;
	REP(i, b){
		ans*=a;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin>>x;
	int ans=1;
	FOR(i, 1, x){
		FOR(j, 2, x){
			if(pow(i, j)>x) break;
			ans=max(ans, POW(i, j));
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;
long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

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

void getrunrun(long long a, vector<long long>& vec) {

	if ((int)log10((long long)a) + 1 >=11) {
		return;
	}
	vec.push_back(a);

	if (a % 10 > 0 ) {
		getrunrun((10 * a + (a % 10 - 1)), vec);
	}
	getrunrun((10 * a) + a % 10, vec);

	if (a % 10 < 9) {
		getrunrun((10 * a + (a % 10 + 1)), vec);
	}
}



int main(void) {

	long long a;

	vector<long long> vec;

	cin >> a;

	for (int i = 1; i <= 9; i++) {
		getrunrun(i, vec);
	}

	std::sort(vec.begin(),vec.end());

	cout << vec[a - 1];

}




Measured memory_bytes: 2804
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=0,S[100];


void push(int);
int pop(void);
int isempty(void);
int isfull(void);


int main(){

  int a,b,x;
  char s[100];

  while(scanf("%s",s)!=EOF){


    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      x=atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[top]);
  return 0;
}










void push(int x){
  if(isfull()==1)
    S[++top]=x;
}






int pop(){
  if(isempty()==1)
    {
    top--;
  
  return S[top+1];
    }
}






int isempty(){
  if(top==0)return 0;
  else return 1;
}



int isfull(){
  if(top>100-1)return 0;
  return 1;
}

Measured memory_bytes: 548
def f(N,S):
    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    ret_s = ""
    for s in S:
        num = (alpha.index(str(s)) + int(N))
        if num <= 25:
            pass
        else:
            num = num-(num//26)*26
        ret_s += alpha[num]
    return print(ret_s)
  
a = input()#13#
b = input()#"ABCDEFGHIJKLMNOPQRSTUVWXYZ"#
 
f(a,b)

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

int main(){
    int N;
    cin >> N;
    N %= 10;
    if(N == 3) cout << "bon" << endl;
    else if(N == 1||N == 6|| N == 8|| N == 0) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <unordered_map>
#include <bitset>

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

const ll mod=1000000007ll;

const ll hmax=100;
const ll wmax=8;
ll dp[wmax+2][hmax+1];

const ll F[wmax+2]={0,1,1,2,3,5,8,13,21,34};

int main(){
    ll h,w,k;
    cin>>h>>w>>k;
    dp[1][0]=1;

    for(ll j=1;j<=h;j++){
        for(ll i=1;i<=w;i++){
            dp[i][j]=((F[i-1]*F[w-i+1]*dp[i-1][j-1])%mod+(F[i]*F[w-i]*dp[i+1][j-1])%mod+(F[i]*F[w-i+1]*dp[i][j-1])%mod)%mod;
        }
    }
    //for(ll i=1;i<=w;i++){
    //    for(ll j=0;j<=h;j++){
    //        cout<<"("<<i<<","<<j<<")"<<dp[i][j]<<" ";
    //    }
    //    cout<<endl;
    //}
    ll i=1;ll j=2;
    cout<<dp[k][h]<<endl;
    return 0;
}


Measured memory_bytes: 256
// 'By Anki'
 
#include<bits/stdc++.h>
// #include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000007LL
typedef unsigned long long ull;
#define M 10004
using u64= uint64_t;

ll mod(ll n){
  if(n<0)return n+lim;
  else return n%lim;
}


int main()
{
fast
ll t=1LL;
// cin>>t;
while(t--)
{
   ll n,k,arr[200005];
            cin>>n>>k;
        for(int i=0;i<n;i++)cin>>arr[i];
            sort(arr,arr+n);

            ll start = 0,end = n-1,ans = 1,val = 0;
            if(arr[n-1]<0&&k%2)
            {
                for(int i=0;i<k;i++)
                {
                    ans = (ans*arr[n-1-i])%lim;
                }
            }
            else
            {
                while(k)
                {
                    if(k>1)
                    {
                        if(arr[start]*arr[start+1]>arr[end]*arr[end-1])
                        {
                            ans = (((arr[start]*arr[start+1])%lim)*ans)%lim;
                            start+=2;
                            k-=2;
                        }
                        else
                        {
                            ans = (ans*arr[end])%lim;
                            end--;
                            k--;
                        }
                    }
                    else
                    {
                        ans = (ans*arr[end])%lim;
                        end--;
                        k--;
                    }
                }
            }
            ans = (ans+lim)%lim;
            cout<<ans;

}
} 

Measured memory_bytes: 5196
while True:
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':    
        print(a * b)
    elif op == '/':
        print(a // b)
    elif op == '?':
        break



Measured memory_bytes: 5596
n, k = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
MOD = 10**9 + 7
A.sort()

l = 0
r = n - 1
sign = 1  # 1 or -1
ans = 1
if k % 2 == 1:
    ans = A[r]
    r -= 1
    k -= 1
    if ans < 0:
        sign = -1

while k:
    x = A[l] * A[l + 1]
    y = A[r] * A[r - 1]
    if x * sign > y * sign:
        ans *= x % MOD
        ans %= MOD
        l += 2
    else:
        ans *= y % MOD
        ans %= MOD
        r -= 2
    k -= 2

print(ans)

Measured memory_bytes: 94360
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
bool sel[MAXN];
int main() {
	int n; read(n);
	if (n == 3) {
		puts("2 5 63");
		return 0;
	}
	int base = 0;
	while (n >= 8) {
		n -= 8;
		printf("%d %d %d %d %d %d %d %d ", base + 2, base + 3, base + 4, base + 6, base + 8, base + 9, base + 10, base + 12);
		base += 12;
	}
	if (n == 1) printf("%d\n", base + 6);
	else if (n == 2) printf("%d %d\n", base + 2, base + 4);
	else if (n == 3) printf("%d %d %d\n", base + 2, base + 4, base + 6);
	else if (n == 4) printf("%d %d %d %d\n", base + 2, base + 3, base + 4, base + 9);
	else if (n == 5) printf("%d %d %d %d %d\n", base + 2, base + 3, base + 4, base + 6, base + 9);
	else if (n == 6) printf("%d %d %d %d %d %d\n", base + 2, base + 3, base + 4, base + 6, base + 9, base + 12);
	else if (n == 7) printf("%d %d %d %d %d %d %d\n", base + 2, base + 3, base + 4, base + 6, base + 8, base + 9, base + 10);
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &v : A) cin >> v;
  sort(A.begin(), A.end());

  for (int i = 0; i < N - 1; ++i) {
    if (A[i] == A[i + 1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

int partition(int*, int, int);

int main() {
  int i, n, key;
  int *a;
  
  scanf("%d",&n);
  a = (int*)malloc(sizeof(int) * n);
  for(i = 0;i < n;i++) 
    scanf("%d",&a[i]);
  key = partition(a, 0, n);
  for(i = 0;i < n;i++) {
    if(i == key) printf("[%d]",a[i]);
    else printf("%d",a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n");
  free(a);
  return 0;
}

int partition(int* a, int p, int r) {
  int j, change;
  int x = a[r-1];
  int i = -1;
  for(j = p;j < r-1;j++) {
    if(a[j] <= x) {
      i++;
      change = a[i];
      a[i] = a[j];
      a[j] = change;
    }
  }
  change = a[i+1];
  a[i+1] = a[r-1];
  a[r-1] = change;
  return i+1;
}

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

const int INF = 1<<20;

int GM[100][100];
int GT[100][100];

int main() {
  
  int n, m, a, b, c, t;
  int K, p, q, r;
  
  while(cin >> n >> m, n+m) {
    fill(GM[0], GM[100], INF);
    fill(GT[0], GT[100], INF);
    for(int i=0; i<m; i++) {
      GM[i][i] = 0;
      GT[i][i] = 0;
    }
    for(int i=0; i<n; i++) {
      cin >> a >> b >> c >> t; a--, b--;
      GM[a][b] = c, GM[b][a] = c;
      GT[a][b] = t, GT[b][a] = t;
    }
    
    for(int k=0; k<m; k++)
      for(int i=0; i<m; i++)
	for(int j=0; j<m; j++) {
	  GM[i][j] = min(GM[i][j], GM[i][k] + GM[k][j]);
	  GT[i][j] = min(GT[i][j], GT[i][k] + GT[k][j]);
	}
    
    cin >> K;
    for(int i=0; i<K; i++) {
      cin >> p >> q >> r; p--, q--;
      if(r) {
	cout << GT[p][q] << endl;
      } else {
	cout << GM[p][q] << endl;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 1236
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<int> lstInp = new List<int>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++)
            {
                lstInp.Add(int.Parse(sS[i]));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstInp.Sort();
            int iMin = lstInp[0];
            int iMax = lstInp[lstInp.Count -1];
            List<int> lstRet = new List<int>();
            for (int i = iMin; i <= iMax; i++)
            {
                int iSum = 0;
                for (int j = 0; j < lstInp.Count; j++)
                {
                    iSum += (int)Math.Pow((double)(lstInp[j] - i), 2D);
                }
                lstRet.Add(iSum);
            }
            lstRet.Sort();

            // 出力
            System.Console.WriteLine("{0}", lstRet[0].ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline

h, n = map(int, input().split())
A = []
B = []
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

Ama = max(A)

dp=[float("inf")]*(h+Ama+1)
dp[0]=0

for i in range(n):
    for j in range(A[i],h+Ama+1):
        dp[j]=min(dp[j],dp[j-A[i]]+B[i])

print(min(dp[h:]))

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

#define mod 2019

//long int min(long int a,long int b)
long int solve(long int l,long int r){
    
    vector<long int>m;
  
    
    long int ans = INT_MAX;
    for(long int i = l;i<=min(l+2019,r);i++){
        for(long int j = i+1;j<=min(l+2019,r); j++)
            ans = min(ans,(i*j)%mod);
        
    }
    return ans;
}

int main(){
  
    long int l,r;
    cin>>l>>r;
    cout<<solve(l,r);    
    
 return 0;  
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	long ans;
	String[] S;

	Main(){
		// 整数の入力
		n = sc.nextInt();
		S = new String[n];

		// 文字列の入力
		for(int i=0;i<n;i++){
			String s = sc.next();
			String[] ss = s.split("");
			Arrays.sort(ss);
			S[i]=ss[0];
			for(int j=1;j<10;j++){
				S[i] += ss[j];
			}
		}

		Arrays.sort(S);

		String str = S[0];
		long cnt = 1;
		for(int i=1;i<n;i++){
			if(!str.equals(S[i])){
				ans+=comv(cnt);
				cnt=0;
				str = S[i];
			}
			cnt++;
		}

		ans+=comv(cnt);

		// 出力
		System.out.println(ans);		
	}

	private long comv(long x){
		if(x==1)return 0;
		else return x*(x-1)/2;
	}

	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 99220
#include<bits/stdc++.h>
using namespace std;
vector<int> g[100005];
int dp[100005], vis[100005], mx;

void dfs(int node)
{
    vis[node] = 1;
    for (int a: g[node]){
        if (!vis[a]) dfs(a);
        dp[node] = max(dp[a] + 1, dp[node]);
    }
    mx = max(mx, dp[node]);    
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    while (m--){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
    }
    for (int i = 1; i <= n; i++){
        if (!vis[i]) dfs(i);
    }
    cout << mx << endl;
}

Measured memory_bytes: 12576
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int maxn = 1e5 + 5;
int ans[maxn];
int vis[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m, n;
	cin >> k;
	deque<pii>q;
	q.push_back(mp(1, 1));
	ans[1] = 1;
	while (!q.empty())
	{
		pii t = q.front(); q.pop_front();
		if (t.first == 0)
		{
			cout << t.second << endl;
			return 0;
		}
		if (vis[t.first])continue;
		vis[t.first] = 1;
		q.push_front(mp((t.first * 10) % k, t.second));
		q.push_back(mp((t.first + 1) % k, t.second+1));
	}
	return 0;
}



Measured memory_bytes: 1408
N, A, B, C = map(int, input().split())
mod = 10 ** 9 + 7

W = [1] * (2 * N + 1)
for w in range(2 * N):
    W[w + 1] = ((w + 1) * W[w]) % mod


def rev(a):
    return pow(a, mod - 2, mod)


def comb(a, b):
    return (W[a] * rev(W[b]) * rev(W[a - b])) % mod


def f(a, b):
    res = 0
    for i in range(N):
        res += ((i + N) * com[i] * pow(b, i, mod)) % mod
        res %= mod
    return (pow(a, N, mod) * res) % mod


a = A * rev(A + B)
b = B * rev(A + B)
c = C * rev(100)
com = [comb(i + N - 1, i) for i in range(N)]

w_a = f(a, b)
w_b = f(b, a)
ans = ((w_a + w_b) * rev(1 - c)) % mod
print(ans)


Measured memory_bytes: 14952
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N ;
    int r,l;
    
    long long int ans = 0;

    for(int i = 0; i < N ; i++){
        cin >> r >> l;
        ans += l - r + 1;
    }
    if(ans>100000){
       cout << 100000 << endl;
    }else{
       cout << ans << endl;
    }

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<pair<pair<string,int>,int>> A(N);
	for (int i = 0; i < N; i++)
	{
		cin >> A[i].first.first;
		int tmp;
		cin >> tmp;
		A[i].first.second = 100 - tmp;
		A[i].second = i + 1;
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; i++)
	{
		cout << A[i].second << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
  int N,A,B,C,D;
  cin >> N >> A >> B >> C >> D ;
  int x,y;
  if(N%A==0){
    x=N/A*B;    
  }else{
    x=((N/A)+1)*B;    
  }
  if(N%C==0){
    y=(N/C)*D;
    
  }else{
    y=((N/C)+1)*D;
  }
   if(x<y){
     cout << x << endl;
   }
   else{
    cout << y << endl;   }
   
   
}



Measured memory_bytes: 3120
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
inline bool 
operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
vector<int> 
string_to_vector_int(const string& input){vector<int> out(input.length());rep(i,input.length()){out[i] = (int)(input[i]-'0');} return out;}
template<class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(cmap.begin(),cmap.end(),[&cmap](T x){cmap[x]++;}); return cmap; }
map<int,int> 
count_same_elements(const vector<int>& v){map<int,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }

template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
tryple_map(const vector<A>& v,const function<B(A,A,A)>& func){vector<B> v_(v.size()-2);rep(i,v.size()-2){ v_[i]=func(v[i+2],v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const B& (*func)(A)){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,B (*func)(A,A)){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A,class B> vector<B> 
tryple_map(const vector<A>& v,B (*func)(A,A,A)){vector<B> v_(v.size()-2);rep(i,v.size()-2){ v_[i]=func(v[i+2],v[i+1],v[i]); }return v_;}

int twosame(int a,int b){return a==b;}
int tryple_same(int a,int b,int c){return a==b and b==c;}
int integer_sumnation(int a,int b){return a+b;}

ll n,k,a,b,c,d,x;
vector<ll>v;
string s;
void input(){
    cin>>s;
}
void src(){
    auto ss=string_to_vector_int(s);
    auto m=count_same_elements(ss);
    cout<<m[1];
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

int n, a[200200], now, j;
long long ans;

int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",a+i);
	j = 1;
	for (int i=1;i<=n;i++) {
		while (j < i && (now & a[i]) > 0) now ^= a[j++];
		now |= a[i];
		ans += (i-j+1);
	}
	printf("%lld\n",ans);
}

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

int main() {
  int n;
  cin >> n;
  vector<int> la(n);
  int upper = 0;
  int lower = n;
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
    upper = max(upper, la[i]);
    lower = min(lower, la[i]);
  }
  if (upper-lower > 1) {
    cout << "No" << endl;
    return 0;
  }
  if (upper == lower) {
    if (upper*2 <= n) {
      cout << "Yes" << endl;
    }
    else if (upper+1 == n) {
      // 全部違う色の時
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
    return 0;
  }
  int c = upper;
  int m = n;
  for (int a: la) {
    if (a == lower) { 
      --c;
      --m;
    }
  }
  if (c <= 0 || c*2 > m) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
 
int n[100010];
int main()
{
  int N;
  scanf("%d",&N);
  int temp;
 
  for(int x=1;x<105;x++){
    for(int y=1;y<105;y++){
      for(int z=1;z<105;z++){
        temp = x*x + y*y + z*z + x*y + y*z + z*x;
        n[temp]++;
      }
    }
  }
  
  for(int i=1;i<=N;i++){printf("%d\n",n[i]);}
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a[10000000],b,c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
           if(a[i]%2!=0){
              Cout(0);
              return 0;
           }
       }
       while(1){
          rep(i,n){
              a[i]/=2;
              if(a[i]%2!=0){
                  Cout(cnt+1);
                  return 0;
              }
          } 
          cnt++;
       }
return 0;
}


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

int main()
{
	int a, b, aok = 0, bok = 0;
	char tmp[5];

	scanf("%s", &tmp);
	
	a = (tmp[0] - '0') * 10 + tmp[1] - '0';
	b = (tmp[2] - '0') * 10 + tmp[3] - '0';

	if (a >= 1 && a <= 12)
		aok = 1;
	if (b >= 1 && b <= 12)
		bok = 1;

	if (aok && bok)
		printf("AMBIGUOUS\n");
	else if (aok)
		printf("MMYY\n");
	else if (bok)
		printf("YYMM\n");
	else
		printf("NA\n");

	return 0;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<ll> v(n+1);
    for(auto&& i : v) cin >> i;

    if(v[0] != 0 && n > 0){
        cout << -1 << endl;
        return 0;
    }

    if(n == 0){
        if(v[0] != 1){
            cout << -1 << endl;
            return 0;
        }else{
            cout << 1 << endl;
            return 0;
        }
    }

    vector<ll> ma(n+1);
    ma[0] = 1;
    REP(i, n){
        if(v[i+1] > 2 * ma[i]){
            cout << -1 << endl;
            return 0;
        }
        if(ma[i] > INF){
            ma[i+1] = INF;
        }else{
            ma[i+1] = ma[i]*2 - v[i+1];
        }
    }

    ma[n] = 0;

    ll ans = 0, x = 0;
    RREP(i, n+1){
        if(Div(x,2LL) > ma[i]){
            cout << -1 << endl;
            return 0;
        }
        x = min(x + v[i], ma[i] + v[i]);
        ans += x;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
for a1 in range(101):
    b1 = c11-a1
    b2 = c12-a1
    b3 = c13-a1
    a2 = c21-b1
    a3 = c31-b1
    if (c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3):
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 3064
package main
import(
  "fmt"
  "os"
  "bufio"
  "strconv"
)
func main(){
  var(
   b,c []int
   a,time,module int
  )
  module=10
  scan:=bufio.NewScanner(os.Stdin)
  for scan.Scan() {
    a,_=strconv.Atoi(scan.Text())
    b=append(b,a)
    if a%10==0{
      c=append(c,10-a%10)
    }else{
      c=append(c,a%10)
      if module>a%10{
       module=a%10 
      }
    }
  }
  for i,j:=range c{
    if j==10{
     time+=b[i]
    }else{
     time+=b[i]+10-j 
    }
  }
  fmt.Println(time-10+module)
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
   }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
        p[i]--;
    }

    UnionFind UF(N);

    for(int i = 0; i < M; i++){
        int x, y;
        cin >> x >> y;
        UF.unite(x - 1, y - 1);
    }

    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += (UF.root(i) == UF.root(p[i]));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#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 reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }

string f(ll v) {
    string ans = "";
    while(v) {
        ans += (char)(v % 2 + '0');
        v /= 2;
    }
    reverse(all(ans));
    return ans;
}

string g(string s, ll k) {
    ll r = k - len(s);
    string p = "";
    rep(i, r) p += '0';
    return p + s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MIN / 2 + 1;
    const ll MB = 41;
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<ll> bc(MB, 0);
    rep(i, n) {
        rep(j, MB) {
            if (a[i] & (1LL << j)) bc[j]++;
        }
    }
    string kb = g(f(k), MB);
    ll nn = len(kb);
    // dp[figure][0:just, 1:smaller]
    vector<vector<ll>> dp(nn + 1, vector<ll>(2, inf));
    dp[0][0] = 0;
    rep(i, nn) {
        ll cv = kb[i] - '0';
        if (cv == 0) {
            if (dp[i][0] != inf) {
                chmax(dp[i + 1][0], dp[i][0] * 2 + bc[nn - 1 - i]);
            }
            if (dp[i][1] != inf) {
                chmax(dp[i + 1][1], dp[i][1] * 2 + bc[nn - 1 - i]);
                chmax(dp[i + 1][1], dp[i][1] * 2 + (n - bc[nn - 1 - i]));
            }
        }
        else {
            if (dp[i][0] != inf) {
                chmax(dp[i + 1][0], dp[i][0] * 2 + (n - bc[nn - 1 - i]));
                chmax(dp[i + 1][1], dp[i][0] * 2 + bc[nn - 1 - i]);
            }
            if (dp[i][1] != inf) {
                chmax(dp[i + 1][1], dp[i][1] * 2 + bc[nn - 1 - i]);
                chmax(dp[i + 1][1], dp[i][1] * 2 + (n - bc[nn - 1 - i]));
            }
        }
    }
    ll ans = max(dp[nn][0], dp[nn][1]);
    ll tmp = 0;
    rep(i, n) tmp += 0 ^ a[i];
    chmax(ans, tmp);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3972
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;} fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

int main(void){
    // char ;
    ll n,k;
    scanf("%lld%lld",&n,&k);
    ll a[n];
    // ll even=0;
    rep(i,0,n){
        scanf("%lld",&a[i]);
        // if(a[i]%2==0) even++;
    }
    // sortup(a,n);
    if( maxn(n,a) < k ){
        printf("IMPOSSIBLE\n");
        return 0;
    }
    // if(even==n){
    //     if(k%2){
    //         printf("IMPOSSIBLE\n");
    //     }else{
    //         ll r = []
    //     }
    // }
    ll g=a[0];
    rep(i,1,n){
        g= gcd(g,a[i]);
    }
    if(k%g==0){
        printf("POSSIBLE\n");
    }else{
        printf("IMPOSSIBLE\n");
    }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;

        return true;
    }
};

int main(){
    ll N,M; cin >> N >> M;
    vector<int> a(M), b(M);
    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    UnionFind uni(N);
    vector<ll> ans(M);
    ans[M-1] = N*(N-1)/2;

    for(int i=M-2; i>=0; i--){
        int A = a[i+1], B = b[i+1];
        if(uni.root(A) != uni.root(B)){
            ans[i] = ans[i+1] - uni.size(A)*uni.size(B);
            uni.connect(A, B);
        } else {
            ans[i] = ans[i+1];
        }
    }

    for(int i=0; i<M; i++) cout << ans[i] << endl;
}

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

int n;
int sum[2001];

int main()
{
	for( int i = 0; i <= 1000; ++i )
		for( int j = 0; j <= 1000; ++j )
			++sum[i + j];

	while( std::cin >> n )
	{
		int ans = 0;
		for( int a = 0; a <= 2000; ++a )
		{
			if( n - a < 0 || n - a > 2000 )
				continue;

			ans += sum[a] * sum[n-a];
		}

		std::cout << ans << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1168
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
using namespace std;
vector<int> v;
long long ans;
const int MOD = 1e9 + 7;
int main() {
	int n;
	cin >> n;

	// 1 3 6
	// 5 * 1 + 3*2
	vector<long long> v(n);
	for (auto& i : v) cin >> i;
	vector<long long> partSum(n);
	partSum[0] = v[0];
	for (int i = 0; i < v.size(); ++i) {
		partSum[i] = (i-1 >= 0 ? partSum[i - 1] : 0 ) + v[i];
	}
	for (int i = 0; i < v.size(); ++i) {
		long long sum = (partSum[n - 1] - partSum[i])%MOD;
		ans += v[i] * sum;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;

}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int n;
    cin >> n;
    vector<int> w(n);
    int s1,s2=0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        if(i>0)s2+=w[i];
    }
    s1=w[0];

    int ans = abs(s1-s2);
    Rep(i, 1, n){
        s1 += w[i];
        s2 -= w[i];
        ans = min(ans, abs(s1-s2));
    }
    pr(ans);
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
//#include <bits/stdc++.h>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007


#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(int a,int b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 

 
int main() {
    ll N,H,K;
    cin >> N>>H>>K;
    ll a[N];
    ll ans=0;
    ll sum=0;
    FOR(i,0,N-1){
      //cin>>a[i];
    }
    
  cout<<(N-K+1)*(N-H+1)<<endl;

  return 0;
}





Measured memory_bytes: 256
X, N = map(lambda x: int(x), input().split(" "))
if N != 0:
    Ps = set(map(lambda x: int(x), input().split(" ")))
    result = 0
    for i in range(1, 102):
        if i in Ps:
            continue
        if abs(X-result) > abs(X-i):
            result = i
else:
    input()
    result = X

print(result)


Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a1(n);
    vector<int> a2(n);
    vector<int> left1(n,0);
    vector<int> left2(n,0);
    vector<int> right1(n,0);
    vector<int> right2(n,0);
    rep(i, n) {
        cin >> a1[i];
    }
    rep(i, n) {
        cin >> a2[i];
    }
    rep(i, n) {
        if(i == 0) {
            left1[i] = a1[i];
            left2[i] = a2[i];
        } else {
            left1[i] = left1[i-1] + a1[i];
            left2[i] = left2[i-1] + a2[i];
        }
    }
    for(int i = n-1; i >= 0; i--) {
        if(i == n-1){
            right1[i] = a1[i];
            right2[i] = a2[i];
        } else {
            right1[i] = right1[i+1] + a1[i];
            right2[i] = right2[i+1] + a2[i];
        }
    }
    int max = 0;
    rep(i, n) {
        int tmp = left1[i] + right2[i];
        if(tmp > max)
            max = tmp;
    }
    cout << max << endl;
}




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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TC = 1;
    for (int tc = 0; tc<TC; ++tc) {
        int N; 
        cin >> N;
        if (N>=30) cout << "Yes";
        else cout << "No";
    }
}

Measured memory_bytes: 3648
#include <stdio.h>
 
int main() {
	int l,r,d;
	scanf("%d %d %d", &l, &r, &d);
	int a = 0;
	for(int i = l; i <= r; i++){
		if ( i % d == 0){
		a++;
			
		}
		
	}
	printf("%d", a);
	return 0;
}

Measured memory_bytes: 1704
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

// int n,a[100];

// ll dfs(int i,int rem){
	// if(rem==0) return 1;
	// if(i==n) return rem==0?1:0;

	// ll res=0;
	// res+=dfs(i+1,rem);

	// bool ok=true;
	// if(i>0 && a[i-1]==1) ok=false;
	// if(i==n-1 && a[0]==1) ok=false;
	// if((n&1)==0 && i>=n/2 && a[i-n/2]==1) ok=false;
	// if(ok){
		// a[i]=1;
		// res+=dfs(i+1,rem-1);
		// a[i]=0;
	// }

	// return res;
// }

int main(){
	// 前計算 (14 min)
	// for(n=8;n<=70;n++) printf("n=%2d: %lld\n",n,dfs(0,8));

	const ll ans[71]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,18,285,160,2079,946,9867,4224,35750,15314,107406,47264,281010,128370,660858,314368,1427679,706962,2877875,1480608,5476185,2919730,9924525,5468800,17250012,9797970,28915436,16887200,46955700,28132082,74144004,45474816,114191805,71564050,171986841,109947552,253873763,165301938,367982175,243703936,524607138,352947922,736647450,502914720,1020107270,705996914,1394666910,977586176,1884328875,1336628370,2518145487LL,1806252448,3331034685LL,2414479410LL};
	for(int n;scanf("%d",&n),n;) printf("%lld\n",40320*ans[n]);

	return 0;
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		//?????°?¨????
		String line, output;
		int num1, num2;

		//????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((line =br.readLine()) != null) {
			//??????
			String[] numString = line.split(" ", 0);
			//??????
			num1 = Integer.parseInt(numString[0]);
			num2 = Integer.parseInt(numString[1]);
			//?¨????
			num1 = num1 + num2;
			//??????
			output = String.valueOf(num1);
			System.out.println(output.length());
		}
	}

}

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

using namespace std;

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

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
long long n;

int main()
{
    while (scanf("%lld",&n)!=EOF)
    {
        string s;
        if (n==0)
        {
            puts("0");
            continue;
        }
        
        while (n!=0)
        {
            s=to_string(n&1)+s;
            n-=(n&1);
            n/=-2;
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  vector<int> a(5);
  rep(i, 5) cin >> a[i];

  int sum = 0;
  rep(i, 5){
    sum += a[i];
    a[i]--;
    a[i] %= 10;
  }
  sort(all(a));
  REP(i, 1, 5){
    a[i]++;
    sum += 10-a[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache



def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)



def main():
    n=int(input())
    a=list(map(int,input().split()))
    ans=1
    for i in range(n):
        ans*=a[i]
        if ans>10**18:
            ans=-1
            break
    if 0 in a:
        ans=0
    print(ans)










if __name__ == "__main__":

    main()

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

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

int main() {
  ll n,INF=10000000000;
  cin >> n ;
  vector<ll>h(n);
  rep(i,n) cin >> h.at(i);
  vector<ll>dp(n+5,INF);
  dp.at(0)=0;
  rep(i,n-1){
  	chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
  	chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
   
using namespace std;
typedef long long int ll;
  
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a+b==15){
		printf("+\n");
	}else if(a*b==15){
		printf("*\n");
	}else{
		printf("x\n");
	}
    return 0;
}

Measured memory_bytes: 256