akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const ll mod = 998244353;

ll dp[310][310];

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


	string S;
	int K;
	int k = 0;
	int A[301] = {};

	cin >> S >> K;
	rep(i, S.size()) {
		if (S[i] == '0') k++;
		else A[k]++;
	}

	int kosuu = 0;
	dp[0][0] = 1;
	for (int i = k; i >= 0; i--) {
		if ((i & 3) == 0) {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					dp[j][k] %= mod;
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		else {
			for (int j = kosuu; j >= 0; j--) {
				ll tmp = 0;
				for (int k = kosuu; k >= 0; k--) {
					tmp += dp[j][k];
					rep1(p, A[i]) dp[j + p][k + p] += dp[j][k];
					dp[j][k] = tmp;
				}
			}
		}
		kosuu = min(kosuu + A[i], K);		
	}

	ll kotae = 0;
	rep(i, min(K, kosuu) + 1) {
		kotae += dp[i][0] % mod;
	}
	co(kotae % mod);



	Would you please return 0;
}

Measured memory_bytes: 4340
#include<iostream>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<cstdlib>
#include<queue>
#include<list>
using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0; i<n; i++)cin>>a[i];
    int sum=0;
    for(int i=0; i<n; i++)
        sum+=a[i];
    for(int i=0; i<n; i++){
        if(a[i]>=sum-a[i]){
            cout<<"No"<<endl;
            break;
        }
        if(i==n-1)cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{ 
	int d;
	
	while (cin >> d)
	{
		int area = 0;
		for (int i = d; i <= 600 - d; i += d)
			area += ((i * i) * d);

		cout << area << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, M;
    cin >> N >> M;
    cout << (100 * (N - M) + 1900 * M) * pow(2, M) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
char s[510000];
char s2[510000];
int main(){
	int k=0;
	while(cin>>s[k]){
		//if(s[k]=='o')break;
		k++;
	}
	for(int i=0;i<k;i++){
		s2[k-i-1]=s[i];
		if(s2[k-i-1]=='b'&&s[k-i-1]!='d'){
			printf("No");
			return 0;
		}
		if(s2[k-i-1]=='d'&&s[k-i-1]!='b'){
			printf("No");
			return 0;
		}
		if(s2[k-i-1]=='q'&&s[k-i-1]!='p'){
			printf("No");
			return 0;
		}
		if(s2[k-i-1]=='p'&&s[k-i-1]!='q'){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define x first
#define y second

namespace perform
{
	typedef std::pair<int,int> pii;
	const int N=510,M=N*N;
	pii s[N];
	int t[M];
	int n,m;
	void initialize()
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
			scanf("%d",&s[i].x),s[i].y=i;
		std::sort(s+1,s+n+1);
		m=n*n;
	}
	bool work()
	{
		t[0]=t[m+1]=-1;

		int ind=0,id;
		for(int i=1;i<=n;i++)
		{
			id=s[i].y;
			for(int tmp=id-1;tmp--;)
			{
				for(;t[ind];ind++);
				t[ind]=id;
			}
			if(ind>=s[i].x)return 0;
			t[s[i].x]=id;
		}

		ind=m+1;
		for(int i=n;i;i--)
		{
			id=s[i].y;
			for(int tmp=n-id;tmp--;)
			{
				for(;t[ind];ind--);
				t[ind]=id;
			}
			if(ind<=s[i].x)return 0;
		}

		return 1;
	}
	void solve()
	{
		initialize();
		if(!work())printf("No\n");
		else
		{
			printf("Yes\n");
			for(int i=1;i<=m;i++)
				printf("%d ",t[i]);
			printf("\n");
		}
	}
}
int main()
{
	perform::solve();
	return 0;
}


Measured memory_bytes: 2176
import math
a,b = map(int,input().split())

max = math.ceil(a*100/8)*math.ceil(b*10)

for i in range(1, max+1):
    if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
        print(i)
        exit()
print(-1)

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

int main()
{
  double a_phi, a_theta, b_phi, b_theta;
  while (cin >> a_theta >> a_phi >> b_theta >> b_phi && a_phi >= 0) {
    static const double R = 6378.1;
    a_theta *= M_PI/180.0; a_phi *= M_PI/180.0;
    b_theta *= M_PI/180.0; b_phi *= M_PI/180.0;

    const double a_x = R*cos(a_theta)*cos(a_phi);
    const double a_y = R*cos(a_theta)*sin(a_phi);
    const double a_z = R*sin(a_theta);
    const double b_x = R*cos(b_theta)*cos(b_phi);
    const double b_y = R*cos(b_theta)*sin(b_phi);
    const double b_z = R*sin(b_theta);

    const double dot = a_x*b_x + a_y*b_y + a_z*b_z;
    const double rad = acos(dot / (R*R));
    const double ans = R * rad;
    cout << lround(ans) << endl;
  }
  return 0;
}

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

typedef vector<int> vi;  
typedef pair<int,int> ii;  
typedef vector<ii> vii;  
typedef list<int> li;  
typedef unordered_map<int,int> mii;

#define ll long long
#define rep(i,n) for (int i = 0; i < (n); i++)  
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rap(i,a,n) for (int i = a; i < (n); i++) 
#define rrap(i,n,a) for (int i = (n)-1; i >= a; i--) 


int main() {
    ios_base::sync_with_stdio(false);
    int n,c=0;
    cin >> n;
    rap(i,1,n-1) {
        if (i < n-i) c++;
    }
    cout << c << '\n';
    return 0;

    //compile: g++ -std=c++14 -O2 -Wall NAME.cpp -o NAME
}

Measured memory_bytes: 256
// Example program
#include <iostream>
using namespace std;

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

Measured memory_bytes: 1156
<?php 
fscanf(STDIN, "%s", $s);

$eraserReplace = str_replace("eraser", " ", $s);
$eraseReplace = str_replace("erase", " ", $eraserReplace);
$dreamerReplace = str_replace("dreamer", " ", $eraseReplace);
$dreamReplace = str_replace("dream", " ", $dreamerReplace);

$end = str_replace(" ", "", $dreamReplace);

if($end == ""){
  echo "YES";
}else {
  echo "NO";
}

?>


Measured memory_bytes: 4108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int MOD = (int)1e9 + 7;
int add(int x, int y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
int sub(int x, int y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
int mult(int x, int y) {
	return ((ll)x * y) % MOD;
}

const int N = 5002;
int C[N][N];
int f[N];
int n;
vector<int> g[N];
int sz[N];
int a[N];
int m;
int dp[2][N];

void dfs(int v, int par) {
	sz[v] = 1;
	for (int u : g[v]) {
		if (u == par) continue;
		dfs(u, v);
		sz[v] += sz[u];
	}
}

void solve() {
	dp[0][0] = 1;
	for (int i = 0; i < m; i++) {
		for (int x = 0; x <= n; x++)
			dp[1][x] = 0;
		for (int x = 0; x <= n; x++) {
			if (dp[0][x] == 0) continue;
			for (int y = 0; y <= a[i]; y++)
				dp[1][x + y] = add(dp[1][x + y], mult(mult(dp[0][x], f[y]), mult(C[a[i]][y], C[a[i]][y])));
		}
		for (int x = 0; x <= n; x++)
			dp[0][x] = dp[1][x];
	}
	int ans = 0;
	for (int x = 0; x <= n; x++) {
		int val = mult(dp[0][x], f[n - x]);
		if (x & 1)
			ans = sub(ans, val);
		else
			ans = add(ans, val);
	}
	printf("%d\n", ans);
}

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

	for (int i = 0; i < N; i++)
		C[i][0] = C[i][i] = 1;
	for (int i = 0; i < N; i++)
		for (int j = 1; j < i; j++)
			C[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);
	f[0] = 1;
	for (int i = 1; i < N; i++)
		f[i] = mult(f[i - 1], i);

	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int v, u;
		scanf("%d%d", &v, &u);
		v--;u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	dfs(0, -1);
	int v = 0;
	while(true) {
		int w = -1;
		for (int u : g[v]) {
			if (sz[u] > sz[v]) continue;
			if (2 * sz[u] >= n)
				w = u;
		}
		if (w == -1) break;
		v = w;
	}
	dfs(v, -1);
	for (int u : g[v]) {
		a[m] = sz[u];
		if (2 * a[m] > n) throw;
		if (2 * a[m] == n) {
			printf("%d\n", mult(f[a[m]], f[a[m]]));
			return 0;
		}
		m++;
	}
	solve();

	return 0;
}


Measured memory_bytes: 97152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T>

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

vvi adl_input(int N,int M){ //N頂点M辺
  vvi L(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    //a--;b--;
    L[a].push_back(b);
    L[b].push_back(a);
  }
  return L;
}

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

vector<int> bfs(vvi L,int S){ //List,Start
  vector<int> v(L.size(),-1);
  v[S]=0;
  queue<int> q;
  q.push(S);
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:L[a]){
      if (v[x]==-1){
        v[x]=v[a]+1;
        q.push(x);
      }
    }
  }
  return v;//startからの距離
}

void initialize(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
}

/////////////////////////////////////////

int main(){
  initialize();
  string S;
  cin >> S;
  string Ans[3]={"Sunny","Cloudy","Rainy"};
  int i;
  if (S == "Sunny") i=1;
  if (S == "Cloudy") i=2;
  if (S == "Rainy") i=0;
  cout << Ans[i] << endl;
  return 0;
}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
import math
from collections import defaultdict


def main():
  N,K = map(int, input().split())
  ABn = defaultdict(lambda:0)
  for _ in range(N):
    a,b = map(int, input().split())
    ABn[a] += b

  for i in sorted(ABn.keys()):
    ret = i
    K -= ABn[i]
    if K <= 0:
      return ret


if __name__ == "__main__":
  ret = main()
  print(ret)


Measured memory_bytes: 56408
/**
 *      purpose : CODE FESTIVAL 2016 qual A A
 *      author  : kyomukyomupurin
 *      created : 2018-11-11 21:21:35
**/

#include <bits/stdc++.h>
using namespace std;
#define int64 long long
#define print(x) cout << (x) << '\n'

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s; cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << '\n';
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    List<int>[] G;
    List<long>[] C;
    int[] child;
    long[] cost;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        G = new List<int>[N];
        C = new List<long>[N];
        child = new int[N];
        for(int i=0;i<N;i++){
            G[i] = new List<int>();
            C[i] = new List<long>();
        }
        for(int i=0;i<N-1;i++){
            string[] str = Console.ReadLine().Split(' ');
            G[int.Parse(str[0])-1].Add(int.Parse(str[1])-1);
            C[int.Parse(str[0])-1].Add(int.Parse(str[2]));
            G[int.Parse(str[1])-1].Add(int.Parse(str[0])-1);
            C[int.Parse(str[1])-1].Add(int.Parse(str[2]));
        }
        GetChild(0,-1);
        int Center = Central(0,N/2,-1);
        GetChild(Center,-1);
        long count = 0;
        cost = new long[N];
        Cost(Center,0,-1);
        for(int i=0;i<N;i++){
            count += 2*cost[i];
        }
        int Center2 = -1;
        if(N % 2 == 0){
            for(int i=0;i<N;i++){
                if(child[i] == N/2){
                    Center2 = i;
                }
            }
        }
        long min = 100000000;
        if(Center2 == -1){
            for(int i=0;i<G[Center].Count;i++){
                min = Math.Min(min,C[Center][i]);
            }
        }
        else{
            min = cost[Center2];
        }
        count -= min;
        sb.Append(count+"\n");
    }
    void Cost(int v,long c,int f){
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(t != f){
                Cost(t,c+C[v][i],v);
            }
        }
        cost[v] = c;
    }
    int Central(int v,int c,int f){
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(t != f && child[t] > c){
                return Central(t,c,v);
            }
        }
        return v;
    }
    int GetChild(int v,int f){
        int count = 1;
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(t != f){
                count += GetChild(t,v);
            }
        }
        child[v] = count;
        return count;
    }
}

Measured memory_bytes: 46472
#include<stdio.h>
int main()
{
    int A,p[50],B=0;
    scanf("%d",&A);
    for(int i=1;i<=A;i++){
        scanf("%d",&p[i]);
    }
    for(int k=1;k<=A;k++){
        if(p[k]!=k){
            B++;
        }
    }if(B==2||B==0){
        printf("YES");
    }else{
        printf("NO");
    }

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  int s=S.size();
  int count=0;
  for (int i=0;i<s;i++){
    if (S[i]=='L'&&i>0){
      if (S[i-1]=='L'){
        count++;
      }
    }
    if (S[i]=='R'&&i<s-1){
      if (S[i+1]=='R'){
        count++;
      }
    }
  }
  int ans=min(N-1,count+2*K);
  cout << ans << endl;
}

Measured memory_bytes: 512
import sys
W = input()

ans = 0
if W[:] == "RRR":
    print(3)
    sys.exit(0)
elif W[:2] == "RR" or W[1:] == "RR":
    print(2)
    sys.exit(0)
elif "R" in W:
    print(1)
    sys.exit(0)
print(0)

Measured memory_bytes: 61632
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

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

//		?????? r ???????????¢?????¨?????¨?????????????±???????????????°?????????????????????????????????

		double r = Double.parseDouble(scan.next());

		double area = r * r * Math.PI;
		double length = 2 * r * Math.PI;

		System.out.printf("%.6f %.6f",  area, length);

	}
}

Measured memory_bytes: 17308
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s[150];
	cin>>s+1;
	int n=strlen(s+1);
	bool flag=true;
	for(int i=1;i<=n;++i){
		if(s[i]!=s[n-i+1]){
			flag=false;
			break;
		}
	}
	for(int i=1;i<=(n-1)/2;++i){
		if(s[i]!=s[(n-1)/2-i+1]) {
			flag=false;
			break;
		}
	}
	for(int i=(n+3)/2;i<=n;++i){
		if(s[i]!=s[n-i+(n+3)/2]) {
			flag=false;
			break;
		}
	}
	if(flag) cout<<"Yes\n";else cout<<"No\n";
} 

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

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

    vector<string> ans;

    for ( int i = 0; i < s.length() - t.length() + 1; i++ ) {
        bool ok = true;
        int tmp_num = 0;
        for ( int j = 0; j < t.length(); j++ ) {
            if ( s[i+j] != t[j] && s[i+j] != '?' ) {
                ok = false;
            }
            tmp_num = i;
        }
        if ( ok ) {
            string tmp_s = "";
            for ( int k = 0; k < s.length(); k++ ) {
                if ( k >= tmp_num && k < tmp_num + t.length() ) {
                    tmp_s += t[k-tmp_num];
                }
                else if ( s[k] == '?' ) {
                    tmp_s += "a";
                }
                else {
                    tmp_s += s[k];
                }
            }
            ans.push_back(tmp_s);
        }
    }

    sort(ans.begin(), ans.end());

    if ( ans.size() == 0 ) {
        cout << "UNRESTORABLE" << endl;
    }
    else {
        cout << ans[0] << endl;
    }

    return 0;
}

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

namespace ALDS1_11_B
{
    class Program
    {
        private static int n;
        private static int[,] neighborList;
        private static int[] arriveTime;
        private static int[] finishTime;
        private static bool[] isVisit;
        static void Main(string[] args)
        {
            Program.n = int.Parse(Console.ReadLine());
            Program.neighborList = new int[n,n];
            for (int i = 0; i < n; i++)
            {
                int[] tmpLine = Console.ReadLine()
                                       .Split(' ')
                                       .Select(s => int.Parse(s))
                                       .ToArray();
                for (int j = 2; j < tmpLine[1] + 2; j++)
                {
                    Program.neighborList[i, tmpLine[j] - 1] = 1;
                }
            }
            Program.arriveTime = new int[Program.n];
            Program.finishTime = new int[Program.n];
            Program.isVisit = new bool[Program.n];

            int tmpTime = 0;
            for (int i = 0; i < Program.n; i++)
            {
                if (!Program.isVisit[i])
                {
                    tmpTime = Program.DepthFirstSearch(i + 1, tmpTime);
                }
            }
            
            for (int i = 0; i < Program.n; i++)
            {
                Console.WriteLine(string.Format("{0} {1} {2}", i + 1, Program.arriveTime[i], Program.finishTime[i]));
            }
        }

        static int DepthFirstSearch(int targetIndex, int beforeArriveTime){
            //targetIndexは、配列上のインデックスではなく、実際のインデックス
            int tmpTime = beforeArriveTime;
            //遷移元から+1秒
            tmpTime++;
            Program.arriveTime[targetIndex - 1] = tmpTime;
            Program.isVisit[targetIndex - 1] = true;

            Stack<int> neighborStack = new Stack<int>(); 
            for (int i = Program.n - 1; i >= 0; i--)
            {
                if (Program.neighborList[targetIndex - 1, i] == 1)
                {
                    neighborStack.Push(i + 1);
                }
            }

            while (neighborStack.Count > 0)
            {
                int neighborIndex = neighborStack.Pop();
                if (!Program.isVisit[neighborIndex - 1])
                {
                    tmpTime = Program.DepthFirstSearch(neighborIndex, tmpTime);    
                }
            }
            //遷移元へ戻るのに、+1秒
            tmpTime++;
            Program.finishTime[targetIndex - 1] = tmpTime;

            return tmpTime;
        }
    }
}



Measured memory_bytes: 18712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Alan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int x = in.nextInt();
            if (x < 1200) out.printLine("ABC");
            else out.printLine("ARC");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void printLine(String s) {
            writer.println(s);
        }

        public void close() {
            writer.close();
        }

    }
}



Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <stack>
#include <unordered_map>
#include <climits>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef short int ui;
typedef unsigned long long int ull;
const int N = 200010;
int ans=INT_MAX;
int c3,c1[N],c2[N];
string s;
int main() {
	cin >> c3;
	for (int i = 1; i <= c3; i++) {
		char v1; cin >> v1;
		c1[i] += c1[i - 1] + (v1 == '#');
		c2[i] = (v1 == '.');
	}
	for (int i = c3; i >= 1; i--)c2[i] += c2[i + 1];
	ans = c1[c3];
	for (int i = 1; i <= c3; i++) {
		ans = min(ans, c1[i - 1] + c2[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
from itertools import combinations

if __name__ == '__main__':
    # ??????????????\???
    num1 = int(input())
    A = [int(x) for x in input().split(' ')]
    num2 = int(input())
    M = [int(x) for x in input().split(' ')]
    #A = [1, 5, 7, 10, 21]
    #pick = 4
    #M = [2, 4, 17, 8]

    # ????????????
    results = ['no' for x in range(len(M))]  # M?????¨??????????´?????????????????????????????????§????????????????????±???(no)??¨????????????

    for p in range(1, len(A)+1):  # A????????????1????????¨????????°?????????????????¢????????????
        combi = combinations(A, p)  # n??????????????¢??????????????´????????¨?????????????????????
        for choice in combi:
            total = sum(choice)
            while total in M:
                i = M.index(total)
                results[i] = 'yes'
                M[i] = 'Done'

    # ???????????????
    for txt in results:
        print(txt)

Measured memory_bytes: 7756
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
#define LAST(X) X[X.size()-1]
#define MOD 1000000007
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
inline bool BETWEEN(int x, int min,int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}

using namespace std;
#pragma endregion
signed main() {
	string A,B,C;
	cin >> A >> B >> C;
	if (LAST(A)==B[0] && LAST(B)==C[0] )
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int ans= 180 * (N - 2);
cout << ans << endl;

return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N-1);
  vector<int> b(N, 0);

  for (int i = 0; i < N-1; i++) {
    cin >> a[i];
    b[a[i]-1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << b[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  vector<vector<int>> a(3, vector<int>(3));
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j){
      cin >> a[i][j];
    }
  }
  int n; cin >> n;
  vector<int> b(n);
  for(int i=0; i<n; ++i) cin >> b[i];
  
  vector<vector<bool>> buf(3, vector<bool>(3, false));
  for(int i=0; i<3; ++i){
    for(int j=0; j<3; ++j){
      for(int x : b){
        if(a[i][j] == x) buf[i][j] = true;
      }
    }
  }
  
  string res = "No";
  for(int i=0; i<3; ++i){
    if(buf[i][0] && buf[i][1] && buf[i][2]) res = "Yes";
    if(buf[0][i] && buf[1][i] && buf[2][i]) res = "Yes";
  }
  if(buf[0][0] && buf[1][1] && buf[2][2]) res = "Yes";
  if(buf[2][0] && buf[1][1] && buf[0][2]) res = "Yes";
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

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


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    int N;cin>>N;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    sort(all(A));
    sort(all(B));

    A.push_back(INF);
    B.push_back(INF);

    vector<int> S(2*N,0);
    int anow=0,bnow=0;
    
    while(anow+bnow<2*N){
        if(A[anow]<B[bnow]){
            S[anow+bnow]=1;
            anow++;
        }else{
            S[anow+bnow]=0;
            bnow++;
        }
    }
    ll ans=1;

    int acnt=0,bcnt=0;
    for(int i=0;i<2*N;i++){
        if(S[i]==1){
            if(bcnt>0){
                ans=ans*bcnt%mod;
                bcnt--;
            }else{
                acnt++;
            }
        }
        else{
            if(acnt>0){
                ans=ans*acnt%mod;
                acnt--;
            }
            else{
                bcnt++;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
const int inf = 1e9;
using namespace std;
int di[1010][1010];

struct DATE{
  int left;
  int right;
  int len;
}date[1010];

int main(){
  int n,m,a,b,c;
  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      if(i==j)
        di[i][j]=0;
      else
        di[i][j]=inf;
    }
  }
  for(int i=0;i<m;i++){
    scanf("%d%d%d",&date[i].left,&date[i].right,&date[i].len);
    di[date[i].left][date[i].right]=date[i].len;
    di[date[i].right][date[i].left]=date[i].len;
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        di[j][k]=min(di[j][k],di[i][j]+di[i][k]);
      }
    }
  }
  int ans=m;
  for(int i=0;i<m;i++){
    int kk=0;
    a=date[i].left;b=date[i].right;c=date[i].len;
    for(int j=1;j<=n;j++){
      if(di[j][a]+c==di[j][b])
        kk=1;
    }
    if(kk)
      ans--;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640
//#define M_PI 3.14159265358979323846
#define _USE_MATH_DEFINES

//#define _GLIBCXX_DEBUG
//#define all(x) (x).begin(),(x).end()
#pragma comment(linker,"/STACK:256000000")

#include <bits/stdc++.h>

#define TASK ""
#define sqr(x) ((x)*(x))
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const ll INFLL = numeric_limits<ll>::max();
const ll INFINT = numeric_limits<int>::max();
const ld EPS = 1e-7;
const ll MOD = 1000000000;
const ll MAXN = 123456;

void run()
{
    string s;
    cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4, 8) << endl;
}

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

#ifdef LOCAL
//#define STRESS
#ifdef STRESS
    freopen("input.txt", "w", stdout);
    cout << "1000 50\n";
    for (int i = 0; i < 999; i++)
    {
        for (int j = 0; j < 999; j++) cout << ".";
        cout << "X\n";
    }
    for (int j = 0; j < 1000; j++)
        if (j != 1000 / 50)cout << "X";
        else cout << ".";
    return 0;

#endif
    if (strcmp(TASK, "-") != 0)
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#else
    if (strcmp(TASK, "")   != 0)
    {
        freopen(TASK".in", "r", stdin)  ;
        freopen(TASK".out", "w", stdout)  ;
    }
#endif
    run();

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  char s[1000]={0};
  int i,w;
  scanf("%s",s);
  scanf("%d",&w);
  for(i=0;i<1000;i++){
    if(s[i]==0) break;
    if(i%w==0) printf("%c",s[i]);
  }
  return 0;
}

Measured memory_bytes: 128
N = int(input())
a = list(map(int,input().split()))

ans = 0
a_as = {}

for x in a:
    if x in a_as:
        a_as[x] += 1
    else:
        a_as[x] = 1

for x in a_as:
    if x > a_as[x]:
        ans += a_as[x]
    else:
        ans += abs(a_as[x]-x)
    
print(ans)

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

    int r;
    cin >> r;

    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
  
typedef long long ll;
typedef pair<int, int> ii;
 
#define DEBUG false
 
void dfs(vector<int> v, int n, int u){
     
    if(n == 0) {
        rep(i, v.size()){
            cout << v[i];
            if(i != v.size()-1) cout << " ";
        }
        cout << endl;
        return;
    }
    for(int i = min(n, u); i > 0; i--){
        vector<int> tmp(v);
        tmp.push_back(i);
        dfs(tmp, n-i, i);
    }
     
    return;
}
 
int main(){
 
    int n;
    while(cin >> n, n){
         
        vector<int> null;
        dfs(null, n, n);
         
    }
     
     
     
    return 0;
}

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

const int MAX_N = 1000000;
const int INF = 1000000000;

int dp_nat[MAX_N]; // dp_nat[i]: 数字iを作るための最小の正四面体の個数
int dp_odd[MAX_N]; // dp_odd[i]: 数字iを作るための最小の奇数の正四面体の個数

vector<int> tetras; // 正四面体数
vector<int> odd_tetras; // 奇数の正四面体数

int main() {
  // 正四面体数を事前に計算しておく
  for(int i = 1; 1; i++) {
    int m = i*(i+1)*(i+2)/6;
    if (m > MAX_N) break;
    tetras.push_back(m);
    if (m % 2 != 0) odd_tetras.push_back(m);
  }

  // 入力のnによらずdp_natとdp_oddの中身は同じになるので、入力を読む前に計算しておく

  // 全ての正四面体数を使ったパターン
  dp_nat[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_nat[i] = INF;
    for (int j = 0; j < tetras.size(); j++) {
//    cout << "dbg" << i << "," << dp_nat[i] << endl;
      if (i - tetras[j] < 0) break;
      dp_nat[i] = min(dp_nat[i], dp_nat[i - tetras[j]] + 1);
    }
  }

  // 奇数のみのパターン
  dp_odd[0] = 0;
  for (int i = 1; i < MAX_N; i++) {
    dp_odd[i] = INF;
    for (int j = 0; j < odd_tetras.size(); j++) {
      if (i - odd_tetras[j] < 0) break;
      dp_odd[i] = min(dp_odd[i], dp_odd[i - odd_tetras[j]] + 1);
    }
  }

  int n;
  while(cin >> n, n != 0) {
    cout << dp_nat[n] << " " << dp_odd[n] << endl;
  }
  return 0;
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
n, m, l = list(map(int, input().split()))

a = [0]*n
b = [0]*m
c = [[0 for col in range(l)] for row in range(n)]

for i in range(n):
    a[i] = list(map(int,input().split()))

for i in range(m):
    b[i] = list(map(int,input().split()))


for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k]*b[k][j]
    print(*c[i])

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int w[108],n;
long long int dp[105][100008]={0},v[108];
long long int solve(int i, int c)
{
    long long int ans1,ans2;
    //ans1=0;ans2=0;
    if(i==n+1){return 0;}
    if(dp[i][c]!=-1)
    {return dp[i][c];}
    ans1=solve(i+1,c);
    if((c-w[i])>=0){ans2=solve(i+1,c-w[i])+v[i];}
    else{ans2=0;}
    dp[i][c]=max(ans1,ans2);
    return max(ans1,ans2);
 
}
int main()
{
    int i,W;
    //long long int a;
    cin>>n>>W;
    for(i=0;i<=101;i++)
        for(int j=0;j<=100004;j++)
            dp[i][j]=-1;
        
    for(i=1;i<=n;i++)
    {
        cin>>w[i]>>v[i];
        //cout<<dp[1][i];
    }
    //a=solve(1,W,N);
    cout<<solve(1,W);
}

Measured memory_bytes: 80256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

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

  if (K > (N - 1) * (N - 2) / 2) {
    cout << "-1" << endl;
    return 0;
  }

  vector<string> output;
  for (int i = 2; i <= N; i++) {
    output.push_back(to_string(1) + " " + to_string(i));
  }

  vector<string> storage;
  for (int i = 2; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      storage.push_back(to_string(i) + " " + to_string(j));
    }
  }

  for (int i = 0; i < (storage.size() - K); i++) {
    string str = storage.at(i);
    output.push_back(str);
  }

  cout << output.size() << endl;
  for (int i = 0; i < output.size(); i++) {
    cout << output.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int [] mArray = new int [m+1];
		for(int i = 0; i < n; i++) {
			int k = sc.nextInt();
			int [] aArray = new int [k];
			for(int j = 0; j < k; j++) {
				aArray[j] = sc.nextInt();
				mArray[aArray[j]]++;
			}
		}
		int result = 0;
		for(int i = 1; i < m+1; i++) {
			if(mArray[i] == n) result++;
		}
		System.out.println(result);
		sc.close();
	}

}


Measured memory_bytes: 22736
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    s: Chars
    }
    let p = 1_000_000_007;
    let n = s.len();
    let mut dp = vec![vec![0; 13]; 100005];
    dp[0][0] = 1;
    for i in 0..n {
        let d = if s[i] == '?' { 10 } else { s[i].to_digit(10).unwrap() as usize };
        for j in 0..10{
            if d < 10 && j != d {continue}
            for k in 0..13 {
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                dp[i + 1][(k * 10 + j) % 13] %= p;
            }
        }
    }
    let ans = dp[n][5];
    println!("{}", ans);
}


Measured memory_bytes: 10976
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

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

    while(true){
        int n; cin>>n;
        if(n == 0) return 0;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin>>a[i];

        vector<int> dp(n, 0);
        dp[0] = a[0];
        for(int i=1; i<n; i++){
            dp[i] = max(a[i], dp[i-1] + a[i]);
        }

        cout << *max_element(all(dp)) << endl;
    }

    return 0;
}


Measured memory_bytes: 3196
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::vector<int> ac(n);
	ac[0] = a[0];
	rep(i,n-1) ac[i+1] = ac[i] + a[i+1];
	std::vector<int> A(n,-1);
	{
		int l = 0;
		for(int r=1;r<n-2;r++) {
			while(std::abs(2*ac[l+1]-ac[r])<std::abs(2*ac[l]-ac[r])) l++;
			A[r] = l;
		}
	}
	debug(A);
	std::vector<int> bc(n);
	bc[0] = a[n-1];
	rep(i,n-1) bc[i+1] = bc[i] + a[n-2-i];
	debug(bc);
	std::vector<int> B(n,-1);
	{
		int l = 0;
		for(int r=1;r<n-2;r++) {
			while(std::abs(2*bc[l+1]-bc[r])<std::abs(2*bc[l]-bc[r])) l++;
			B[r] = l;
		}
	}
	debug(B);
	const int INF = 1e18;
	int min = INF;
	for(int i=1;i<n-2;i++) {
		int fi,se,th,fo;
		fi = ac[A[i]];
		se = ac[i]-fi;
		th = bc[B[n-2-i]];
		fo = bc[n-2-i] - th;
		debug(fi,se,th,fo);
		min = std::min(min, std::max({fi,se,th,fo}) - std::min({fi,se,th,fo}));
	}
	print(min);

	return 0;
}


Measured memory_bytes: 8064
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
 
namespace MF {
	#define MAXN 50000
	#define MAXM 500000
	#define wint int
	const wint wEPS = 0;
	const wint wINF = 1001001001;
	int n, m, ptr[MAXN], next[MAXM], zu[MAXM];
	wint capa[MAXM], tof;
	int lev[MAXN], see[MAXN], que[MAXN], *qb, *qe;
	void init(int _n) {
		n = _n; m = 0; memset(ptr, ~0, n * 4);
	}
	void ae(int u, int v, wint w0, wint w1 = 0) {
		next[m] = ptr[u]; ptr[u] = m; zu[m] = v; capa[m] = w0; ++m;
		next[m] = ptr[v]; ptr[v] = m; zu[m] = u; capa[m] = w1; ++m;
	}
	wint augment(int src, int ink, wint flo) {
		if (src == ink) return flo;
		wint f;
		for (int &i = see[src]; ~i; i = next[i]) if (capa[i] > wEPS && lev[src] < lev[zu[i]]) {
			if ((f = augment(zu[i], ink, min(flo, capa[i]))) > wEPS) {
				capa[i] -= f; capa[i ^ 1] += f; return f;
			}
		}
		return 0;
	}
	bool solve(int src, int ink, wint flo = wINF) {
		wint f;
		int i, u, v;
		for (tof = 0; tof + wEPS < flo; ) {
			qb = qe = que;
			memset(lev, ~0, n * 4);
			for (lev[*qe++ = src] = 0, see[src] = ptr[src]; qb != qe; ) {
				for (i = ptr[u = *qb++]; ~i; i = next[i]) if (capa[i] > wEPS && !~lev[v = zu[i]]) {
					lev[*qe++ = v] = lev[u] + 1; see[v] = ptr[v];
					if (v == ink) goto au;
				}
			}
			return 0;
		au:	for (; (f = augment(src, ink, flo - tof)) > wEPS; tof += f);
		}
		return 1;
	}
}
 
int H, W;
char A[110][110];
 
int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		scanf("%s", A[i]);
	}
 
	int s, t;
	MF::init(H * W * 2 + H + W);
 
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			int id = i * W + j;
 
			if (A[i][j] == 'S') s = id;
			if (A[i][j] == 'T') t = id;
 
			if (A[i][j] != '.') {
				MF::ae(id * 2, id * 2 + 1, 1, 0);
				MF::ae(id * 2 + 1, H * W * 2 + j, 1000);
				MF::ae(id * 2 + 1, H * W * 2 + W + i, 1000);
				MF::ae(H * W * 2 + j, id * 2, 1000);
				MF::ae(H * W * 2 + W + i, id * 2, 1000);
			}
		}
	}
	
	MF::solve(s * 2 + 1, t * 2);
	int ret = MF::tof;
	if (ret > 200) ret = -1;
	printf("%d\n", ret);
 
}

Measured memory_bytes: 4992
#include<iostream>
#include<stdio.h>
#include<map>
#include<string>
using namespace std;

int main()
{
	int n;
	cin >> n;
	map<string, bool> T;
	for (int i = 0; i < n; i++)
	{
		char str[10];
		char C[13];
		//cin >> str >> C;
		scanf("%s", &str);
		scanf("%s", &C);
		if (str[0] == 'i')
		{
			T[string(C)] = true;
		}
		else
		{
			if (T[string(C)])
			{
				cout << "yes" << endl;
			}
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 47464
// AOJ 2018 (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2018)
#include<cstdio>
#define rep(i,a) for(int i=0;i<(a);++i)

int N, M, P;

int main()
{
	while( scanf( "%d%d%d", &N, &M, &P ), N|M|P )
	{
		int S = 0, cnt = 0;
		rep( i, N )
		{
			int X;
			scanf( "%d", &X );
			S += X*100;

			if( i == M-1 )
				cnt = X;
		}

		S *= (100-P);
		S /= 100;

		printf( "%d\n", cnt?S/cnt:0 );
	}

	return 0;
}

Measured memory_bytes: 1028
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
  long h,w,num[10]={},a,b;
  int n,cnt=0;
  vector<pair<long,long>> p;
  scanf("%ld %ld %d",&h,&w,&n);
  for(int i=0;i<n;i++){
    scanf("%ld %ld",&a,&b);
    for(long j=max((long)1,a-2);j<=min(a,h-2);j++)
      for(long k=max((long)1,b-2);k<=min(b,w-2);k++)
        p.push_back(make_pair(j,k));
  }
  a=b=0;
  sort(p.begin(),p.end());
  p.push_back(make_pair(h+1,w+1));
  for(int i=0;i<p.size();i++){
    if(a==p[i].first&&b==p[i].second)
      cnt++;
    else{
      num[cnt]++;
      cnt=1;
      a=p[i].first;
      b=p[i].second;
    }
  }
  num[0]=(h-2)*(w-2);
  for(int i=1;i<=9;i++)
    num[0]-=num[i];
  for(int i=0;i<10;i++)
    printf("%ld\n",num[i]);
}

Measured memory_bytes: 18408
/*
***AUTHOR***
*ADVAITVD99*
*/
#include<bits/stdc++.h>
#define MOD (long long)1e9+7
using namespace std;


int main(){
	clock_t tim;
    tim = clock();

    {
		long long a,b,c,d;
		cin>>a>>b>>c>>d;
		long long res;
		res=max(a*c,max(a*d,max(b*c,b*d)));
		cout<<res<<endl;
	}

    //tim = clock() - tim;
    //double time_taken = ((double)tim)/CLOCKS_PER_SEC;
    //cout<< fixed << setprecision(3) << time_taken << "seconds" <<endl;

	return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

struct UnionFind{
    vector<int> branch;
    UnionFind(int N = 0) : branch(N,-1){}

    int find(int x){
        if(branch[x] < 0) return x;
        else return branch[x] = find(branch[x]);//メモ化、要素を入れて根が返ってくる
    }

    bool unite(int x, int y){
        int rx,ry;
        rx = find(x);
        ry = find(y);
        if(rx == ry) return false;//連結できたかどうか
        if(-branch[rx] < -branch[ry]) swap(rx,ry);
        branch[rx] += branch[ry];//木のサイズを負の値で管理
        branch[ry] = rx;
        return true;
    }

    bool same(int x, int y){
        if(find(x) == find(y)) return true;
        else return false;
    }

    int size(int x){
        return -branch[find(x)];
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind il(n);
    vector<pair<int,int>> bg(m);
    vector<ll> can;

    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        bg[i] = {a,b};
    } 
    reverse(bg.begin(),bg.end());
    for(int i = 0; i < m; i++){
        if(il.same(bg[i].first,bg[i].second)) can.push_back(0);
        else can.push_back(il.size(bg[i].first)*il.size(bg[i].second));
        il.unite(bg[i].first,bg[i].second);
    }
    reverse(can.begin(),can.end());
    ll now = 0;
    for(int i = 0; i < m; i++){
        now += can[i];
        cout << now << endl;
    }
    return 0;
}

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

int main(){
  int N;
  int L[100];
  int maxL = 0;
  int sum = 0;
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> L[i];
  }
  for ( int i = 0; i < N; i++ ) {
    maxL = max(maxL,L[i]);
    sum += L[i];
  }
  if ( maxL < sum - maxL ) cout << "Yes" << endl;
  else cout  << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;
 

 
const int INF = 1000000;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;
	char c;
	char str[1024];
	string s;
	ll l;
	int nextInt(){
		scanf("%d", &n);
		return n;
	}
	ll nextLong(){
		scanf("%lld", &l);
		return l;
	}
	char nextChar(){
		scanf("%c", &c);
		return c;
	}
	string next(){
		scanf("%s", str);
		return string(str);
	}
	string nextLine(){
		getline(cin, s);
		return s;
	}
};
Input in;


bool d[5010][5010];
int x[3010], y[3010];

int n, ans = 0;

bool f(int x, int y, int dx, int dy){
	int nx = x + dy;
	int ny = y + dx;
	if(nx < 0 || nx >= 5000 || ny < 0 || ny >= 5000 || !d[nx][ny]) return false;
	nx -= dx;
	ny += dy;
	if(nx < 0 || nx >= 5000 || ny < 0 || ny >= 5000 || !d[nx][ny]) return false;

	return true;
}

int main(){
	while(1){
		n = in.nextInt();
		ans = 0;
		rep(i, 5010) rep(j, 5010) d[i][j] = false;
		if(n == 0) break;
		rep(i, n){
			x[i] = in.nextInt();
			y[i] = in.nextInt();
			d[x[i]][y[i]] = true;
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < i; j++){
				int dx = x[i]-x[j];
				int dy = y[i]-y[j];
				int len = dx*dx+dy*dy;
				if(len <= ans) continue;
				if(f(x[i], y[i], dx, dy) || f(x[i],y[i], dx, -dy)) ans = len;
			}
		}

		cout<<ans<<endl;
	}
}

Measured memory_bytes: 25744