akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
    char a [10];
    scanf("%s",a);
    if(a[1]==a[2]&&(a[1]==a[0]||a[2]==a[3]))
    printf("Yes");
    else 
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int inf=(1<<21);

int main()
{
  int i,j;
  int n;
  int k,c,u,o,l;
  int A[100][100],d[100],v[100];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      if(i==0) d[i]=0;
      else d[i]=inf;
      v[i]=0;
      for(j=0;j<n;j++)
	{
	  A[i][j]=inf;
	}
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&u,&k);
      for(j=0;j<k;j++)
	{
	  scanf("%d%d",&o,&c);
	  A[u][o]=c;
	}
    }
 
  while(1)
    {
      l=inf;
      u=-1;
      for(i=0;i<n;i++)
	{
	  if(l>d[i]&&!v[i])
	    {
	      u=i;
	      l=d[i];
	    }
	}
      if(u==-1) break;
      v[u]=1;
      for(i=0;i<n;i++)
	{
	  if(!v[i] && A[u][i]!=inf)
	    {
	      if(d[i]>d[u]+A[u][i])
		{
		  d[i]=d[u]+A[u][i];
		}
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      printf("%d %d\n",i,(d[i]==inf?-1:d[i]));
    }
  return 0;
}




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

#define ALL(a) (a).begin(), (a).end()

using namespace std;

signed main(){
	while(true) {
		int n; cin >> n;
		if(n == 0) break;
		int k; cin >> k;
		vector<int> arr(k);
		for(auto &&e : arr) cin >> e;
		sort(ALL(arr));
		int ans = 0;
		if(arr[0] == 0) {
			int acc = 1;
			int prev = 0;
			for(size_t i = 2; i < k; i++) {
				switch(arr[i] - arr[i-1]) {
					case 1:
						acc += 1;
						break;
					case 2:
						ans = max(ans, acc + prev + 1);
						prev = acc;
						acc = 1;
						break;
					default:
						ans = max(ans, acc + prev + 1);
						acc = 1;
						prev = 0;
						break;
				}
			}
			ans = max(ans, acc + prev + 1);
		} else {
			int acc = 1;
			for(size_t i = 1; i < k; i++) {
				if(arr[i] - arr[i-1] == 1) {
					acc += 1;
				} else {
					ans = max(ans, acc);
					acc = 1;
				}
			}
			ans = max(ans, acc);
		}
		cout << ans << "\n";
	}
	return 0;
}




Measured memory_bytes: 3020
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
using namespace std;

const int INF = 1e9;

struct edge {int to, cap, cost, rev;};

int V;
const int MAX_V = 3010;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

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

int min_cost_flow(int s, int t, int f){
  int res = 0;
  fill(h, h+V, 0);
  while(f > 0){
    priority_queue< pair<int,int>, vector< pair<int,int> >, greater< pair<int,int> > > que;
    fill(dist, dist+V, INF);
    dist[s] = 0;
    que.emplace(0, s);
    while(!que.empty()){
      pair<int,int> p = que.top();
      que.pop();
      int v = p.second;
      if(dist[v] < p.first) continue;
      for(int i = 0; i < G[v].size(); ++i){
        edge &e = G[v][i];
        if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          que.emplace(dist[e.to], e.to);
        }
      }
    }
    if(dist[t] == INF) return -1;
    for(int v = 0; v < V; ++v) h[v] += dist[v];
    int d = f;
    for(int v = t; v != s; v = prevv[v]){
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d*h[t];
    for(int v = t; v != s; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main(){
  int V_;
  cin >> V_;
  map<int, int> M;
  vector<int> A(V_), B(V_);
  M[0] = 1;
  int S = 0;
  for(int i = 0; i < V_; ++i){
    cin >> A[i] >> B[i];
    S += A[i] + B[i];
    M[A[i]] = 1;
    M[B[i]] = 1;
  }
  
  int k = V_;
  for(auto itr = M.begin(); itr != M.end(); ++itr){
    itr->second = k;
    ++k;
  }
  
  int s = V_ + M.size(), t = s + 1;

  for(int i = 0; i < V_; ++i){
    add_edge(i, M[A[i]], 1, A[i]);
    add_edge(i, M[B[i]], 1, B[i]);
    add_edge(i, M[0], 1, A[i] + B[i]);
    add_edge(s, i, 1, 0);
  }
  V = t+1;
  add_edge(V_, t, V_, 0);
  for(int i = V_+1; i < s; ++i) add_edge(i, t, 1, 0);

  cout << S - min_cost_flow(s, t, V_) << endl;
  
  return 0;
}





Measured memory_bytes: 3664
N = int(input())
A = list(map(int, input().split()))
L = [0]
for i in range(N-1):
  if A[i] != A[i+1]:
    L.append(i+1)
L.append(N)
S = 0
for i in range(len(L)-1):
  S += (L[i+1] - L[i]) // 2
print(S)

Measured memory_bytes: 3060
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;

int n;
vector<int> e(110, 0); //各素因数の指数を格納 prime^e

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

	cin >> n;

	

	//n!を素因数分解
	//1~nまでを素因数分解して合算
	FOR(num, 2, n+1) {
		
		int tmp = num; //tmpに2~nを格納
		
		FOR(prime, 2, num + 1) {
			//num = prime1^e1 * prime2^e2 * prime3^e3...
			while (tmp % prime == 0) {
				e[prime] += 1;
				tmp /= prime;
			}
		}

	}

	//cout << "e:" << endl;
	//FOR(i, 0, n+1) cout << e[i] << endl;
	//cout << endl;

	//約数75個の時、考えられるnumは
	//a4b4c2、a14b4、a24b2、a74のみ
	int cnt = 0;

	//a74の時
	FOR(i, 2, n + 1) if (e[i] >= 74) cnt++;

	//a24b2の時
	FOR(i, 2, n + 1) FOR(j, 2, n + 1) {
		if (i != j && e[i] >= 24 && e[j] >= 2) cnt++;
	}
	
	//a14b4の時
	FOR(i, 2, n + 1) FOR(j, 2, n + 1) {
		if (i != j && e[i] >= 14 && e[j] >= 4) cnt++;
	}
	
	//a4b4c2の時
	//bはaとかぶらないように注意
	FOR(i, 2, n + 1) FOR(j, i+1, n + 1) FOR(k, 0, n+1) {
		if (i != j && j != k && k != i && e[i] >= 4 && e[j] >= 4 && e[k] >= 2) cnt++;
	}
	
	cout << cnt << endl;

}

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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB emplace_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)





//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,0,1,-1,1,-1,0,1};
//int dy[]= {1,1,1,0,0,-1,-1,-1};




char s[500005];
int n,cnt[27][500005];

void update(int i,int j,int x)
{
    while(j <= n)
    {
        cnt[i][j]+=x;
        j+=(j & (-j));
    }
}

int getSum(int i,int j)
{
    int sum=0;
    while(j > 0)
    {
        sum+=cnt[i][j];
        j-=(j & (-j));
    }
    return sum;
}

int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,q,x,y,ans;
    string s1;
    cin >> n >> s+1;
    for(i=1;i<=n;i++)update(s[i]-'a'+1,i,1);
    cin >> q;
    while(q--)
    {
        cin >> x;
        if(x == 1)
        {
            cin >> x >> s1;
            update(s[x]-'a'+1,x,-1);
            update(s1[0]-'a'+1,x,1);
            s[x]=s1[0];
        }
        else
        {
            ans=0;
            cin >> x >> y;
            for(i=1;i<27;i++)ans+=((getSum(i,y)-getSum(i,x-1)) > 0);
            cout << ans << '\n';
        }
    }
    return 0;
}


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

int main() {
	int N;
	cin >> N;

	int* X = new int[N+1];
	int Max = 0;
	int Min ;
	for (int i = 1; i <= N; i++) {
		cin >> X[i];
		if (X[i] > Max) {
			Max = X[i];
		}
		if (i == 1) {
			Min = X[i];
		}

		if (X[i] < Min) {
			Min = X[i];
		}
	}

	

	int P = 0;
	int T = 0;
	int *S = new int[N+1];	//総和

	for (int i=Min; i <= Max; i++) {	//iが集会の座標
		for (int j = 1; j <= N; j++) {	//	jが探査している座標
			if (j == 1) {
				S[i] = 0;
			}
			T = X[j] - i;
			S[i] += (T * T);
		}
	}

	P = S[Min];

	for (int i = Min; i <= Max; i++) {
		if (P > S[i]) {
			P = S[i];
		}
	}

	cout << P;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    private static final double ninf = -1e18;

    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();

            int[] a = new int[M];
            int[] b = new int[M];
            int[] c = new int[M];
            for (int i = 0; i < M; i++) {
                a[i] = in.nextInt() - 1;
                b[i] = in.nextInt() - 1;
                c[i] = in.nextInt();
            }

            ArrayList<Edge>[] edges = new ArrayList[N];
            for (int i = 0; i < edges.length; i++) {
                edges[i] = new ArrayList<>();
            }
            for (int i = 0; i < M; i++) {
                edges[a[i]].add(new Edge(b[i], c[i]));
            }

            ArrayList<Edge>[] reverseEdges = new ArrayList[N];
            for (int i = 0; i < reverseEdges.length; i++) {
                reverseEdges[i] = new ArrayList<>();
            }
            for (int i = 0; i < M; i++) {
                reverseEdges[b[i]].add(new Edge(a[i], c[i]));
            }

            PriorityQueue<State> pq = new PriorityQueue<>();
            long[] max = new long[N];
            for (int i = 0; i < max.length; i++) {
                max[i] = (long) ninf;
            }
            {
                State e = new State();
                e.index = N - 1;
                e.score = 0;
                pq.add(e);
                max[e.index] = e.score;
            }

            int countPoll = 0;
            for (; !pq.isEmpty();) {
                State current = pq.poll();
                countPoll++;

                if (countPoll >= 2100) {
                    // if (current.index == 0) {
                    System.out.println("inf");
                    return;
                    // }
                    // continue;
                }

                for (Edge edge : reverseEdges[current.index]) {
                    State next = new State();
                    next.index = edge.index;
                    next.score = current.score + edge.score;

                    if (next.score <= max[next.index]) {
                        continue;
                    }

                    // if (max[next.index] > ninf) {
                    // System.out.println("inf");
                    // return;
                    // }

                    max[next.index] = next.score;
                    pq.add(next);
                }

            }

            System.out.println(max[0]);

        }
    }
}

class State implements Comparable<State> {

    public int index;
    public long score;

    @Override
    public int compareTo(State o) {
        if (score > o.score) {
            return -1;
        }
        if (score < o.score) {
            return 1;
        }
        return 0;
    }

}

class Edge {
    int index;
    int score;

    public Edge(int index, int score) {
        super();
        this.index = index;
        this.score = score;
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  vector<int> cnt(n, 0);
  for (int i = 1; i < n; i++) {
    if (h[i - 1] >= h[i]) {
      cnt[i] = cnt[i - 1] + 1;
    }
  }
  sort(cnt.begin(), cnt.end());
  cout << cnt[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 4028
import numpy as np
import math
stdin = open(0)

N,K = map(int,input().split())
A = np.array([int(Ai) for Ai in input().split()])
A = np.sort(A)

maxA = max(np.abs(A))

z = A[A==0]
p = A[A>0]
n = A[A<0]

def check(x):
    ret = 0
    if x >= 0:
        ret += N*len(z)
    ret += np.searchsorted(A,x//p,side='right').sum()
    ret += (N - np.searchsorted(A, (-x - 1) // (-n), side='right')).sum()
#     ret += (N-np.searchsorted(A,np.ceil(x/n))).sum()
    ret -= np.count_nonzero(A*A<=x)
    return ret//2;

ub = maxA*maxA
lb = -ub-1
while ub-lb > 1:
    mid = (ub+lb)>>1
    if check(mid) < K:
        lb = mid
    else:
        ub = mid
print(ub)

Measured memory_bytes: 32324
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
int mod=1e9+7;
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}


signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 int n;
 cin>>n;

 int x=26;
 int ct=1;
 while(x<n)
 {
    n-=x;
    x*=26;
    ct++;
 }

 //cout<<n<<endl;

 x/=26;

 //cout<<x<<endl;
 int y=0;
 vector<char> s;
 while(n>0&&x>0)
 {
    y++;
    //cout<<n<<" "<<x<<endl;
    cout<<char('a'-1+ceil(n/(1.0*x)));
    n-=(n/x)*x;
    x/=26;
 }
 while(y<ct)
 {
    cout<<'z';
    y++;
 }

 for(auto i:s)
 cout<<i;


}

Measured memory_bytes: 3608
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
800
15 200
 */
int x;

int main(){
  cin>>x;
  cout<< x*800 - (x/15)*200 << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io;


fn main() {
    let (n, a, b, c, d) = {
        let i = read::<isize>();
        (i[0], i[1], i[2], i[3], i[4])
    };

    let mut flg = false;
    for i in 0..n {
        let lower = a + i * c - (n - 1 - i) * d;
        let upper = a + i * d - (n - 1 - i) * c;
        if lower <= b && b <= upper { flg = true; }
    }

    if flg { println!("YES"); }
    else { println!("NO"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  for(i=1;i<s.size();i++){
    if(s[i-1]==s[i]){
      cnt++;
      i+=2;
    }
  }
  cout<<s.size()-cnt;
}

Measured memory_bytes: 644
#include <stdio.h>
#include <string.h>
#include <math.h>

#define max 2

int* sortMaxmin(int*, int);
int* sortMinmax(int*, int);

int main()
{
    int n, x, i;
    
    scanf("%d", &n);
    
    for (i=1; i<=50000; i++) {
        x=i*1.08;
        if(x==n){
            printf("%d", i);
        return 0;
        }
    }
    
    printf(":(");
    
    return 0;
}

int* sortMaxmin(int *a, int b)
{
    int i, j, tmp;
    for(i=0; i<b; i++){
        for (j=i+1; j<b; j++) {
            if(a[i]>a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    return a;
}

int* sortMinmax(int *a, int b)
{
    int i, j, tmp;
    for(i=0; i<b; i++){
        for (j=i+1; j<b; j++) {
            if(a[i]<a[j]){
                tmp=a[i];
                a[i]=a[j];
                a[j]=tmp;
            }
        }
    }
    return a;
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s,p;
    cin >> s >> p;
    int i,j,n,m;
    n=s.length();
    m=p.length();
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            if(s.at((i+j)%n)!=p.at(j))break;
            if(j==m-1) j++;
       }
        if(j==m+1) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>

int main() {
  int all;
  std::cin >> all;
  int h = all / 3600;
  all -= h * 3600;
  int m = all / 60;
  all -= m * 60;
  int s = all;
  std::cout << h << ":" << m << ":" << s << std::endl;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll k, n;
	cin >> k >> n;
	vll v(n);
	ll ans = 0;
	for(int i = 0; i < n; i++)
		cin >> v[i];
	for(int i = 0; i < n; i++){
		if(i > 0)
			ans = max(ans, v[i] - v[i - 1]);
		else
			ans = max(ans, k - v[n - 1] + v[0]);
	}
	cout << k - ans << endl;
}

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

int main()
{
    string s;
    cin >> s;
    if((int)s.size() < 4){
        cout << "No" << endl;
        return 0;
    }
    s = s.substr(0, 4);
    if(s == "YAKI") cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

    vector<int> takoyakiList;

    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        takoyakiList.push_back(input);
    }

    int sum = 0;

    for (int x = 0; x < takoyakiList.size(); x++)
    {
        for (int y = 0; y < x; y++)
        {
            if (x != y)
            {
                sum += takoyakiList.at(x) * takoyakiList.at(y);
            }
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,-1,0,1},dy={1,0,-1,0};



int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> w(n);
	rep(i,n) cin >> w.at(i);
	int ans=1000000000;
	for(int i=1;i<n;++i){
		int sum1=0,sum2=0;
		rep(j,i) sum1+=w.at(j);
		for(int j=i;j<n;++j) sum2+=w.at(j);
		ans=min(ans,abs(sum1-sum2));
	}
	cout << ans << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x"=" << x <<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3

#define MAX_N 1000000001

int main(){
	cin.sync_with_stdio(false);
	string s;
	cin >> s;

	int b = -1, e = -1;
	rep(i, s.length() - 2) {
		if (s[i] == s[i + 1]) {
			b = i + 1;
			e = i + 2;
			break;
		} else if (s[i] == s[i + 2]) {
			b = i + 1;
			e = i + 3;
			break;
		}
	}
	if (s[s.length() - 2] == s[s.length() - 1]) {
		b = s.length() - 1;
		e = s.length();
	}

	cout << b << " " << e << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int n;
    string s,t = "";
    vector<int> ans(26,50);
    cin >> n;
    rep0(i, n){
        cin >> s;
        vector<int> cnt(26,0);
        rep0(i, s.size()){
            ++cnt[s[i] - 'a'];
        }
        rep0(i, 26){
            ans[i] = min(ans[i], cnt[i]);
        }
    }
    rep0(i, 26){
        rep0(j, ans[i]){
            t += (char)(i + 'a');
        }
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){

  int n;
  cin >> n;
  vector<int> d(n);
  REP(i,n) cin >> d[i];

  sort(ALL(d));

  int l = d[n/2 -1];
  int r = d[n/2];

  if(l == r) cout << 0 << endl;
  else{
    cout << r -l << endl;
  }

  return 0;
}

Measured memory_bytes: 3788
# one -> four
# two -> two, four
# four -> one, two, four

n = int(input())
one = 0
two = 0
four = 0

for a in map(int,input().split()):
    if a%2 != 0: one+= 1
    elif a%4 != 0: two+= 1
    else: four+= 1

def no():
    print("No")
    exit()

if two == 0:
    #1414141
    print("Yes" if four >= one-1 else "No")
else:
    #222222241414141
    print("Yes" if four >= one else "No")

Measured memory_bytes: 11480
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {

	int n, T;
	bool flag = false;
	int min = 10000;
	int c[110], t[110];
	cin >> n >> T;
	for (int i = 0; i < n; i++) {
		cin >> c[i] >> t[i];
		if (min > c[i] && t[i] <= T) {
			min = c[i];
			flag = true;
		}
	}
	if (flag)
		cout << min << endl;
	else
		cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 256
MAX = 500000
H = None

def parent(i):
    return i//2


def left(i):
    return 2*i


def right(i):
    return 2*i+1


def max_heapify(A, i):
    l = left(i)
    r = right(i)

    if l <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    
    if r <= H and A[r] > A[largest]:
        largest = r
    
    if largest != i:
        A[largest], A[i] = A[i], A[largest]
        max_heapify(A, largest)


def build_max_heap(A):
    for i in range(H//2, 0, -1):
        max_heapify(A, i)


def main():
    global H
    H = int(input())
    A = [0] * (MAX+1)

    v_s = input().split(' ')

    for i in range(H):
        A[i+1] = int(v_s[i])

    build_max_heap(A)

    print(' ' + ' '.join(map(str, A[1:H+1])))


if __name__ == '__main__':
    main()



Measured memory_bytes: 99336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


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

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

int main(){
  string s;
  cin>>s;
  ll ans=0;
  for(ll i=0;i<4;i++){
    if(s[i]=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}


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

typedef long long int ll;

int main(){
  ll k,n;
  cin>>k>>n;
  vector <ll> a(n);
  ll i;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  vector <ll> dist;
  for(i=1;i<n;i++){
    dist.push_back(a[i]-a[i-1]);
  }
  dist.push_back(k+a[0]-a[n-1]);
  sort(dist.begin(),dist.end());
  ll sum=0;
  for(i=0;i<dist.size()-1;i++){
    sum+=dist[i];
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <utility>
#define inf 1e9

using namespace std;

int n;
string s, t;
int l[2005], r[2005];
int R[2005];

int main(void)
{
	cin >> s >> t;
	n = s.size();
	
	bool flag = false;
	for(int i = 0; i < n; i++){
		if(t[i] == '1'){
			flag = true;
			break;
		}
	}
	if(!flag){
		if(s == t) cout << 0 << endl;
		else cout << -1 << endl;
		return 0;
	}
	
	string t3 = t + t + t;
	int cnt = 0;
	for(int i = 0; i < 3*n; i++){
		if(t3[i] == '1') cnt = 0;
		else cnt++;
		if(i >= n && i < 2*n) l[i-n] = cnt;
	}
	cnt = 0;
	for(int i = 3*n-1; i >= 0; i--){
		if(t3[i] == '1') cnt = 0;
		else cnt++;
		if(i >= n && i < 2*n) r[i-n] = cnt;
	}
	
	int ans = inf;
	for(int i = 0; i < n; i++){
		string tmp = (s+s).substr(i, n);
		int cnt = 0;
		for(int j = 0; j < n; j++) if(tmp[j] != t[j]) cnt++;
		for(int j = 0; j <= n; j++) R[j] = 0;
		for(int j = 0; j < n; j++){
			if(tmp[j] == '1' && t[j] == '0') R[l[(j+i)%n]] = max(R[l[(j+i)%n]], r[(j+i)%n]);
		}
		int mx = 0;
		for(int j = n; j >= 0; j--){
			int tmp = R[j];
			R[j] = mx;
			mx = max(mx, tmp);
		}
		int mn = inf;
		for(int j = 0; j <= n; j++){
			mn = min(mn, 2*j + R[j] + min((i+R[j])%n, n - (i+R[j])%n));
			mn = min(mn, 2*R[j] + j + min((i-j+n)%n, n - (i-j+n)%n));
		}
		ans = min(ans, mn + cnt);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 998244353;
const int N = 100000 + 7;

ll n,m,x,t,sum,allDis;
vector<int>dis;
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&x);
        sum+=x;
        while(x)
        {
          t=x/2;
          dis.push_back(x-t);
          x/=2;
        }
    }
    sort(dis.rbegin(),dis.rend());
    for(int i=0;i<m&&i<dis.size();i++)
        allDis+=dis[i];
    printf("%lld\n",max(0LL,sum-allDis));
    return 0;
}


Measured memory_bytes: 18792
import java.io.*;

class Main{
public static void main(String[] args)
			throws java.io.IOException{
		reverse();

		// TODO 自動生成されたメソッド・スタブ
		
	}
	
	public static void reverse()throws IOException{
		BufferedReader input =
	            new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine();
		String[] strs =str.split("\\B"); //文字列を文字単位に分割
		String restr="";

		for(int i=(strs.length) - 1;i>=0;i--){
			restr+=strs[i]; //逆順に再結合
		}
		System.out.println( restr);

	}}

Measured memory_bytes: 8940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

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;
}
//using P = pair<int,int>;
//pow(x,n)
//cout << fixed << setprecision(桁数);
//string = to_string(数値)
//int = stoi(文字列)
//(int)(char-'0')
//string = itoa(int)
//円周率: M_PI


int main() {
    string s,t; cin>>s>>t;

    rep(i,s.size()){
        if(s[i]==t[i]) continue;
        else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define foi(i,k,n) for (int i = (int)k; i < (int)n; ++i)

using namespace std;
using ii = pair<int,int>;
using ll = long long;

constexpr int MAXN = 5 + 200000;

int arr[MAXN];

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int k,n; cin >> k >> n;
  foi (i,0,n) cin >> arr[i];
  int ans = k;
  foi (i,1,n) {
    ans = min(ans, k - (arr[i] - arr[i-1]));
  }
  ans = min(ans, abs(arr[n-1]-arr[0]));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
N,K=map(int,input().split())
mod=1000000007
path=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a=a-1
  b=b-1
  path[a].append(b)
  path[b].append(a)
#print(path)
  
abc=[False for i in range(N)] #0ならまだ塗ってない
 
abc[0]=True
cnt=0
ans=K%mod
nx=[]
for i in range(len(path[0])):
  child=path[0][i]
  if abc[child]:
    continue
  ans=ans*(K-1-cnt)
  ans=ans%mod
  cnt=cnt+1
  abc[child]=True
  nx.append(child)
while len(nx)>0:
  a=nx.pop()
  cnt=0
  for i in range(len(path[a])):
    child=path[a][i]
    if abc[child]:
      continue
    ans=ans*(K-2-cnt)
    ans=ans%mod
    cnt=cnt+1
    abc[child]=True
    nx.append(child)
      
print(ans%mod)

Measured memory_bytes: 23660
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    char a,b;
    cin>>a>>b;
    if(a-'A'<b-'A')cout<<"<";
    else if(a==b)cout<<"=";
    else cout<<">";
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int b[n];
    int a[n];
    int ans=0;
    for(int i=0;i<n-1;i++){
        cin>>b[i];
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    for(int i=1;i<n-1;i++){
        a[i]=min(b[i-1],b[i]);
    }
    for(int i=0;i<n;i++){
        ans+=a[i];
    }
    cout << ans<<endl;
    return 0;
}



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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ReadLine();

            var h = new HashSet<char>();

            bool isYes = true;
            for (int i = 0; i < s.Length; i++)
            {
                if (!h.Add(s[i]))
                {
                    isYes = false;
                }
            }
            WriteLine(isYes ? "yes" : "no");
        }

        static int InputNum()
        {
            return int.Parse(ReadLine());
        }
        static List<int> InputNumList()
        {
            return ReadLine().Split(' ').Select(int.Parse).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"

using namespace std;
using ll = long long;

int z;

int main() {

	int a, b;
	char s[60][60];
	int cnt = 0;
	
	cin >> a >> b;

	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cin >> s[i][j];
		}
	}
	
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			if (s[i][j] == '.') {
				if (s[i - 1][j] == '#')cnt++;
				if (s[i - 1][j - 1] == '#')cnt++;
				if (s[i][j - 1] == '#')cnt++;
				if (s[i + 1][j] == '#')cnt++;
				if (s[i + 1][j + 1] == '#')cnt++;
				if (s[i][j + 1] == '#')cnt++;
				if (s[i - 1][j + 1] == '#')cnt++;
				if (s[i + 1][j - 1] == '#')cnt++;
				s[i][j] = '0'+cnt;
			}
			cnt = 0;
		}
	}

	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			cout << s[i][j];
		}
		cout << endl;
	}

	

	cin >> z;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
using ll=long long;

const ll INF = pow(10,18)+1;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}
template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}
 
int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    string res = "";
    REP(i,N){
        if(S.substr(i,1)!=S.substr(K-1,1)) res += "*";
        else res += S.substr(i,1);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

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

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


class UnionFind{

private:
    vector<int> rank,p;

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

  public:
      UnionFind(){};
      UnionFind(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i = 0; i < size; i++){
          makeSet(i);
        }
      }

    bool same(int x, int y){
      return  find(x) == find(y);
    }

    void unite(int x, int y){
      link(find(x), find(y));
    }

    int find(int x){
      if(x != p[x]) p[x] = find(p[x]);
      return p[x];
    }

private:
    void link(int x, int y){
      if(rank[x] > rank[y]){
        p[y] = x;
      }else{
        p[x] = y;
        if(rank[x] == rank[y]) rank[y]++;
      }
    }

};

signed main(void) {
    int n,m;
    cin >> n >> m;

    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        uf.unite(a,b);
    }
    vi a(n);
    rep(i,n)a[uf.find(i)]++;
    //rep(i,n)cout << " " << a[i];cout << endl;
    int s = 0, t = 0;
    rep(i,n){
        if(a[i] == 1)s++;
        if(a[i] > 1)t++;
    }
    cout << abs(s-t) << endl;

}



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

vector<ll> G[100000];
ll color[100000];
ll isolated[100000];

void dfs(ll v) {
  color[v] = 0;
  for (ll i = 0; i < G[v].size(); i++) {
    ll to = G[v][i];
    if (color[to] == 1) {dfs(to);}
  }
}

 

int main() {
  ll N, M;
  cin >> N >> M;
  for (ll i = 0; i < M; i++) {
    ll x, y, z; cin >> x >> y >> z; x--; y--;
    G[x].push_back(y); G[y].push_back(x);
  }
  
  for (ll i = 0; i < N; i++) {
    color[i] = 1;
  }
  
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    if (color[i] == 1) {
      dfs(i);
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main()
{
    int num[3];
    int seven=0, five=0;

    cin  >> num[0] >> num[1] >> num[2];

    for(int i=0;i<3;i++){
        if(num[i] == 5) five++;
        if(num[i] == 7) seven++;
    }

    if(seven == 1 && five == 2){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << 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 INF 1<<30
#define LINF 1LL<<60

//const ll MOD=1e9+7;
//ll powmod(ll x, ll n, ll mod) {
//    ll res = 1;
//    while (n > 0) {
//        if (n & 1) { //?\???°??????
//            res =(res*x)%mod;
//        }
//        x = (x*x)%mod;
//        n >>= 1;
//    }
//    return res;
//}

const ll MOD = 1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}


int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll m,n; cin >> m >> n;
    cout << powmod(m,n) << endl;
    return 0;
}

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

int main(){
	while(true){
		int n,sum=0;
		list<int> score; 
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			int tmp;
			cin>>tmp;
			score.push_back(tmp);
		}
		score.sort();
		score.pop_back();
		score.pop_front();
		for(list<int>::iterator it=score.begin();it!=score.end();++it)sum+=*it;
		cout<<sum/(n-2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;


public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] c = new int[n];
        int[] s = new int[n];
        int[] f = new int[n];
        
        for (int i = 0; i < n-1; i++) {
            String[] line = br.readLine().split(" ");
            c[i+1] = Integer.parseInt(line[0]);
            s[i+1] = Integer.parseInt(line[1]);
            f[i+1] = Integer.parseInt(line[2]);
        }
        
        int ans = 0;
        for (int i = 1; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (ans <= s[j]) {
                    ans += s[j] - ans;
                }
                else if ((ans - s[j]) % f[j] == 0) {
                    
                }
                else {
                    ans += f[j] - ((ans - s[j])%f[j]);
                }
                ans += c[j];
            }
            System.out.println(ans);
            ans = 0;
        }
        System.out.println(0);
    }
}





Measured memory_bytes: 23380
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
const int MOD=1e9+7;
const double eps=1e-8;
typedef long long ll;
//orz yht
using namespace std;
int n,mx=-INF;
string s;
map<string,int> m;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		it->second=0;
	}
	for(int i=1;i<=n;i++){
		cin>>s;
		m[s]++;
	}
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		mx=max(mx,it->second);
	}
	for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
		if(mx==it->second){
			cout<<it->first<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <set>
#include <algorithm>

using namespace std;

array<array<bool, 31>, 50> g_schedule;

array<array<set<int>, 31>, 50> g_map; //[50][30]

int g_n;

int solution() {
	for (int i = 1; i <= 30; ++i) {
		vector<int> ables;
		for (int j = 0; j < g_n; ++j) {
			if (g_schedule[j][i]) ables.push_back(j);
			else g_map[j][i] = g_map[j][i - 1];
		}

		set<int> gathers;
		for (auto able = ables.begin(); able != ables.end(); ++able) {
			for (auto it = g_map[*able][i - 1].begin(); it != g_map[*able][i - 1].end(); ++it) {
				gathers.insert(*it);
			}
		}
		for (auto it = ables.begin(); it != ables.end(); ++it) {
			g_map[*it][i] = gathers;
		}

		for (int j = 0; j < g_n; ++j) {
			if (g_map[j][i].size() == g_n) return i;
		}
	}

	return -1;
}

int main() {
	while (true) {
		cin >> g_n;
		if (g_n == 0) break;
		for (int i = 0; i < g_n; ++i) {
			g_map[i][0].clear();
			g_map[i][0].insert(i);
		}

		for_each(g_schedule.begin(), g_schedule.end(), [](array<bool, 31> & line) {
			line.fill(false);
		});
		for (int i = 0; i < g_n; ++i) {
			int f;
			cin >> f;
			for (int j = 0; j < f; ++j) {
				int day;
				cin >> day;
				g_schedule[i][day] = true;
			}
		}

		cout << solution() << endl;
	}

}

Measured memory_bytes: 4672
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
ans,j=0,M
for i in range(N+1):
  if a[i]>K:
    break
  while b[j]>K-a[i]:
    j-=1
  ans=max(ans,i+j)
print(ans)


Measured memory_bytes: 47588
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

// ºÊ10rbgÌÅCÅºÊÌ0ÌÊu
inline int getmin(int bit)
{
	return __builtin_ctz(~bit);
}
// ºÊ10rbgÌÅCÅãÊÌ0ÌÊu
inline int getmax(int bit)
{
	return 31-__builtin_clz(~bit&1023);
}

int solve(int* c,int* z,int M,int sum,int bit)
{
	int depth=__builtin_popcount(bit);
	if(depth==M)
		return sum==0;
	
	// } è
	if(sum>0){
		int s=sum,b=bit;
		for(int i=depth;i<M;i++){
			int j=c[i]>0?getmin(b):getmax(b);
			b|=1<<j;
			s+=c[i]*j;
		}
		if(s>0)
			return 0;
	}
	if(sum<0){
		int s=sum,b=bit;
		for(int i=depth;i<M;i++){
			int j=c[i]>0?getmax(b):getmin(b);
			b|=1<<j;
			s+=c[i]*j;
		}
		if(s<0)
			return 0;
	}
	
	int res=0;
	for(int i=z[depth];i<10;i++){
		if(bit&1<<i) continue;
		res+=solve(c,z,M,sum+c[depth]*i,bit|1<<i);
	}
	return res;
}

int main()
{
	int d[9]={1};
	for(int i=1;i<9;i++)
		d[i]=d[i-1]*10;
	
	for(int N;scanf("%d ",&N),N;){
		string n[12];
		for(int i=0;i<N;i++){
			char buf[10]; fgets(buf,sizeof buf,stdin);
			n[i]=string(buf,strchr(buf,'\n'));
		}
		
		map<char,int> m;
		for(int i=0;i<N;i++)
			for(int j=0;j<n[i].size();j++)
				if(m.find(n[i][j])==m.end())
					m.insert(make_pair(n[i][j],m.size()));
		int M=m.size();
		
		int c[10]={},z[10]={}; // c:W, z:0ðèÄÄæ¢©Ç¤©
		for(int i=0;i<N;i++){
			if(n[i].size()>1)
				z[m[n[i][0]]]=1;
			reverse(n[i].begin(),n[i].end());
			for(int j=0;j<n[i].size();j++)
				c[m[n[i][j]]]+=i==N-1?-d[j]:d[j];
		}
		
		// WÌâÎlÌ~Å\[g
		for(int i=0;i<M;i++)
			for(int j=M-1;j>i;j--)
				if(abs(c[j-1])<abs(c[j])){
					swap(c[j-1],c[j]);
					swap(z[j-1],z[j]);
				}
		
		printf("%d\n",solve(c,z,M,0,0));
	}
	
	return 0;
}

Measured memory_bytes: 840
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
	int n, m;
	cin >> n >> m;
	cout << ((n - m) * 100 + m * 1900) * (int)pow(2, m) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int result = 0;
		for (int i = 0; i < 2; i++) {
			if (a == b || a > b) {
				result += a;
				a--;
			} else if (a < b) {
				result += b;
				b--;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define _USE_MATH_DEFINES

int main()
{
    int n=0,best_n=0,T=0,A=0,height_i[1001]={0},temp_average=0,temp_diff_from_a=0,new_temp_diff_from_a=0;
    scanf("%d",&n);
    scanf("%d %d",&T,&A);
    for(int i=0;i<n;i++)
	scanf("%d",&height_i[i]);


    for(int i=0;i<n;i++){
	temp_average=1000*T-height_i[i]*6;
	new_temp_diff_from_a=abs(1000*A-temp_average);

	if(i==0 || new_temp_diff_from_a<temp_diff_from_a){
	    temp_diff_from_a=new_temp_diff_from_a;
	    best_n=i;
	}

    }
    printf("%d",best_n+1);
    return 0;
}



Measured memory_bytes: 128
#include "bits//stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
int V[50];
int main() {
	int N, K;
	cin >> N >> K;
	rep(i, N) {
		cin >> V[i];
	}
	ll ans = 0;
	for (int l = 0; l <= N; l++) {
		for (int r = 0; r <= N - l; r++) {
			if (l + r > K) break;
			priority_queue<ll, vector<ll>, greater<ll>> Q;
			ll sum = 0;
			rep(i, l) {
				sum += V[i];
				if (V[i] < 0) Q.push(V[i]);
			}
			rep(i, r) {
				sum += V[N - i - 1];
				if (V[N - i - 1] < 0)  Q.push(V[N - i - 1]);
			}
			rep(i, K - (l + r)) {
				if (Q.empty()) break;
				sum -= Q.top();
				Q.pop();
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{
  int N;
  cin >>N;  
  for(int i=1 ; i<=9 ; i++){
    for(int j=1 ; j<=9 ; j++){
      if(i*j==N){cout<<"Yes"; return 0;}
    }
  }
  cout << "No";

  return 0 ;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main {
  while (true) {
    int n = in();
    if (n == 0) break;
    vector<string> s(n);
    cin >> s;
    rep(i, n) {
      int j = 0;
      while (j < s[i].size() && s[i][j] == '.') s[i][j++] = ' ';
      if (j == 0) continue;
      s[i][--j] = '+';
      int k = i - 1;
      while (k >= 0 && j < s[i].size() && s[k][j] == ' ') s[k--][j] = '|';
    }
    rep(i, n) cout << s[i] << endl;
  }
}



Measured memory_bytes: 3680