akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int maxN = 2e5+5;

void solve(){
    char C[10][10];
    char COPY[10][10];
    int h, w, k;
    cin >> h >> w >> k;
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            char c; cin >> c;
            C[i][j] = c;
        }
    }
    for(int i = 0; i < (1 << h); i++)
    for(int j = 0; j < (1 << w); j++){
        for(int p = 0; p < h; p++){
            for(int q = 0; q < w; q++){
                COPY[p][q] = C[p][q];
            }
        }
        for(int k = 0; k < h; k++){
            if(i & (1 << k)){
                for(int p = 0; p < w; p++){
                    COPY[k][p] = '.';
                }
            }
        }
        for(int k = 0; k < w; k++){
            if(j & (1 << k)){
                for(int p = 0; p < h; p++){
                    COPY[p][k] = '.';
                }
            }
        }
        int curr = 0;
        for(int p = 0; p < h; p++){
            for(int q = 0; q < w; q++){
                if(COPY[p][q] == '#') curr++;
            }
        }
        if(curr == k) ans++;
    }
    cout << ans << "\n";
}


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

    bool multitest = false;
    //multitest = true;
    if(multitest){
        int t; cin >> t;
        while(t--)
            solve();
    }
    else
        solve();
}






Measured memory_bytes: 3648
#include <stdio.h>

int main(){
	int build[4][3][10]={0};
	int  i, j, k;

	
	
	for( i = 0; i<4; i++){

		for( j = 0; j<3; j++){
		
			for(k = 0; k<10; k++){
				
			build[4][3][10] = 0;
 	        
			}
		}
	}
	int n = 0;
	scanf("%d", &n);
	while(n--)
	{
		int b, f, r, v;
		scanf("%d %d %d %d", &b, &f, &r, &v);
		build[b-1][f-1][r-1]+=v; 
	}
	for(i = 0; i<4; i++){
		for(j = 0; j<3; j++){
			for(k = 0; k<10; k++){
				printf(" %d", build[i][j][k]);
			}
			printf("\n");
		}
        if(i != 3)
		{
 	    printf("####################\n");
        }		
	}

	return 0;	
} 


Measured memory_bytes: 2732
#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, a, b;
  cin >> n >> a >> b;
  if((b-a-1)%2==0){
    cout << "Borys" << endl;
  }else{
    cout << "Alice" << endl;
  }



  return 0;
}


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

int N, K;

int main() {
    cin >> N >> K;
    vector<long long> s(N + 1, 0);
    long long a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        s[i + 1] = s[i] + a;
    }
    
    long long t, b, ans = 0;
    int cnt;
    for (int k = 0; k < 41 ; k++) {
        b = 1LL << (40 - k);
        ans += b;
        cnt = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i; j < N; j++) {
                t = s[j + 1] - s[i];
                if ((ans & t) == ans) {
                    ++cnt;
                }
            }
        }
        if (cnt < K) {
            ans -= b;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.nio.file.Path;
import java.util.*;
public class Main{
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int townx[] = new int[n];
    static int towny[] = new int[n];
    public static void main(String []args) {
        for(int i =0;i < n;i++){
            townx[i] = sc.nextInt();
            towny[i] = sc.nextInt();
        }

        int kaizyo = roop(n);
        int countpath = n-1;//一回に通る道の数        
        int allpath = n*(n-1)/2;//一つの図の道の合計数
        int gopath = countpath * kaizyo/allpath; //一つの道を通る合計数

        double pathlength[] = new double[allpath];//町間の距離を入れておく配列
        int count = 1;
        int check = 0;
        for(int j=0; j < n;j++){
            for(int k=count;k<n;k++){
                int difx = (townx[j] -townx[k])*(townx[j] -townx[k]);
                int dify = (towny[j] -towny[k])*(towny[j] -towny[k]);
                pathlength[check] = Math.sqrt(difx+dify);
                check++;
            }
            count++;
        }

        double result = 0;
        for(int m=0;m<allpath;m++){
            result += pathlength[m];
        }

        double average = result*gopath/kaizyo;

        System.out.println(average);
    }

    static int roop(int n){
        int answer = 1;
        for(int a=1;a <= n;a++){
            answer *= a;
        }
        return answer;
    }
}

Measured memory_bytes: 23636
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		int c = a * b;

		if(c % 2 == 0)
		{
			System.out.println("Even");
		}
		else
		{
			System.out.println("Odd");
		}
	}
}


Measured memory_bytes: 23892
program main
implicit none
integer :: i, j, k
integer :: n, s, nn

read(*,*) n
s = 0
nn = n
do i = 9, 0, -1
   s = s + nn/(10**i)
   nn = nn- (10**i) *(nn/(10**i))
end do
if( mod(n,s) == 0 ) then
   write(*,*) 'Yes'
else
   write(*,*) 'No'
end if

end program main


Measured memory_bytes: 256
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] l = new long[n+1];
        l[0] = -1;
        int count = 0;
        for (int i = 1;i<=n;++i) l[i] = sc.nextLong();

        for (int i = 0;i<=n-2;++i)
        {
            for (int j = i+1;j<=n-1;++j)
            {
                for (int k = j+1;k <= n;++k)
                {
                    if (l[i]+l[j] > l[k] && l[i]+l[k] > l[j] && l[j]+l[k] > l[i])
                    {
                        if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k])
                        {
                            //System.err.println(i+","+j+","+k);
                            ++count;
                        }
                    }
                }
            }
        }
        System.out.println(count);
        sc.close();
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

Measured memory_bytes: 36376
#include <stdio.h>
int main(void)
{
     
    int H, W,i,j;
    while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)
    break;
    for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            if(j%2==1){
                if(i%2==1)printf("#");
                else printf(".");
            }else{
                if(i%2==1)printf(".");
                else printf("#");
                }
            }printf("\n");
            }printf("\n");
        }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
	int l;
	cin >> l;
	vector<int>n(5);	
	for(int i = 0; i < l; i++){
		string s;
		cin >> s;
		if(s[0] == 'M'){
			n[0]++;
		}else if(s[0] == 'A'){
			n[1]++;
		}else if(s[0] == 'R'){
			n[2]++;
		}else if(s[0] == 'C'){
			n[3]++;
		}else if(s[0] == 'H'){
			n[4]++;
		}
	}

	ll ans = 0;
	for(int bit = 0; bit < (1<<5); bit++){
		int bitNum = 0;
		for(int i = 0; i < 5; i++){
			if(bit & (1 << i)) bitNum++;
		}
		if (bitNum != 3) continue;
	
		ll temp = 1;
		for(int k = 0; k < 5; k++){
			if(bit & (1 << k)){
				temp *= n[k];
			}
		}

		ans += temp;
	}

	cout << ans << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> s(100020);
	long long int sum = 0;
	priority_queue<int> q;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if (a > M) {
			continue;
		}
		s[a].push_back(b);
	}
	for (int i = 1; i <= M; i++) {
		int max = 0;
			for (int j:s[i]) {
				if (j > max) {
					q.push(max);
					max = j;
				}
				else {
					q.push(j);
				}
			}
		if (!q.empty()) {
			if (q.top() > max) {
				q.push(max);
				max = q.top();
				q.pop();
			}
		}
		sum = max + sum;
	}
	cout << sum;
}

Measured memory_bytes: 6268
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;


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

   int n;
   ll k;
   cin >> n >> k;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];

   vector<int> s;
   vector<int> ord(n + 1, -1);
   int c = 1, l = 0;
   {
      int now = 1;
      while (ord[now] == -1) {
         ord[now] = s.size();
         s.push_back(now);
         now = a[now - 1];
      }
      c = s.size() - ord[now];
      l = ord[now];
   }
   if (k < l)
      cout << s[k] << endl;
   else {
      k -= l;
      k %= c;
      cout << s[l + k] << endl;
   }
   return 0;
}

Measured memory_bytes: 5832
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


ll modInverse(ll a, ll b){
 return 1<a ? b - modInverse(b%a,a)*b/a : 1;
}

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    
    freopen("output.txt", "w", stdout);
    #endif
    
    ll n,i;
    cin>>n;
    string s = "ACL";
    string ans = "";
    for(i=0;i<n;i++){
        ans+=s;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3568
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()

if N&1:
    print(0)
    exit()

answer = N // 10
x = 50
while N >= x:
    answer += (N // x)
    x *= 5
print(answer)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
//const int N = 51;
//int q[N];
int main()
{
	int k,x;
	cin >> k >> x;
	int t = x-(k-1);
	for (int i = 0; i <= 2*k-2 ; i ++ )
	{
		if(i != 2*k-2)
		cout << t + i << " ";
		else cout << t + i;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
# include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 57;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;

void solve()
{
    string s;
    cin>>s;
    lli n;
    cin>>n;
    lli cnt = 0, cnt1 = 0;
    string temp = s;
    set<char> se;
    for(int i = 0; i < temp.size(); i ++)
        se.insert(temp[i]);
    if(se.size() == 1)
    {
        lli ans = n * temp.size();
        ans /= 2;
        cout<<ans<<endl;
        return ;
    }
    for(int i = 0; i < temp.size(); i ++)
    {
        if(temp[i] == temp[i + 1])
        {
            cnt1 ++;
            temp[i + 1] = '.';
        }
    }
    if(n == 1){
        cout<<cnt1<<endl;
        return ;
    }
    s += s;
    for(int i = 0; i < s.size(); i ++)
    {
        if(s[i] == s[i + 1])
        {
            cnt ++;
            s[i + 1] = '.';
        }
    }
    lli x = cnt - cnt1;
    lli ans = (n - 1) * x + cnt1;
    cout<<ans<<endl;
    return ;
}
/*
7
6 7 4 1 2 11 6
5
1 2 10 4 5
*/

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

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
ids = []
for i in range(n):
    ids.append(input())

m = int(input())
num = 0
for i in range(m):
    act = input()
    if act in ids:
        print("Opened by" if num % 2 == 0 else "Closed by", act)
        num += 1
    else:
        print("Unknown", act)

Measured memory_bytes: 6724
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cctype>
using namespace std;
typedef long long int64;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 5e3+5, M = 2e2+5;
int n, m, b[M][N], s[N], f[N];
int64 a[N], ans, d[N][N];
void solve(int *w)
{
    int top = 0, r = 0;
    for(int i = 1; i <= n; ++i) 
    {
        while(top&&w[s[top]] < w[i]) --top;
        f[i] = top?s[top]+1:1, s[++top] = i; 
    }
    top = 0;
    for(int i = n; i; --i) 
    {
        while(top&&w[s[top]] < w[i]) --top;
        r = top?s[top]-1:n, s[++top] = i;
        d[f[i]][i] += w[i], d[f[i]][r+1] -= w[i], d[i+1][i] -= w[i], d[i+1][r+1] += w[i]; 
    }
}
int main()
{
    n = read(), m = read();
    for(int i = 2; i <= n; ++i) a[i] = a[i-1]+read();
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) b[j][i] = read();
    for(int i = 1; i <= m; ++i) solve(b[i]);
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j <= n; ++j)
        {
            d[i][j] += -d[i-1][j-1]+d[i-1][j]+d[i][j-1]; 
            if(i <= j) ans = max(ans, d[i][j]-a[j]+a[i]);
        }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string bit(unsigned int x) {
    string ret = "";
    while (ret.size() < 32) {
        ret.push_back('0' + (x & 1));
        x /= 2;
    }
    reverse(ret.begin(), ret.end());
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    unsigned int X;
    cin >> X;
    cout << bit(X) << endl;
    cout << bit(~X) << endl;
    cout << bit(X << 1LL) << endl;
    cout << bit(X >> 1LL) << endl;

    return 0;
}


Measured memory_bytes: 3220
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    int cnt = 0;
    int ans = 0;
    for(int i=0; i<n; ++i){
        if(s[i] == 'g'){
            if(cnt > 0){
                -- cnt;
                ++ ans;
            }
            else{
                ++ cnt;
            }
        }
        else{
            if(cnt > 0){
                -- cnt;
            }
            else{
                ++ cnt;
                -- ans;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
 
int main()
{
    int i, j = 0, seisu[10000], max = -10000000, min = 10000000, num;
    long int sum = 0;
    scanf("%d", &i);
 
    while(j != i)
    {
        scanf("%d", &seisu[j]);
 
        j++;
    }
 
    j = 0;
 
    for(j=0; j<i; j++)
    {
        num = seisu[j];
 
        if(max < num)
        {
            max = num;
        }
         
        if(min > num)
        {
            min = num;
        }
 
        sum = sum + num;
    }
 
    printf("%d %d %ld\n", min, max, sum);
 
    return 0;
}

Measured memory_bytes: 636
inp = gets.split.map(&:to_i).sort
l,m,s = inp[2],inp[1],inp[0]
counter = 0

until l == m
  s += 1
  m += 1
  counter += 1
end

until s == l || s == m - 1
  s += 2
  counter += 1
end

if s == l
  puts counter
else
  puts counter + 2
end


Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
char s[5005];
int Next[5005];
vector<char> v[5005];
int main()
{
    int n,i,j,k,m,t,max=0;
    scanf("%d%s",&n,s);
    for(i=0;i<n;i++)
        for(j=i;j<n;j++)
            v[i].push_back(s[j]);
    for(i=0;i<n;i++)
    {
        Next[0]=-1;
        j=0;
        k=-1;
        while(j<n-i)
        {
            if(k==-1||v[i][j]==v[i][k])
                Next[++j]=++k;
            else
                k=Next[k];
        }
        for(j=0;j<=n-i;j++)
        {
            if(Next[j]<=j/2)
            {
                if(Next[j]>max) max=Next[j];
            }
            else
            {
                t=j-Next[j];
                t=t*(j/t/2);
                if(t>max) max=t;
            }
        }
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
int main()
{  ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = a; i <= b; i++)
	{
		int  digit;
		int p = i ;
		int k = i;
		int rev = 0;

		do
		{
			digit = k % 10;
			rev = (rev * 10) + digit;
			k = k/ 10;

		} while(k != 0);
		if(p == rev)
		{
			cnt ++;
		}
		else
			continue ;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,n,l;
    ll sum=0;
    ll ate=MAX;
    cin >>n>>l;
    for(int i=0;i<n;i++){
        sum+=l+i;
        if(abs(l+i)<abs(ate))ate=l+i;
    }
    sum-=ate;


    cout <<sum<<endl;

    return 0;

}

Measured memory_bytes: 256
import numpy as np
N,M,C=[int(i)for i in input().split()]
B=np.array([int(b)for b in input().split()])
A=np.array([[int(a)for a in input().split()]for _ in range(N)])
#print([c>0 for c in A*B])
#print([c>0 for c in np.dot(A,B)])
ans=sum([c+C>0 for c in np.dot(A,B)])
#print(B)
#print()
#print(A)
print(ans)

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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i ,a, b) for (int i = a ; i <= b ; i++)
#define sz(a) int(a.size())
#define cuti(a) cout << a << endl;
#define cutii(a,b) cout << a << " " << b << endl;
#define vec(a) vector<int > a;

template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }

typedef pair<int ,int > pii;
typedef long long LL;
const long long oo = 1e9 + 7;

int n;
pii A[123456];

int main() {
 //   freopen("test.txt","r",stdin);
    long long ans = 0;
    cin >> n;
    for (int i =1 ; i <= n ;i++) {
        int x,y;
        cin >> x >>y;
        A[i] = pii(x,y);
    }
    sort( A+1 , A+ 1 + n);
    ans += n;
    ans += abs( 1 - A[1].fi);
    for (int i =1 ; i < n ; i++) {
        ans += max(0,abs( A[i].fi - A[i+1].fi) -1);
    }
    ans += abs(0 - A[n].se);
    cuti(ans)
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
#define NMAX 5100

//int dp[NMAX][NMAX];
int a[NMAX];

int main()
{
    int n;
    while(cin>>n)
    {
        if(n==0)break;
        memset(a,0,sizeof(int)*NMAX);

        for(int i =1;i<=n;++i)
        {
            cin >> a[i];
        }
        int sum = 0,ans = a[1];
        for(int first = 1;first<=n; ++first)
        {
            sum = a[first];
            if(ans<sum) ans = sum;
            for(int last = first+1;last<=n;++last)
            {
                sum += a[last];
                if(ans<sum) ans = sum;
            }
            sum = 0;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(){

int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
if (0<=x-r && x+r<=W && 0<=y-r && y+r<=H){cout<<"Yes"<<endl;}
else {cout<<"No"<<endl;}




	return 0;
}


Measured memory_bytes: 3084
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define int long long
//#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 998244353;

void solve() {
    int n, m;
    cin >> n >> m;
    int ans = m * (m - 1) / 2 + n * (n - 1) / 2;
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(12);
    srand(time(0));
    cout << fixed;
    solve();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
	int a,b;
	cin>>a>>b;
	if(a<b){
		cout<<"a < b"<<endl;
	}
	if(a==b){
		cout<<"a == b"<<endl;
	}
	if(a>b){
		cout<<"a > b"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
n, k = map(int, input().split())
l = [0 for _ in range(k)]
for i in range(k-1, -1, -1):
    j = pow(k//(i+1), n, 10**9+7)
    for m in range(2, k//(i+1) + 1):
        j -= l[(i+1)*(m)-1]
    l[i] = j

ans = 0
for i in range(k):
    ans += (i+1) * l[i]
print(ans % (10**9+7))

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<pair<int, int>> red(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		red[i] = make_pair(x, y);
	}

	vector<pair<int, int>> blue(n);
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		blue[i] = make_pair(x, y);
	}

	sort(red.begin(), red.end());
	sort(blue.begin(), blue.end());

	int ans = 0;
	vector<bool> used(n);
	for (auto b : blue) {
		int maxY = -1, maxYIndex = -1;
		for (int i = 0; i < red.size(); i++) {
			if (used[i]
				|| red[i].first >= b.first
				|| red[i].second >= b.second) {
				continue;
			} else if (maxY < red[i].second) {
				maxY = red[i].second;
				maxYIndex = i;
			}
		}

		if (maxY != -1) {
			ans++;
			used[maxYIndex] = true;
		}
	}

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


Measured memory_bytes: 256
S = input()

a = S.count('A')
c = S[2:-1].count('C')

i = S.find('C')
if S[0] == 'A' and a == 1 and c == 1:
    temp = S[1:i]+S[i+1:]
    if 1 < i and i < len(S)-1 and temp.islower():
        print('AC')
    else:
        print('WA')
else:
    print('WA')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define map map<string,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  ll N,A,B,C,D;
  cin>>N;
  A=N/500;
  B=N%500;
  C=B/5;
  D=1000*A+5*C;
  cout<<D<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;


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;
}




int main() {
    string date;
    cin >> date;
    int year = stoi(date.substr(0, 4));
    int month = stoi(date.substr(5, 2));
    int day = stoi(date.substr(8, 2));
    if(year >= 2019 and month >= 5) {
        cout << "TBD" << endl;
    }
    else {
        cout << "Heisei" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

a = [_ab[0] for _ab in ab]
b = [_ab[1] for _ab in ab]
a.sort()
b.sort()

if n % 2 == 1:
    m = a[n // 2]
    M = b[n // 2]
    print(M - m + 1)
else:
    m = (a[n // 2 - 1] + a[n // 2]) / 2
    M = (b[n // 2 - 1] + b[n // 2]) / 2
    print(int((M - m) * 2 + 1))


Measured memory_bytes: 129400
use std::io::prelude::*;

fn input<T>() -> T
where T: std::str::FromStr {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a = input::<u32>();
    let b = input::<u32>();
    println!("{:?}", (a + b) % 24);
}

Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        int m = cin.nextInt();
        WriteLine(n == m? "Yes":"No");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
(* O(n) *)
let n, k = Scanf.scanf " %d %d" @@ fun a b -> a, b
let s = Scanf.scanf " %s" @@ fun s -> s
let rec f acc i c m =
  if i >= n then List.rev @@ (if c = '1' then m :: acc else 0 :: m :: acc)
  else if s.[i] <> c then f (m :: acc) (i + 1) s.[i] 1
  else f acc (i + 1) s.[i] (m + 1)
let base = f [] 0 '1' 0 |> Array.of_list
let m = Array.length base
let sums = Array.make (m + 1) 0
let ans = ref 0
let _ =
  Array.iteri (fun i c -> sums.(i + 1) <- sums.(i) + c) base;
  let i = ref 0 in
  while !i <= m do
    let r = min m @@ !i + 2 * k + 1 in
    ans := max !ans @@ sums.(r) - sums.(!i);
    i := !i + 2
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    vector <int> per(n+1,0);
    for (int i=0; i<n; i++){
        cin >> per[i+1];
    }
    vector <int> l;
    int x,y;
    vector <vector <int> > gr(n+1,l);
    for (int i=0; i<m; i++){
        cin >> x >> y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    vector <int> used(n+1,0);
    queue <int> q;
    vector <vector <int> > comp;
    for (int i=1; i<n+1; i++){
        if (used[i]==0){
            vector <int> c;
            q.push(i);
            while (q.size()!=0){
                int v = q.front();
                q.pop();
                if (used[v]==0){
                    c.push_back(v);
                    for (int j=0;j<gr[v].size();j++){
                        q.push(gr[v][j]);
                    }
                    used[v] = 1;
                }
            }
            comp.push_back(c);
        }

    }
    int kol = 0;
    for (int i=0; i<comp.size(); i++){
        set <int> se;
        for (int j=0; j<comp[i].size(); j++){
            se.insert(per[comp[i][j]]);
        }
        for (int j=0; j<comp[i].size(); j++){
            if (se.find(comp[i][j])!=se.end()) kol++;
        }
    }
    cout << kol;
    return 0;
}

Measured memory_bytes: 11632
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000



int main(){

	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	int cnt = 0;
	for(int i=0;i<N;i++){
		if(S[i]=='R')cnt++;
	}
	
	int ans = 0;
	for(int i=0;i<cnt;i++){
		if(S[i]=='W')ans++;
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3748
K, N = map(int, input().split())
points = list(map(int, input().split()))

points.sort()

# 2週目追加
points += [p + K for p in points]

# 2 ＊ 10^5 だけど間に合うはず
print(min(
    points[start + N - 1] - points[start]
    for start in range(N)
))


Measured memory_bytes: 89692
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
using namespace std;int main(){int n,m;cin >> n;int b[n-1];rep(i,0,n-1)cin>>b[i];m=b[0]+b[n-2];rep(i,0,n-2)m+=min(b[i], b[i+1]);cout << m << endl;return 0;}

Measured memory_bytes: 256
//C
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
int main(){
	ll k,ans = 0;
	cin >> k;
	for(int i = 1;i <= k;i++)
		for(int j = 1;j <= k;j++)
			for(int x = 1;x <= k;x++)ans += gcd(i,gcd(j,x));
	cout << ans;
	return 0;
}


Measured memory_bytes: 3572
N = int(input())
S = list(input())

R = [None] * S.count("R")
G = [None] * S.count("G")
B = [None] * S.count("B")

ri = 0
gi = 0
bi = 0
for i in range(N):
    if S[i] == "R":
        R[ri] = i+1
        ri+=1
    elif S[i] == "G":
        G[gi] = i+1
        gi += 1
    else:
        B[bi] = i+1
        bi += 1
R = set(R)
G = set(G)
B = set(B)

c = 0
for r in R:
    for g in G:
        for d in [(r + g) / 2, 2 * r - g, 2 * g - r]:
            if d in B:
                c += 1

ans = len(R) * len(G) * len(B) - c
print(ans)

Measured memory_bytes: 9604
from collections import deque

CONST = 1000000007

n,m = map(int,input().split())
lis = deque([int(input()) for _ in range(m)])
lis.append(n+1)
nhole = lis.popleft()

memo = deque([0, 1])
for i in range(1,n+1):
    if i == nhole:
        memo.append(0)
        nhole = lis.popleft()
    else:
        memo.append((memo[-1] + memo[-2])%CONST)
print(memo[-1])

Measured memory_bytes: 8056
#include <iostream>

using namespace std;

int Solution(int l[10],int v[2])
{
    double sum=0;
    
    double t;
    
    double len;
    
    for(int i = 0; i < 10; i++)
    {
        sum += l[i];
    }
    
    t = sum / (v[0] + v[1]);
    
    len = v[0] * t;
    
    sum = 0;
    
    for(int i = 0; i < 10; i++)
    {
        sum += l[i];
        
        if(len <= sum)
        {
            return i+1;
        }
    }
}

int main()
{
    int l[10];
    int v[2]; // v1, v2
    
    char comma;
    
    while(cin >> l[0])
    {
        for(int i = 1; i < 10; i++)  //data input
        {
            cin>>comma>>l[i];
        }
        
        for(int i = 0; i < 2; i++)
        {
            cin>>comma>>v[i];
        }
        
        cout<<Solution(l, v)<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
// // If you want something you've never had, you must be willing to do
// // something you've never done

// //  When the going gets tough,  the tough get going

// #pragma GCC optimize ("O3")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef tree<pair<int,int>, null_type,less<pair<int, int> >,rb_tree_tag,tree_order_statistics_node_update > pbds;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define int ll
ll power(ll a, ll b, ll mod) {
    ll res = 1;
    a %= mod;
    while(b) {
        if(b % 2) {
            res *= a;
            res %= mod;
        }
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}
const int INF = 2e9;

// ----------------------------------------------------------
// #define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod = 1e9 + 7;
int n, m, q;

signed main() {
    ll x;
    cin >> x;
    ll a, b;
    for(int i=-500; i<=500; i++) {
        for(int j=-500; j<=500; j++) {
            if(pow(i, 5) - pow(j, 5) == x) {
                cout << i << ' ' << j << '\n';
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

int main()
{
	std::vector<int> vec(10);
	for (int i = 0; i < 10; ++i) {
		std::cin >> vec[i];
	}
	std::partial_sort(
			vec.begin(), vec.begin() + 3, vec.end(),
			std::greater<int>());
	for (int i = 0; i < 3; ++i) {
		std::cout << vec[i] << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [list(map(int,input().split())) for _ in range(M)]
ans = min(a) + min(b)

for i in range(M):
  x = a[c[i][0]-1] + b[c[i][1]-1] - c[i][2]
  if ans >= x:
    ans = x
print(ans)

Measured memory_bytes: 38488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  string s;
  cin>>s;
  int ans=0;
  rep(i,3)if(s[i]=='1')ans++;
  cout<<ans<<endl;
  return(0);
}


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

int main() {
  
  int N = 0;
  cin >> N;
  int T = 0;
  
  for (int i = 0; i < N; i++){
    
    int l = 0;
    int r = 0;
    
    cin >> l >> r;
    
    int dif;
    
    dif = r - l + 1;
    
    T = T + dif;
    
  }
  
  cout << T << endl;
  

 }

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

const int MOD = 998244353;

void solve_test() {
	int n, k;
	cin >> n >> k;
	vector<pair<int,int>> s(k);
	for (int i = 0; i < k; ++i)
		cin >> s[i].first >> s[i].second;

	vector<int> dp(n + 1);
	dp[n] = 1;
	vector<int> sum_dp(k);
	for (int i = n - 1; i >= 1; i--) {
		// update sum_dp
		for (int j = 0; j < k; j++) {
			int l = s[j].first;
			int r = s[j].second;
			if (i + l <= n)
				sum_dp[j] = (dp[i + l] + sum_dp[j]) % MOD;
			if (i + 1 + r <= n)
				sum_dp[j] = (sum_dp[j] - dp[i + 1 + r] + MOD) % MOD;
		}

		// calc dp
		for (int j = 0; j < k; j++)
			dp[i] = (dp[i] + sum_dp[j]) % MOD;

		cerr << "dp at i " << i << ' ' << dp[i] << '\n';
	}
	cout << dp[1] << '\n';
}

int main() {
	int T;
	T = 1;
	for (int t = 1; t <= T; t++)
		solve_test();

	return 0;
}


Measured memory_bytes: 6120
import javax.crypto.Cipher;
import java.util.*;

public class Main{
    public static void main(String args[]){
        List<City> cityList = new ArrayList<>();

        List<City> cityList2 = new ArrayList<>();
        Scanner scanner = new Scanner(System.in);
        try{
            int n = scanner.nextInt();
            for(int i = 0;i<n;i++) {
                String city = scanner.next();
                int score = scanner.nextInt();
                cityList.add(new City(city,score));
                cityList2.add(new City(city,score));
            }
            cityList.sort(new CityComparater());
        for(int i = 0 ; i<n; i++){
            System.out.println(cityList2.indexOf(cityList.get(i))+1);
        }
        }catch(Exception e){
            System.out.println(e.getMessage());
        }finally{
            scanner.close();
        }
    }
}

class CityComparater implements Comparator<City>{
    @Override
    public int compare(City city1,City city2){
        if(city1.name.compareTo(city2.name)==0) return city1.score > city2.score ? -1:1;
        return city1.name.compareTo(city2.name);
    }
}
class City{
    String name;
    int score;
    City(String name, int score){
        this.name = name;
        this.score = score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        City city = (City) o;
        return score == city.score &&
                Objects.equals(name, city.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, score);
    }
}


Measured memory_bytes: 22612
#include<stdio.h>
#include<string.h>
int main(){
	char s[10];
	gets(s+1);
	int m=1;
	char c[10];
	c[1]=s[1];
	for (int i=2;i<=4;i++){
		int k=1;
		for (int j=1;j<=m;j++)
			if (c[j]==s[i]) k=0;
		if (k) m++,c[m]=s[i];
	}
	if (m==2) puts("Yes");else puts("No");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {
  long long n;
  cin >> n;
  
  long long yen=100;
  
  rep(i, 5000) {
  yen = yen+yen/100;
      if(yen>=n) {
      cout << i+1;
      return 0;
      }
  }
     
}



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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

int main(){
	IOS;

	int n,c=0;
	cin >> n;
	for(int i=1;i<=n;i++){
		int val = (n/i) - (n%i == 0);
		c += val;
	}
	cout << c;
	return 0;    
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> adj[200200];
long long  ans[200200];
int p[200200];
void dfs(int s ){
	if(p[s] != -1){
		ans[s] += ans[p[s]];
//		cout<<"at node "<<s<<" ";
//		cout<<ans[s]<<" "; cout<<ans[p[s]]<<" ";
//		cout<<"\n";
	}
	for(auto u : adj[s]){
		dfs(u);
	}
	return;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,q;  cin>>n>>q;
	int a,b;
	for(int i = 0; i <= n; i++) p[i] = -1;
	for(int i = 0; i < n-1; i++){
		cin>>a>>b;
		adj[a].push_back(b);
		p[b] = a;
	}
	int p,x;
	for(int i = 0; i < q; i++){
		cin>>p>>x;
		ans[p] += x;
	}
	dfs(1);
	for(int i = 1; i <= n; i++) cout<<ans[i]<<" ";
	cout<<"\n";
}

Measured memory_bytes: 21888
from collections import Counter


def main():
    n = int(input())
    S = [input() for i in range(n)]

    CS = Counter(S)

    print('AC x ' + str(CS['AC']))
    print('WA x ' + str(CS['WA']))
    print('TLE x ' + str(CS['TLE']))
    print('RE x ' + str(CS['RE']))


if __name__ == '__main__':
    main()


Measured memory_bytes: 82968
#include <bits/stdc++.h>
#define foru(i,a,b) for(int i = int(a); i <= (b); i++)
#define ford(i,a,b) for(int i = int(a); i >= (b); i--)
using namespace std;

const int N = 1000005;

int rangeJ[N], rangeO[N], rangeI[N], n;
char s[N];

int main() {
    //freopen("a.txt", "r", stdin);
    scanf("%s", &s);  n = strlen(s);
    rangeI[n] = rangeJ[n] = rangeO[n] = -1;
    ford(i, n-1, 0) {
        rangeI[i] = rangeJ[i] = rangeO[i] = -1;
        if (s[i] == 'J')
            rangeJ[i] = max(i, rangeJ[i+1]);
        else if (s[i] == 'O')
            rangeO[i] = max(i, rangeO[i+1]);
        else
            rangeI[i] = max(i, rangeI[i+1]);
    }

    int ans = 0;
    foru(i, 0, n-1) {
        if (s[i] != 'J') continue;
        int len = rangeJ[i] - i + 1;
        int vJ = i, vO, vI;
        vO = vJ + len;  vI = vO + len;
        if (vO >= n || vI >= n) continue;
        if (s[vO] != 'O' || rangeO[vO] != vI-1) continue;
        if (s[vI] != 'I' || rangeI[vI] - vI + 1 < len) continue;
        ans = max(ans, len);
    }
    cout << ans << endl;


}

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

int main() {
  string S,T;
  cin >> S >> T;
  int a = 0;
  for( int i = 0; i < 3; i++){
    if( S.at(i) == T.at(i)){
      a++;
    }
    else{
      a;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
// 2011/09/21 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int a, b;
		cin >> a >> b;
		if(a==0&&b==0)
			break;

		int DP[17][17];
		for(int y=0; y<=b; y++)
			for(int x=0; x<=a; x++)
				if(y==0||x==0)
					DP[y][x] = 0;
				else if(y==1&&x==1)
					DP[y][x] = 1;
				else
					DP[y][x] = -1;

		int n;
		cin >> n;

		for(int i=0; i<n; i++){
			int X, Y;
			cin >> X >> Y;
			DP[Y][X] = 0;
		}

		for(int y=1; y<=b; y++)
			for(int x=1; x<=a; x++)
				if(DP[y][x]==-1)
					DP[y][x] = DP[y-1][x]+DP[y][x-1];

		cout << DP[b][a] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
module Main where

import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Integer
  print $ n * (n - 1) `div` 2
  
  -- forM_ [1..10] $ \n -> do
  --   let xs = [1..n]
  --   print $ maximum $ map (sum . modOrig xs) $ perm2 xs n

-- modOrig x y = zipWith mod y x


-- perm2 :: Eq a => [a] -> Int -> [[a]]
-- perm2 _ 0 = [[]]
-- perm2 xs n = [x:ys | x <- xs, ys <- perm2 xs (n-1)]

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

using namespace std;
int n;
string s;
int out = -40000;
int f(string a, string b){
  vector<int> fa(27,0), fb(27,0);
  for(char c : a){
    fa[c-'a']++ ;
  }
  for(char c : b){
    fb[c-'a']++;
  }
  int ans=0;
  for(int i=0; i<fa.size(); i++){
    if(fa[i] != 0 && fb[i] != 0) 
      ans++;
  }
  return ans;
}
int main(){
  cin >> n ;
  cin >> s ;
  for(int i=1; i<n; i++){
    out = max(out, f(s.substr(0,i),s.substr(i,n)));
  }
  cout << out << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<chrono>
using namespace std;
using namespace std::chrono;
using namespace __gnu_pbds; 
#define lli long long int
#define fr(i,a,b) for(lli i=a;i<b;i++)
#define bfr(i,a,b) for(lli i=a;i>=b;i--)
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define mod 1000000007LL
#define mod2 998244353LL
#define all(vec) vec.begin(),vec.end()  
#define ld long double
#define pb push_back
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update> 

int main()
{
    
                        
     fio

          
     lli a[5];
     fr(i,0,5)
     {
     	cin>>a[i];
     	if(a[i]==0){cout<<i+1;return 0;}
     }

              


return 0;}    


Measured memory_bytes: 3608
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    char B;
    cin >> B;
    switch (B) {
    case 'A':
        cout << 'T';
        break;
    case 'C':
        cout << 'G';
        break;
    case 'G':
        cout << 'C';
        break;
    case 'T':
        cout << 'A';
        break;
    }
    cout << endl;
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 06.08.2020 04:12:18
**/

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

int main() {

    int n,m;
    cin >> n >> m;
    vector<string> a(n),b(m);
    rep(i,n) cin >> a.at(i);
    rep(i,m) cin >> b.at(i);
    bool same;

    rep(i,n-m+1){
        rep(j,n-m+1){
            same=true;
            rep(k,m){
                rep(l,m){
                    if(b.at(k).at(l)!=a.at(i+k).at(j+l)) same=false;
                    if(!same) break;
                }
                if(!same) break;
            }
            if(same) break;
        }
        if(same) break;
    }

    if(same) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3556
'''
ITP-1_8-A
 ??§????????¨?°????????????\?????????
????????????????????????????°?????????¨??§???????????\????????????????????°????????????????????????????????????
???Input
????????????1???????????????????????????
???Output
????????????????????????????°?????????¨??§???????????\????????????????????????????????????????????????
??¢????????????????????\???????????????????????????????????????????????????
'''
# inputData
inputData = input()

for i in range(len(inputData)):
    if "a"<=inputData[i]<="z":
        # ??§????????????
        print(inputData[i].upper(),end='')
    elif "A"<=inputData[i]<="Z":
        # ?°?????????????
        print(inputData[i].lower(),end='')
    else:
        # ??¢????????????????????\?????????????????????
        print(inputData[i],end='')

# ????????????
print('')

Measured memory_bytes: 7360
from collections import Counter
N = int(input())
Sc = Counter([input() for _ in range(N)]).most_common()
# print(Sc)
max_num = Sc[0][1]
ans = []
for key, val in Sc:
    if val == max_num:
        ans.append(key)
ans.sort()
for t in ans:
    print(t)

Measured memory_bytes: 43476
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,z,w;
  	cin>>n>>z>>w;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    if(n==1) cout<<abs(a[0]-w);
    else cout<<max(abs(a[n-1]-a[n-2]),abs(a[n-1]-w));
}  

Measured memory_bytes: 3624