akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld double
#define llu unsigned long long
#define rep(i,x,y)  for(ll i=x;i<y;++i)
#define For(i,x,y)  for(ll i=x;i<=y;++i)
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define pi acos(-1)
#define mk make_pair<ll,ll>
#define pa pair<ll,ll>
#define lf else if
#define max(x,y)    ((x)<(y)?(y):(x))
#define min(x,y)    ((x)<(y)?(x):(y))
#define sqr(x)      ((x)*(x))
#define abs(x)      ((x)>0?(x):-(x))
#define Mul(x,y)    ((x)=1LL*(x)*(y)%mod)
#define Add(x,y)	((x)=((x)+(y))%mod)
#define Max(x,y)    ((x)=((x)<(y)?(y):(x)))
#define Min(x,y)	((x)=((x)>(y)?(y):(x)))
#define E(x)        return writeln(x),0
#define p(x)        printf("~%lld~\n",(long long)x)
#define pp(x,y)     printf("~~%lld %lld~~\n",(long long)x,(long long)y)
#define ppp(x,y,z)  printf("~~~%lld %lld %lld~~~\n",(long long)x,(long long)y,(long long)z)
#define pppp(a,b,c,d)	printf("~~~%d %d %d %d\n",(long long)a,(long long)b,(long long)c,(long long)d)
#define f_in(x)     freopen(x".in","r",stdin)
#define f_out(x)    freopen(x".out","w",stdout)
#define open(x)     f_in(x),f_out(x)
#define fi first
#define se second
#define GuYueNa		puts("GYN_________________________________________")
typedef complex<double> E;
namespace _GuYueNa{
#ifdef LOCAL
    struct _{_(){freopen("cf.in","r",stdin);}}_;
#endif
#define NEG 1
#if NEG
    inline ll read(){    ll x=0,f=1; char ch=getchar();   for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;  for (;isdigit(ch);ch=getchar())  x=x*10-48+ch;   return x*f; }
    inline void write(ll x){    if (x<0) putchar('-'),x=-x;  if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#else
    inline ll read(){    ll x=0; char ch=getchar();   for (;!isdigit(ch);ch=getchar());    for (;isdigit(ch);ch=getchar()aaaaaaaaaaaaa)  x=x*10-48+ch;   return x;   }
    inline void write(ll x){    if (x>=10)   write(x/10);    putchar(x%10+'0');  }
#endif
    inline void writeln(ll x){  write(x);   puts("");   }
}using namespace _GuYueNa;
const ll N=200010,mod=998244353;
char s[N];ll f[N][3][3],n,frog1,frog2,A,B,C,ans;
ll ppow(ll x,ll k){ll ans=1;for(;k;k>>=1,Mul(x,x))if (k&1)Mul(ans,x);return ans;}
int main(){
	scanf("%s",s+1);n=strlen(s+1);
	For(i,1,n)A+=s[i]=='a',B+=s[i]=='b',C+=s[i]=='c';
	if (n==2)return writeln(1+(s[1]!=s[2])),0;
	if (n==3){
		if (s[1]==s[2]&&s[2]==s[3]) puts("1");
		lf (s[1]==s[2]||s[2]==s[3]) puts("6");
		lf (s[1]==s[3]) puts("7");
		else puts("3");
		return 0;
	}
	rep(i,1,n){
		frog1|=s[i]!=s[i+1];
		frog2|=s[i]==s[i+1];
	}if (!frog1)return puts("1"),0;
	ans=ppow(3,n-1);
	For(i,0,2)f[1][i][i]=1;
	For(i,2,n)	For(cur,0,2)For(lzh,0,2)For(now,0,2)if (lzh^now)Add(f[i][(cur+now)%3][now],f[i-1][cur][lzh]);
	For(i,0,2)
	Add(ans,-f[n][(B+C*2)%3][i]),Add(ans,mod),Add(ans,mod);
/*
有i个位置和i+1位置相同,要求1..n-1答案,即 
*/ 
	writeln((!frog2+ans)%mod);
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

vll adj[N];ll visit[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m,k;
string s,t;
vll a,b,p,ans;
// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >>n;
	vll a(n);
	for(ll i=0;i<n;i++) {
		cin>>a[i];
	}
	ll val = __gcd(a[0],a[1]);
	//cout<<val<<" ";
	for(ll i=2;i<n;i++) val = __gcd(val,a[i]);// cout<<val<<" " ;
	cout<<val;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



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

signed main(){
	vector<int> a(3);
	cin>>a[1]>>a[2]>>a[0];
	sort(a.begin(),a.end());
	bool pro=true;
	if(a[0]==a[1]&& a[1]==a[2])pro=true;
	else if(a[0]!=a[1] && a[0]!=a[2] && a[2]!=a[1])pro=true;
	else{
		pro=false;
	}
	cout<<((pro)? "No": "Yes")<<endl;

}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

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

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
     
    while(x!=NULL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NULL) {
        root = z;
    } else {
        if(z->key < y->key) {
            y->left = z;
        }else{
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

Node * find(Node *u, int k) {
    while(u!=NIL && k != u->key) {
        if (k < u->key) {
            u = u->left;
        }else{
            u = u->right;
        }
    }
    return u;
}

int main() {
    int n, i, x;
    string com;
    
    scanf("%d", &n);
    
    for (i=0; i<n; i++) {
        cin >> com;
        if(com == "insert") {
            scanf("%d", &x);
            insert(x);
        }else if(com == "find") {
            scanf("%d", &x);
            Node *t = find(root, x);
            if(t!=NIL) printf("yes\n");
            else printf("no\n");
        }else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    
    return 0;
}


Measured memory_bytes: 21964
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<pi> vpi;

#define debugone(x) cout << #x << " " << x << endl;
#define debugtwo(x) cout << #x << "-------------" << endl;for(auto &it: x) cout << it << " ";cout << endl;
#define debugthree(x, i, j) cout << #x << "------------" << endl;cout << "from " << i << " to " << j << endl;for(int k=i; k<=j; k++) cout << x[k] << " ";cout << endl;

const int mod = (int)1e9 + 7;

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

	int h, w;
	cin >> h >> w;
	vector<vector<bool>> obstacle(h+1, vector<bool> (w+1));

	vector<vector<int>> rows(h+1), cols(w+1);

	


	for(int row = 1; row <=h; row++){
		rows[row].push_back(0);
	}

	for(int col = 1; col <= w; col++){
		cols[col].push_back(0);
	}


	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			char ch;
			cin >> ch;
			if(ch == '#'){
				obstacle[i][j] = true;
				rows[i].push_back(j);
				cols[j].push_back(i);
			} 
			else obstacle[i][j] = false;
		}
	}

	for(int row = 1; row <=h; row++){
		rows[row].push_back(w+1);
	}

	for(int col = 1; col <= w; col++){
		cols[col].push_back(h+1);
	}

	int maxi = 0;

	for(int r = 1; r <= h; r++){
		for(int c = 1; c <= w; c++){
			cerr << (obstacle[r][c] ? '#' : '.');
		}
		cerr << endl;
	}


	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			if(!obstacle[i][j]){
				int totalLight = 0;
				int id = lower_bound(rows[i].begin(), rows[i].end(), j) - rows[i].begin();
				totalLight += rows[i][id] - rows[i][id-1] - 1;
				id = lower_bound(cols[j].begin(), cols[j].end(), i) - cols[j].begin();
				totalLight += cols[j][id] - cols[j][id-1] - 2;
				maxi = max(totalLight, maxi);
			}
		}
	}

	cout << maxi << endl;
}

Measured memory_bytes: 35072
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<complex>
#include<algorithm>
#include<vector>
#include<math.h>
#include<set>
#include<map>

int main()
{
	int x, y;
	scanf("%d%d", &x, &y);
	if (x == 2 || y == 2)
		printf("No\n");
	else
	{
		if (x >= 8) x++;
		if (y >= 8) y++;
		if (!((x + y) % 2)) printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll M; cin >> M;
  vector<ll> D(M);
  vector<ll> C(M);
  rep(i,M) cin >> D[i] >> C[i];
  ll ans = 0;
  vector<ll> cntd(10, 0);
  rep(i,M){
    if(D[i]==0){
      ans += C[i];
    }
    else{
      cntd[D[i]] += C[i];
    }
  }
  bool flag = true;
  while(flag){
    vector<ll> cnt_(10,0);
    rep(i,10){
      if(i==0) continue;
      ans += cntd[i]/2;
    }
    cnt_[2] += cntd[1]/2; cnt_[1] += cntd[1]%2;
    cnt_[4] += cntd[2]/2; cnt_[2] += cntd[2]%2;
    cnt_[6] += cntd[3]/2; cnt_[3] += cntd[3]%2;
    cnt_[8] += cntd[4]/2; cnt_[4] += cntd[4]%2;
    cnt_[1] += cntd[5]/2; cnt_[0] += cntd[5]/2; cnt_[5] += cntd[5]%2;
    cnt_[1] += cntd[6]/2; cnt_[2] += cntd[6]/2; cnt_[6] += cntd[6]%2;
    cnt_[1] += cntd[7]/2; cnt_[4] += cntd[7]/2; cnt_[7] += cntd[7]%2;
    cnt_[1] += cntd[8]/2; cnt_[6] += cntd[8]/2; cnt_[8] += cntd[8]%2;
    cnt_[1] += cntd[9]/2; cnt_[8] += cntd[9]/2; cnt_[9] += cntd[9]%2;
    ans += cnt_[0]; cnt_[0]=0;
    ans += 10*(cnt_[1]/10); cnt_[1] = cnt_[1]/10+cnt_[1]%10;
    cntd = cnt_;
    rep(i,10){
      cerr << cntd[i] << " ";
    }
    cerr << endl;
    rep(i,10){
      if(cntd[i] >= 2) break;
      if(i==9) flag = false;
    }
    //break;
  }
  cerr << "a" << endl;
  bool flag2 = true;
  vector<ll> cntt_ = cntd;
  while(flag2){
    for(int x=1;x<10;x++){
      for(int y=x;y<10;y++){
        if(cntt_[x]>0 && cntt_[y]>0){
          if(x==y){
            if(cntt_[x]>=2){
              if(x+y>=10) cntt_[1]++;
              cntt_[(x+y)%10]++;
              cntt_[x]--;
              cntt_[y]--;
              ans++;
            }
          }
          else{
            if(x+y>=10) cntt_[1]++;
            cntt_[(x+y)%10]++;
            cntt_[x]--;
            cntt_[y]--;
            ans++;
            // goto ttt;
          }
        }
      }
    }
    // ttt:
    ans += cntt_[0]; cntt_[0] = 0;
    ans += 10*(cntt_[1]/10); cntt_[1] = cntt_[1]/10+cntt_[1]%10;
    ll s=0;
    rep(i,10){
      cerr << cntt_[i] << " ";
      s+=cntt_[i];
    }
    cerr << endl;
    if(s<=1) flag2 = false;
    //ans += cnt_[0]; cnt_[0]=0;
    /*
    rep(i,10){
      cntd[i] += cnt_[i];
    }
    */
    /*
    int cnt=0;
    rep(i,10){
      cerr << cntd[i] << " ";
      cnt += cntd[i];
    }
    cerr << endl;
    if(cnt==1 || cnt==0) break;
    */
  }

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


Measured memory_bytes: 3328
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

var pfs map[int]int
var prime []int

const size = 1000100

func initPrime() {
	prime = make([]int, size+1)
	for i := 0; i <= size; i++ {
		prime[i] = i
	}
	for i := 2; i*i <= size; i++ {
		if prime[i] == i {
			for j := i; j <= size; j += i {
				prime[j] = i
			}
		}
	}
}

// PfsMap : 素因数分解し、マップを作成
func PfsMap(n int) {
	for n >= 2 {
		p := prime[n]
		pfs[p]++
		for n%p == 0 {
			n /= p
		}
	}
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	a := getInts(N)

	// N := 100
	// a := make([]int, N)
	// for i := 0; i < N; i++ {
	// 	a[i] = rand.Intn(1000000)
	// }

	initPrime()
	pfs = make(map[int]int)

	sc := a[0]
	PfsMap(a[0])
	for i := 1; i < N; i++ {
		PfsMap(a[i])
		sc = GCD(sc, a[i])
	}
	// out(sc, pfs, a)
	flg := true
	for _, e := range pfs {
		if e != 1 {
			flg = false
			break
		}
	}
	if flg == true {
		out("pairwise coprime")
		return
	}
	if sc == 1 {
		out("setwise coprime")
		return
	}
	out("not coprime")

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  ll ans = 0;
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  for(int i = 0; i < N; i++) cin >> t[i];

  for(int i = 0; i < N-1; i++){
    ans += min(T, t[i+1]-t[i]);
  }
  ans += T;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#define _ read()
int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
int read() {
    int s=0;
    char c=getchar();
    while(c<'0'||c>'9') c=getchar();
    while(c>='0'&&c<='9') s=s*10+c-'0',c=getchar();
    return s;
}
int main() {
    int a,b,c;
    int x1,x2,y1,y2,n;
    x1=y1=0;
    x2=_,y2=_, n=_;
    while(n--) {
        a=_,b=_,c=_;
        if (c==1) x1=max(a,x1);
        else if(c==2) x2=min(a,x2);
        else if (c==3) y1=max(b,y1);
        else y2=min(b,y2);
    }
    printf("%d\n",x2>x1&&y2>y1?(x2-x1)*(y2-y1):0);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
while(n-->0){
int r=sc.nextInt(),t=sc.nextInt();String a="";
for(int y=0;y<(t%30>0?2:1);y++)
for(int x=0;x<(r%100>0?2:1);a+=(t/30+y)*5+r/100+x++)
if((x|y)==1)
a+=" ";
System.out.println(a);
}
}
}


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<string>> vec(N);
    REP(i, M) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        vec[p].push_back(s);
    }

    ll A = 0;
    ll W = 0;
    REP(i, vec.size()) {
        bool ok = false;
        int tmp = 0;
        REP(j, vec[i].size()) {
            if (vec[i][j] == "AC") {
                ok = true;
                break;
            } else {
                tmp++;
            }
        }
        if (ok) {
            A++;
            W += tmp;
        }
    }
    cout << A << " " << W << endl;
}

signed main() {
    solve();
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;


struct Dinic {
    typedef long long flow_type;
    struct edge {
        int src, dst;
        flow_type capacity, flow;
        size_t rev;
    };
    int n;
    vector<vector<edge>> adj;
    Dinic(int n) : n(n), adj(n) { }
    void add_edge(int src, int dst, flow_type capacity) {
        adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
        adj[dst].push_back({dst, src, 0, 0, adj[src].size()-1});
    }
    flow_type max_flow(int s, int t) {
        vector<int> level(n), iter(n);
        function<int(void)> levelize = [&]() { // foward levelize
            level.assign(n, -1); level[s] = 0;
            queue<int> Q; Q.push(s);
            while (!Q.empty()) {
                int u = Q.front(); Q.pop();
                if (u == t) break;
                for (auto &e: adj[u]) {
                    if (e.capacity > e.flow && level[e.dst] < 0) {
                        Q.push(e.dst);
                        level[e.dst] = level[u] + 1;
                    }
                }
            }
            return level[t];
        };
        function<flow_type(int, flow_type)> augment = [&](int u, flow_type cur) {
            if (u == t) return cur;
            for (int &i = iter[u]; i < (ll)adj[u].size(); ++i) {
                edge &e = adj[u][i], &r = adj[e.dst][e.rev];
                if (e.capacity > e.flow && level[u] < level[e.dst]) {
                    flow_type f = augment(e.dst, min(cur, e.capacity - e.flow));
                    if (f > 0) {
                        e.flow += f;
                        r.flow -= f;
                        return f;
                    }
                }
            }
            return flow_type(0);
        };
        for (int u = 0; u < n; ++u) // initialize
            for (auto &e: adj[u]) e.flow = 0;

        flow_type flow = 0;
        while (levelize() >= 0) {
            fill(iter.begin(),iter.end(), 0);
            for (flow_type f; (f = augment(s, INF)) > 0; )
                flow += f;
        }
        return flow;
    }
    const vector<edge> operator[](const ll k){return adj[k];}
};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll a[N];
  ll ans = 0;
  for(ll i=0;i<N;i++){
    cin>>a[i];
    if(a[i]>0)ans += a[i];
  }
  Dinic g(N+2);
  ll src=N,dst=N+1;
  for(ll i=0;i<N;i++){
    g.add_edge(src,i,(a[i]>0?0:-a[i]));
    g.add_edge(i,dst,(a[i]>0?a[i]:0));
  }
  for(ll i=1;i<=N;i++){
    for(ll j=2*i;j<=N;j+=i){
      g.add_edge(i-1,j-1,INF);
    }
  }
  ans -= g.max_flow(src,dst);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rip(i, n) for(int i = 0; i < (int)(n); i++) 

int main() {
  
  int a, c;
  char b;
  cin >> a >> b >> c;
  if(b == '+'){
  	cout << a + c << endl;
  }
  if(b == '-'){
  	cout << a - c << endl;	
  }
  
  	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

vector<double> memo(1000,0.0);

int main(){
    double n, k;
    cin >> n >> k;

    double ans = 0.0;
    memo[0] = 1.0;
    memo[1] = 0.5;
    for(int i = 2; i <= 999; i++){
        memo[i] = memo[i-1]*0.5;
    }

    for(int i = 1; i <= n; i++){
        int val = i;
        int cnt = 0;
        while(val < k){
            val *= 2;
            cnt++;
        }
        ans += memo[cnt]/n;
    }


    printf("%.10f\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;main(){long long n,b ,k,res=0;cin>>n>>k;if(!k)return cout<<n*n,0;for(b = k+1;b<=n;b++)res+=n/b*max(0LL,b-k)+max(n%b-k+1,0LL);cout << res;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0) printf("%d\n",(a+b)/2);
    else if(a==b) printf("%d\n",0);
    else printf("IMPOSSIBLE\n");
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N, D, i, j, k, M=0;
    int x[20][10];
    double l, L;

    cin >> N >> D;

    for (i = 1; i <= N; i++) {
      for (j = 1; j <= D; j++) {
        cin >> x[i][j];
      }
    }

    for (i = 1; i <= N-1; i++) {
      for (j = i+1; j <= N; j++) {
        l = 0;
        for (k = 1; k <= D; k++) {
          l += pow(((x[i][k])-(x[j][k])), 2.0);
        }
        L = sqrt(l);
        if (L == floor(L)) {
          M++;
        }
      }
    }

    cout << M;


    return 0;
}


Measured memory_bytes: 764
package main

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

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func readInt(sc *bufio.Scanner) (res int) {
	res, _ =strconv.Atoi(readLine(sc))
	return
}

func readInts(sc *bufio.Scanner, n int) []int {
	ns := strings.Split(readLine(sc), " ")
	res := make([]int, n)

	for i, n := range ns {
		res[i], _ = strconv.Atoi(n)
	}
	return res
}

func readInt64s(sc *bufio.Scanner, n int) []int64 {
	ns := strings.Split(readLine(sc), " ")
	res := make([]int64, n)

	for i, n := range ns {
		res[i], _ = strconv.ParseInt(n, 10, 64)
	}
	return res
}

func readMatrix(sc *bufio.Scanner, rows, cols int) [][]int {
	res := make([][]int, rows)
	for i := 0; i < rows; i ++ {
		res[i] = readInts(sc, cols)
	}
	return res
}

func main() {
	sc := bufio.NewScanner(os.Stdin)

	xs := readInts(sc, 2)
	a := xs[0]
	b := xs[1]

	fmt.Println((a + b) % 24)
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int main() {
	int K, A, B; cin >> K >> A >> B;
	for (int i = A; i <= B; i++) {
		if (i % K == 0) { cout << "OK" << endl; return 0; }
	}
	cout << "NG" << endl;
}

Measured memory_bytes: 3640
//g++ -std=c++14 test.cpp -o test.out
//問題URL:
//https://atcoder.jp/contests/arc100/tasks/arc100_b

//参考：
// https://drken1215.hatenablog.com/entry/2018/08/28/193000

// ポイント：理想の状況がどういう時かを考える
// Max-minが最小になるのはどういう時？
// →PQSTどれ2つをとっても、差ができるだけ小さくなっているはず
// （あえて大きくしてもいいが、それだとMax-minが大きくなってしまう危険をはらんでいる上に、
// Max-minをもっと小さくする、といったことができない）
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
LL A[200000];

LL ans = INF;

void solve(){
	vector<LL> accum(N,A[0]);
	for(int i=1;i<N;i++) accum[i] = accum[i-1] + A[i];

	//切れ込み3箇所のうち、真ん中を決めうち
	//インデックスi番目の直後に入れることを想定
	for(int middle=1;middle<=N-3;middle++){
		auto search = [&](int left_index,int right_index){
			LL left = left_index;
			LL right = right_index-1;
			while(left+1<right){
				LL center = (left+right)/2LL;
				LL leftside = accum[center] - ((left_index==0)?0:accum[left_index-1]);
				LL rightside = accum[right_index] - accum[center];
				if(leftside==rightside) return center;
				if(leftside>rightside) right = center;
				if(leftside<rightside) left = center;
			}
			LL left_diff,right_diff;
			{
				LL leftside = accum[left] - ((left_index==0)?0:accum[left_index-1]);
				LL rightside = accum[right_index] - accum[left];
				left_diff = abs(rightside-leftside);
			}
			{
				LL leftside = accum[right] - ((left_index==0)?0:accum[left_index-1]);
				LL rightside = accum[right_index] - accum[right];
				right_diff = abs(rightside-leftside);
			}
			return (left_diff<right_diff)?left:right;
		};
		LL left = search(0,middle);
		LL right = search(middle+1,N-1);

		LL P = accum[left];
		LL Q = accum[middle] - accum[left];
		LL R = accum[right] - accum[middle];
		LL S = accum[N-1] - accum[right];
		LL cand = max(max(P,Q),max(R,S)) - min(min(P,Q),min(R,S));
		ans = min(ans,cand);
	}
}
 
int main(){
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

Measured memory_bytes: 6052
def examA():
    S, T = LSI()
    ans = T+S
    print(ans)
    return

def examB():
    A, B, K = LI()
    if A>K:
        A -=K
        print(A,B)
        return
    if A+B>K:
        B -=(K-A)
        A = 0
        print(A,B)
        return
    A = 0; B = 0
    print(A,B)
    return

def examC():
    def is_prime(n):
        if n == 1: return False
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True
    X = I()
    while(True):
        if is_prime(X):
            ans = X
            break
        X +=1
    print(ans)
    return

def examD():
    N, K = LI()
    R, S, P = LI()
    T = SI()
    C = Counter(T)
    sumT = C["r"]*P + C["s"]*R + C["p"]*S
#    print(sumT)
    ans = sumT
    d = defaultdict(bool)
    for i in range(K,N):
        if T[i]==T[i-K] and not d[i-K]:
            if T[i]=="r":ans -=P
            elif T[i]=="s":ans -=R
            else:ans -=S
            d[i] = True
    print(ans)
    return

def examE():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()


Measured memory_bytes: 15892
import sys

n = int(sys.stdin.readline().strip())

dist = {}

for i in xrange(0, n):
    array = map(int, sys.stdin.readline().strip().split(" "))
    for (j, d) in enumerate(array):
        dist[(i, j)] = d

searched = []
length = 0

target = 0

while len(searched) != n:
    searched.append(target)
    min_len = 2001
    for v in searched:
        for i in xrange(0, n):
            if (i not in searched) and (min_len > dist[(v, i)]) and (dist[(v, i)] != -1):
                min_len = dist[(v, i)]
                target = i
    if min_len != 2001:
        length += min_len

print str(length)

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

int n = 0, k = 0;
int nIn[100000] = { 0 };
typedef long long ll;

int check(ll lIn)
{
	ll i = 0, j = 0;
	while (j < k)
	{
		ll lSum = 0;
		while (lSum + nIn[i] < lIn)
		{
			lSum += nIn[i];
			i++;
			if (i == n)
			{
				return j;
			}
		}
		j++;
	}
	return k;
}

int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++)
	{
		cin >> nIn[i];
	}
	ll lLeft = 0, lRight = 100000 * 10000;
	ll LMid = 0;
	while (lLeft + 1 < lRight)
	{
		LMid = (lLeft + lRight) / 2;
		if (check(LMid) < k)
		{
			lRight = LMid;
		}
		else
		{
			lLeft = LMid;
		}
	}
	cout << lLeft << endl;
	return 0;
}


Measured memory_bytes: 3464
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,d;
    cin >> n >> d;
    int temp = d * 2 + 1;
    cout << (n+temp-1)/temp  << endl;
    return 0;
}

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

typedef long long ll;
const int maxn = 1000005;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

int n;
char s[maxn], t[maxn];
int ans, l, r, q[maxn];

int main()
{
	scanf("%d\n%s%s", &n, s + 1, t + 1);

	int i;
	for (i = 1; i <= n; ++i)
		if (s[i] != t[i]) break;
	if (i > n) return puts("0"), 0;
	
	int up = n, down = n;
	l = 1; r = 0;
	while (down) {
		while (down && t[down - 1] == t[down]) --down;
		while (up && (up > down || s[up] != t[down])) --up;
		if (!up) return puts("-1"), 0;
		while (l < r && q[l] - (r - l + 1) >= down) ++l;
		if (up != down) q[++r] = up;
		ans = max(ans, r - l + 2);
		--down;
	}

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


Measured memory_bytes: 6144
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

int ans=1e9;
string s,t;

int main()
{
    cin >> s >> t;
    for (int i=0;i<=s.size()-t.size();i++)
    {
        int cnt=0;
        for (int j=0;j<t.size();j++)
        {
            cnt+=(s[j+i]!=t[j]);
        }
        ans=min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;
  string S;
  cin >>N>>S;
  vector<int> A;
  rep(i,N-1){
    if(S[i]==S[i+1]){
      
    }
    else{
      A.emplace_back(S[i]);
    }
  }
  int ans=A.size()+1;
  
  cout <<ans<<endl;
return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef unsigned long long ull; 
 
class AOJ0186{
private:
  int q1,b,c1,c2,q2;
public:
 
  AOJ0186(int a,int b,int c,int d,int f):q1(a),b(b),c1(c),c2(d),q2(f){}
  ~AOJ0186(){}
 
 
  void run(){
    int aizu_meet,meet;
 
    bool ok = false;
    int preb = b;
     
    for(int i=q2;i>=1;i--){
      aizu_meet = meet = 0,b = preb;
      if(i*c1 > b)continue;
      aizu_meet = i;
      b -= (c1*i);
      meet = b/c2;
      //cout << "i =" << i << endl;
      //cout << aizu_meet << ' ' << meet << ", b = " << b << endl;
      if(aizu_meet+meet < q1)continue;
      if(aizu_meet == 0)continue;
      ok = true;
      cout << aizu_meet << ' ' << meet << endl;
      //cout << "i = " << i << endl;
 
      break;
    }
 if(!ok)cout << "NA" << endl;
  }
};
 
int main(){
  int q;
  while(true){
    cin >> q;
      if(q == 0)break;
    int B,c,cc,qq;
    cin >> B >> c >> cc >> qq;
    AOJ0186 ans = AOJ0186(q,B,c,cc,qq);
    ans.run();
  }
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  for(int i = 0; i < n; i++) cin >> x.at(i);
  
  int ans = 10000000;
  for(int i = 1; i < 100; i++){
    int sum = 0;
    for(int j = 0; j < n; j++){
      sum += pow((x.at(j) - i), 2);
    }
    ans = min(ans, sum);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

decimal.getcontext().prec = 50

N = input()
x = []
y = []
for i in range(N):
    x_, y_ = map(int, raw_input().split())
    x += [decimal.Decimal(x_)]
    y += [decimal.Decimal(y_)]

ans = 0

for i in range(N):
    for j in range(N - 1):
        if math.atan2(x[j], y[j]) > math.atan2(x[j + 1], y[j + 1]):
            x[j], x[j + 1] = x[j + 1], x[j]
            y[j], y[j + 1] = y[j + 1], y[j]
for i in range(N):
    for j in range(N):
        X = decimal.Decimal(0)
        Y = decimal.Decimal(0)
        for k in range(N):
            if i <= j and i <= k <= j:
                X += x[k]
                Y += y[k]
            elif j < i and not j < k < i:
                X += x[k]
                Y += y[k]
        ans = max(ans, X * X + Y * Y)

L = decimal.Decimal(0)
R = decimal.Decimal(INF)

for loop in range(1000):
    mid = (L + R) / 2
    if mid * mid <= ans:
        L = mid
    else:
        R = mid
print L

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){
  Node n = u;
  while(n != NIL) {
    if(n->key > k) n = n->left;
    else if(n->key < k) n = n->right;
    else return n;
  }
  return NIL;
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = (node *)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x != NIL) {
    y = x;
    x = (z->key < x->key)? x->left : x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u){
  if(u == NIL) return;
  if(u->left != NIL) inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 21956
#include <iostream>
#include <cstdlib>

using namespace std;

int main(){
  int N, i, s1=0, s2=0, sum=0, ans;
  cin >> N;
  int w[N];
  for(i=0; i<N; i++) cin >> w[i];
  for(i=0; i<N; i++) sum += w[i];
  for(i=0; i<N-1; i++){
    s1+=w[i];
    s2=sum-s1;
    if(i==0) ans = abs(s1-s2);
    else{
      if(ans > abs(s1-s2)) ans = abs(s1-s2);
    }
  }
  cout << ans << endl;
  return 0;
}


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

#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++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

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

  ll l = 0, r = 0;
  REP(i, n) {
    if (s[i] == ')') {
      if (l > 0) {
        --l;
      } else {
        ++r;
      }
    } else {
      ++l;
    }
  }

  string ans = string(r, '(') + s + string(l, ')');

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
bool be[31] = {0};
bool sg[3001] = {0};
int main()
{
	int a,b,c,d,e,f;
	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
	int t;
	be[0] = 1;
	for(t=a;t<31;t++)
	{
		if(be[t-a] == 1)
			be[t] = 1;
	}
	for(t=b;t<31;t++)
	{
		if(be[t-b] == 1)
			be[t] = 1;
	}
	sg[0] = 1;
	for(t=c;t<3001;t++)
	{
		if(sg[t-c] == 1)
			sg[t] = 1;
	}
	for(t=d;t<3001;t++)
	{
		if(sg[t-d] == 1)
			sg[t] = 1;
	}
	int mw=a,ms=0;
	double ma=0;
	for(t=f/100;t>0;t--)
	{
		if(be[t] == 1)
		{
			int sm;
			sm = t*e;
			if(sm > f-t*100)
				sm = f-t*100;
			while(sg[sm] == 0)
				sm--;
			if(ma < 100.0*sm/(t*100+sm))
			{
				ma = 100.0*sm/(t*100+sm);
				mw = t;
				ms = sm;
			}
		}
	}
	printf("%d %d\n",mw*100+ms,ms);
	return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;
  vector<int> cnt(13);

  rep(i, n){
    int d;
    cin >> d;
    cnt[d]++;
  }
  if(cnt[0] > 0){
    cout << 0 << endl;
    return 0;
  }

  vector<int> base(25);
  rep(i, 25) base[i] = 0;
  base[0] = 1;
  base[24] = 1;

  vector<int> kouho;

  rep(i, 13){
    
    if(cnt[i] >= 3){
      cout << 0 << endl;
      return 0;
    }else if(cnt[i] == 2){

      if(i==12){
        cout << 0 << endl;
        return 0;
      }

      base[i] = 1;
      base[24-i] = 1;

    }else if(cnt[i]==1){

      if(i==12){
        base[12] = 1;
      }else{
        kouho.push_back(i);
      }
    }
  }

  int ans = 0;

  int m = kouho.size();
  for(int bit = 0; bit < (1<<m); bit++){

    vector<int> val(25);
    rep(i, 26) val[i] = base[i];

    rep(i, m){
      if(bit & (1<<i)){
        val[kouho[i]] = 1;
      }else{
        val[24-kouho[i]] = 1;
      }
    }

    int cnt = 0;
    int tans = 26;
    rep(i,1, 25){
      if(val[i] == 0){
        cnt++;
      }else {
        chmin(tans, cnt);
        cnt = 0;
      }

    }
    if(cnt > 0) chmin(tans, cnt);
    chmax(ans, tans+1);
  }


  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 256
def array_integer(a)
	0.upto(a.count - 1) {|x|
		a[x] = a[x].to_i if a[x] != "\n"
	}
	return a
end

eof = false



until eof do 
	num_array = array_integer(STDIN.gets.chomp!.split(""))
	
	if num_array.length == 1 && num_array[0] == 0 then
		eof = true
		break
	end
	
	sum = 0
	num_array.each {|i|
			sum += i
	}
	print sum, "\n"
end



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

int main() {
  /*
  cin.tie(0);
  ios::sync_with_stdio(false);
  */
  
  const double pi = 3.1415926535;
  int A, B, H, M;
  cin>>A>>B>>H>>M;
  double d = 6.0*M - (H*60+M)*0.5;
  double rad = (d*pi)/180;
  double x = A*A+B*B-2*A*B*cos(rad);
  double y = sqrt(x);
  printf("%.10lf\n", y);
}

Measured memory_bytes: 4152
#include<bits/stdc++.h>
using namespace std;
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  double om,op,pm,pp,a,b;
  int n;
  cin>>n;
  for(long long i=0;i<n;i++){
    cin>>om>>pm>>op>>pp;
    if(op>=5 && pp>=2){
      cout<<(om*op+pm*pp)*0.8<<'\n';
    }
    else{
      a=om*op+pm*pp;
      if(op>=5) b=(om*op+2*pm)*0.8;
      else if(pp>=2) b=(om*5+pp*pm)*0.8;
      else b=(om*5+pm*2)*0.8;
      if(a>=b) cout<<b<<'\n';
      else cout<<a<<'\n';
    }
  }
  return(0);
}



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

front = A[0]
count = 0
for i in range(1,N):
    hight = 0
    if front > A[i]:
        hight = front -A[i]
        count += hight
    front = hight + A[i] 
print(count)

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

int main() {
    int A, B;
    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        bool isOk = true;
        int s = i % 10;
        int t = (i / 10000) % 10;
        if (s != t) isOk = false;
        int v = (i / 10) % 10;
        int u = (i / 1000) % 10;
        if (v != u) isOk = false;
        if (isOk) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int x;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> x;
	rep2(i,-1000,1000) rep2(j,-1000,1000){
		if(i*i*i*i*i-j*j*j*j*j==x){
			print2(i,j);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3664
#include<iostream>
#include<iomanip>
#include<deque>

using namespace std;

deque<pair<int,double> > Q;

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

    int n,l;
    cin>>n>>l;

    long long Vt=0;
    double VTt=0.0;
    for(int i=1; i<=n; i++)
    {
        int v;
        double t;
        cin>>t>>v;

        Vt+=v;
        VTt+=1.0*v*t;
        while(Vt>l)
        {
            int elim=min(1LL*Q.front().first,Vt-l);
            Vt-=elim;
            VTt-=elim*Q.front().second;

            if(elim==Q.front().first)
                Q.pop_front();
            else
                Q.front().first-=elim;
        }

        cout<<setprecision(7)<<fixed<<1.0*VTt/l<<"\n";

        while(!Q.empty() && Q.back().second>t)
        {
            t=1.0*(t*v+Q.back().second*Q.back().first)/(v+Q.back().first);
            v=v+Q.back().first;
            Q.pop_back();
        }
        Q.push_back({v,t});
    }
    return 0;
}


Measured memory_bytes: 17296
import java.util.*;
import java.lang.*;
public class Main {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      long  a=sc.nextLong();
      long v=sc.nextLong();
      long b=sc.nextLong();
      long w=sc.nextLong();
      long t=sc.nextLong();
      long p=Math.abs(a-b);
      long q=t*(v-w);
     
      
      if(p<=q)
      System.out.println("YES");
      else
      System.out.println("NO");
      }
    
}

Measured memory_bytes: 35676
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
vector<string> a(200);
ll dp[101][101][2];
ll n, m;
ll recurse(ll x, ll y, ll color) {
	if(x > n or y > m) return inf; 
	if(x == n-1 and y == m-1) {
		ll cc;
		a[x][y] == '#' ? cc = 0 : cc = 1;
		if(cc == 0 and color == 1) return 1;
		return 0;
	}
	ll &ans = dp[x][y][color];
	if(ans != -1) return ans;
	ans = inf;
	ll sum = 0;
	ll currcol;
	a[x][y] == '#' ? currcol = 0 : currcol = 1;
	if(currcol == 0 and color == 1) sum = 1;
	ans = min(ans, sum + recurse(x + 1, y, currcol));
	ans = min(ans, sum + recurse(x, y + 1, currcol));
	return ans;
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n >> m;
  for(ll i = 0; i < n; i++) cin >> a[i];
  memset(dp, -1, sizeof dp);
	ll ans = recurse(0, 0, 1);
	cout << ans << endl;

  return 0;
} //good night.

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  string s;
  cin >> s;
  if (s == "Sunny")
    cout << "Cloudy";
  else if (s == "Cloudy")
    cout << "Rainy";
  else
    cout << "Sunny";
}


Measured memory_bytes: 3600
{-# LANGUAGE BangPatterns, OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BS

main = do
    [n,a,b] <- map ((read :: String -> Int) . BS.unpack) . BS.words <$> BS.getLine
    let q = n `div` (a+b)
    let r = n `mod` (a+b)
    print $ q*a + min a r

Measured memory_bytes: 508
def make_divisor(n):
    divisor = set([1, n])
    i = 2
    while i * i <= n:
        q, r = divmod(n, i)
        if r == 0:
            divisor.add(i)
            divisor.add(q)
        i += 1
    return sorted(list(divisor))


n, m = [int(v) for v in input().split()]
divisors = make_divisor(m)

ans = 1
maxv = m // n
for v in divisors:
    if v <= maxv:
        ans = v
    else:
        break

print(ans)

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

using namespace std;

inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}

const int maxn = 100 + 15;
const int Maxsz = 2e7;
const int inf = 1e9 + 7;

int Prime[Maxsz + 1] , Primelen , Vis[Maxsz + 1] , Pf[Maxsz + 1] , Have[Maxsz + 5] , n , Used[maxn << 1] , Link[maxn];
vector < int > odd , even , Edge[maxn << 1];


void Init(){
	for(int i = 2 ; i <= Maxsz ; ++ i){
		if( !Vis[i] )
			Prime[Primelen ++] = i;
		for(int j = 0 ; j < Primelen && Prime[j] * i <= Maxsz ; ++ j){
			Vis[i * Prime[j]] = 1;
			if( i % Prime[j] == 0 ) break;
		}
	}
}

bool Dfs( int x ){
	for(auto && v : Edge[x]){
		if( Used[v] ) continue;
		Used[v] = 1;
		if( Link[v] == -1 || Dfs( Link[v] ) ){
			Link[v] = x;
			return true;
		}
	}
	return false;
}

int main( int argc , char * argv[] ){
	Init();
	n = read();
	for(int i = 1 ; i <= n ; ++ i){
		int x = read();
		Have[x] = 1;
	}
	for(int i = 1 ; i <= Maxsz ; ++ i){
		if( Have[i] ^ Have[i - 1] ){
			if( i & 1 ) odd.emplace_back( i );
			else even.emplace_back( i );
		} 
	}
	Vis[1] = 1;
	for(int i = 0 ; i < odd.size() ; ++ i)
		for(int j = 0 ; j < even.size() ; ++ j)
			if( ( abs( odd[i] - even[j] ) & 1 ) && Vis[ abs( odd[i] - even[j] ) ] == 0 )
				Edge[i].emplace_back( j );
	memset( Link , -1 , sizeof( Link ) );
	int K = 0;
	for(int i = 0 ; i < odd.size() ; ++ i){
		memset( Used , 0 , sizeof( Used ) );
		K += Dfs( i );
	}
	int ret = K + ( ( odd.size() - K ) / 2 + ( even.size() - K ) / 2 ) * 2 + ( odd.size() - K ) % 2 * 3;
	printf( "%d\n" , ret );
	return 0;
}

Measured memory_bytes: 123136
#include <stdio.h>

int main(){
	int a[100][100];
	int b[100];
	int n, m, i, j;
	
	scanf("%d %d", &n, &m);
	
	for( i = 0; i<n; i++){
		for( j = 0; j<m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	
	for( i = 0; i<m; i++)
{
	scanf("%d", &b[i]);
	}
int c[100] = {0};

for( i = 0; i<n; i++)
{
 for( j = 0; j<m; j++){
	c[i] += a[i][j]*b[j];
  
}	
}

for( i = 0; i<n; i++){
  printf("%d\n", c[i]);
}
	return 0;	
} 


Measured memory_bytes: 2772