akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

char s[2001], t[2001];
int dp[2001][2001][2];
int main() {
	int m, n; scanf("%d%d%s%s", &m, &n, s, t);
	int Max = 0;
	rep(i, m + 1)rep(j, n + 1) {
		int x = m - i, y = n - j;
		if (x < m) {
			if (s[x] == 'I')dp[i][j][0] = dp[i - 1][j][1] + 1;
			else if (dp[i - 1][j][0])dp[i][j][1] = dp[i - 1][j][0] + 1;
		}
		if (y < n) {
			if (t[y] == 'I')dp[i][j][0] = max(dp[i][j][0], dp[i][j - 1][1] + 1);
			else if (dp[i][j - 1][0])dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][0] + 1);
		}
		Max = max(Max, dp[i][j][1] - 1);
		Max = max(Max, dp[i][j][0]);
	}
	printf("%d\n", Max);
}

Measured memory_bytes: 34504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    char a[11];
    int b[11],j,i,len,s,k;
    scanf("%s",a);
    len=strlen(a);
    memset(b,0,sizeof(b));
    j=0;
    for(i=0;i<len;i++)
    {
        if(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G')
        {
            k=i;
            while(a[k]=='A'||a[k]=='T'||a[k]=='C'||a[k]=='G')
            {
                k++;
                b[j]++;
            }
            j++;
        }
    }
    s=0;
    for(i=0;i<j;i++)
    {
        s=max(s,b[i]);
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 256
$l=length($S=<>)-1;
for$p(0..(1<<$l-1)-1){
	$s=$S;
	$p&1<<($t=-$_)-1&&$s=~s/^\d{$t}\K/+/ for-$l+1..-1;
	$%+=eval$s;
}
print$%,$/

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>








const int N = 20;
ll n, m, x, prc[N], lvl[N][N], res, ttlPrc, ttlLvl[N];
bool vld;





void solve()
{
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++)
	{
		cin >> prc[i];
		for(int j = 0; j < m; j++)
		{
			cin >> lvl[i][j];
		}
	}
	res = -1;
	for(int i = 0; i < (1 << n); i++)
	{
		for(int k = 0; k < m; k++)ttlLvl[k] = 0;
		ttlPrc = 0;
		for(int j = 0; j < n; j++)
		{
			if(i&(1 << j))
			{
				ttlPrc += prc[j];
				for(int k = 0; k < m; k++)
				{
					ttlLvl[k] += lvl[j][k];
				}
			}
		}
		vld = true;
		for(int k = 0; k < m; k++)
		{
			if(ttlLvl[k] < x)
			{
				vld = false;
				break;
			}
		}
		if(vld && (res==-1||res>ttlPrc))
		{
			res = ttlPrc;
		}
	}
	cout << res << "\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N,Q;
	SCD2(N,Q);
	
	static ll a[100002];
	
	
	REP(i,N){
		scanf("%d",&a[i]);
	}
	
	REP(q,Q){
		ll x; scanf("%lld",&x);
		ll res = 0;
		ll sum = 0;
		int right = 0;
			
		REP(left,N){
			while(right < N && sum + a[right] <= x){
				sum += a[right];
				right++;
			}
			
			res += (right - left);
			
			if (right == left) right++;
			else sum -= a[left];
		}
		
		PRINTLLD(res);
	}
	
	
	return 0;
}



Measured memory_bytes: 4000
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}
};




int main()
{	
	char c; cin>> c;
	cout<< char(c+1);
	return 0;
}


Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    a = i_list()

    k = [0]
    for i in range(2*10**5):
        k.append(k[i]+(i+1))
    t = a.copy()
    t.sort()

    s = 0

    m = [0]*n

    for i,n in itertools.groupby(t):
        l = len(list(n))
        s += k[l-1]
        if l > 1:
            m[i-1] = k[l-2] - k[l-1]

    for i in a:
        print(s + m[i-1])







if __name__=="__main__":
    main()


Measured memory_bytes: 33832
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  private static final Long MOD = 1000000007L;

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    String s = sc.next();
    int n = s.length();
    long[][] dp = new long[n][13];

    if (s.charAt(0) == '?') {
      for (int d = 0; d <= 9; d++) {
        dp[0][d] = 1;
      }
    } else {
      int d = s.charAt(0) - '0';
      dp[0][d] = 1;
    }

    for (int i = 1; i < n; i++) {
      if (s.charAt(i) == '?') {
        for (int d = 0; d <= 9; d++) {
          for (int j = 0; j < 13; j++) {
            int mod = (j * 10 + d) % 13;
            dp[i][mod] = (dp[i][mod] + dp[i - 1][j]) % MOD;
          }
        }
      } else {
        int d = s.charAt(i) - '0';
        for (int j = 0; j < 13; j++) {
          int mod = (j * 10 + d) % 13;
          dp[i][mod] = (dp[i][mod] + dp[i - 1][j]) % MOD;
        }
      }
    }
    os.println(dp[n - 1][5]);
  }
}

Measured memory_bytes: 38060
using System;

namespace ABC077_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var B = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var C = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var count = 0L;
            Array.Sort(A);
            Array.Sort(C);
            for(var i=0;i<n;i++)
            {
                var x = m1(B[i], A, 0, n - 1);
                var y = n - m1(B[i] + 1, C, 0, n - 1);
                count += x * y;
            }
            Console.WriteLine(count);
        }

        static long m1(int n, int[] a, long x, long y)
        {
            var z = (x + y) / 2;
            if (y < x)
            {
                return x;
            }
            else if (a[z] < n)
            {
                return m1(n, a, z + 1, y);
            }
            else
            {
                return m1(n, a, x, z - 1);
            }
        }
    }
}


Measured memory_bytes: 44496
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x1=sc.nextInt();
		int y1=sc.nextInt();
		int x2=sc.nextInt();
		int y2=sc.nextInt();
		StringBuilder buff = new StringBuilder();
		String voi="";
		for(int i=0; i<x2-x1; i++) {
			buff.append("R");
		}
		for(int i=0; i<y2-y1; i++) {
			buff.append("U");
		}
		for(int i=0; i<x2-x1; i++) {
			buff.append("L");
		}
		for(int i=0; i<y2-y1+1; i++) {
			buff.append("D");
		}
		for(int i=0; i<x2-x1+1; i++) {
			buff.append("R");
		}
		for(int i=0; i<y2-y1+1; i++) {
			buff.append("U");
		}
		buff.append("LU");
		for(int i=0; i<x2-x1+1; i++) {
			buff.append("L");
		}
		for(int i=0; i<y2-y1+1; i++) {
			buff.append("D");
		}
		buff.append("R");
		System.out.println(buff.toString());
	}
}

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

class triangle
{
private:
	double a, b, C, S, L, h;
public:
	triangle(double edge1, double edge2, double angle);
	~triangle(){;}
	void calc_area();
	void calc_around();
	void calc_height();
	void print_();

};

triangle::triangle(double edge1, double edge2, double angle)
{
	a = edge1;
	b = edge2;
	C = angle;
}

void triangle::calc_area()
{
	S = (a * b * sin(C)) / 2;
}

void triangle::calc_around()
{
	L = a + b + sqrt(pow(a, 2.0) + pow(b, 2.0) - 2 * a * b * cos(C));
}

void triangle::calc_height()
{
	h = b * sin(C);
}

void triangle::print_()
{
	printf("%lf\n", S);
	printf("%lf\n", L);
	printf("%lf\n", h);	
}



int main(int argc, char const *argv[])
{
	int count = 3;
	double input[3];
	for (int i = 0; i < count; ++i)
	{
		cin >> input[i];
	}
	triangle abc(input[0], input[1], M_PI * input[2] / 180);
	abc.calc_area();
	abc.calc_around();
	abc.calc_height();

	abc.print_();

	return 0;
}

Measured memory_bytes: 1284
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
    int k;
    cin>>k;
    for(int i=0;i<n;i++){
    	if(s[i]==s[k-1]){
    	}
    	else{
    			s[i]='*';
    	}
    }
	cout<<s<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

// 1ÌÆ«trueÉÈÁÄàCÉµÈ¢
bool isPrime(int x){
	for(int i = 2, lim = sqrt(x); i <= lim; ++i){
		if(x % i == 0){ return false; }
	}
	return true;
}

bool table[1000001];

int main(){
	while(true){
		int n, x;
		cin >> n >> x;
		if(n == 0 && x == 0){ break; }
		memset(table, 0, sizeof(bool) * 1000001);
		table[0] = true;
		while(n--){
			int price;
			cin >> price;
			for(int i = 0; i <= x - price; ++i){
				if(table[i]){ table[i + price] = true; }
			}
		}
		int sum = 0;
		for(int i = x; i > 0; --i){
			if(table[i] && isPrime(i)){
				sum = i;
				break;
			}
		}
		if(sum == 0){
			cout << "NA" << endl;
		}else{
			cout << sum << endl;
		}
	}
	return 0;
}

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

typedef long long ll;
#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;
    cin >> N;
    vector<ll> array(N,0);
    REP(i, N){ cin >> array[i];}

    ll ans = 100000000;
    REP(i, 100){
        ll cur = 0;
        for(auto v : array){
            cur += (v - i) * (v - i);
        }
        ans = min(cur, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a,b,c,d,x;
  
  scanf("%d %d %d %d", &a, &b, &c, &d);
  
  if(a < c){
    if(b < d){
      x = b - c;
    }else{
      x = d - c;
    }
  }else{
    if(b > d){
      x = d - a;
    }else{
      x = b - a;
    }
  }
  
  if(x > 0){
    printf("%d\n", x);
  }else{
    printf("0\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){

	int i;
	int n;
	scanf("%d",&n);
	int a[n];
	int b[n];
	int count =0;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i] = 0;
	}
	for(i=0;i<n-1;i++){
		if(b[i]!=0){
			continue;
		}
		if(a[a[i]-1]==i+1){
			count++;
			b[a[i]-1]++;
		}
	}
	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int N=5100;
int k,q,d[N],s[N],n,x,m;
int num(int p)
{
	return x+((p-1)/k)*s[k-1]+s[(p-1)%k];
}
signed main()
{
	scanf("%lld%lld",&k,&q);
	for (int i=0;i<k;i++) scanf("%lld",&d[i]);
	while (q--)
	{
		scanf("%lld%lld%lld",&n,&x,&m);
		n--;
		int cnt=0;
		for (int i=0;i<k;i++) cnt+=(d[i]%m==0);
		cnt=cnt*((n-1)/k);
		for (int i=((n-1)/k)*k+1;i<=n;i++)
		  cnt+=(d[(i-1)%k]%m==0);
		s[0]=d[0]%m;
		for (int i=1;i<k;i++) s[i]=s[i-1]+(d[i]%m);
//		printf("%d\n",num(n));
		cnt+=num(n)/m-x/m;
		printf("%lld\n",n-cnt);
	}
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var N = inputArray[0];
			var S = retreiveStringArray()[0];

			var RPositionList = new List<int>();
			var GPositionList = new List<int>();
			var BPositionList = new List<int>();

			//R,G,Bそれぞれの位置を格納する
			for (int i = 0; i < N; i++) {
				var cha = S[i];
				if (cha == 'R') {
					RPositionList.Add(i);
				}
				else if (cha=='G'){
					GPositionList.Add(i);
				}
				else {
					BPositionList.Add(i);
				}
			}

			//要素が一つもないRGBがある場合、0
			if(RPositionList.Count()==0 | GPositionList.Count() == 0|BPositionList.Count() == 0) {
				Console.WriteLine(0);
				return;
			}
			long sum = RPositionList.Count() * GPositionList.Count();
			sum=sum*BPositionList.Count();

			//i-j=j-kとなるものを除くことを考える
			var exclude = 0;
			foreach (var r in RPositionList) {
				foreach (var g in GPositionList) {
					//bとして選べない数を調べる

					if ((r + g) % 2 == 0) {
						var candicate = (r + g) / 2;
						if (BPositionList.Contains(candicate)) {
							exclude++;
						}
					}
					//bがg or r　の外側にある場合
					var candicate2 = g + g - r;
					var candicate3 = r+r-g;
					if (BPositionList.Contains(candicate2)) {
						exclude++;
					}
					if (BPositionList.Contains(candicate3)) {
						exclude++;
					}

				}
			}
	

			//答えの出力
			var ans = sum-exclude;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28368
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    
        Scanner sc = new Scanner(System.in);
        
        String a = sc.next();
        String b = sc.next();
        String num = a + b;
        int ab = Integer.parseInt(num);

        boolean state = false;
        for(int i = 0; i <= ab; i++){
            if(i*i == ab){
                state = true;
                break;
            }
        }
        System.out.println(state ? "Yes" :"No");
    }
}


Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 100007;
const int K = 5000;
int b[N], a[N], c[N];
map < int, int > cnt, ind;
int solve(int l, int r){
    if (l == r) return 1;
   int res = 0;
  // cout << l << " " << r << endl;
    for (int i = 61; i >= 0; i--){
        if ((l & (1LL << i)) && (r & (1LL << i))){
            r ^= (1LL << i);
            l ^= (1LL << i);
        } else
        if (r & (1LL << i)){
            int c = 1;
            int j = i;
            int ol = l;
            if (l == 0){
                return (1LL << (j + 1));
            }
            while((l & (1LL << i)) == 0){
                c += c;
                i--;
            }
            int z = j - 1;
            while (!(r & (1LL << z))){
                z--;
                if (z == -1)
                    break;
            }
         //   cout << z << " " << c << " " << i << endl;
            int q = (1LL << (z + 1));
          //  cout << q << " "  << l << endl;
            if (q >= l){
                return (1LL << j) + (c / 2 - 1) * ((1LL << (i + 1))) + ((1LL << (i + 1))) - l;
            }
            int res = (c / 2 - 1) * ((1LL << (i + 1))) + ((1LL << (i + 1))) - ol + q + (1LL << j) - l;
           // cout << res << " -- " << l << " " << r << " " << (c / 2 - 1) * ((1LL << (i + 1))) << " " << ((1LL << (i + 1))) - l << " " << (1LL << j) << endl;
            return res;
        }
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int l, r;
    int n;
    cin >> l >> r;
    cout << solve(l, r);
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;



//??????
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int i = 1; i < N; i++) cout << ", " << v[i]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()


int main()
{
	bool blank = false;
	while (true) {

		map<int, vector<string>> standings;

		int n;
		cin >> n;
		if (n == 0) break;

		if (blank) cout << endl;

		string name;
		int w, l, d;
		for (int i = 0; i < n; i++) {
			cin >> name >> w >> l >> d;
			int score = w * 3 + d;
			standings[-score].push_back(name);
		}

		for (auto itr = standings.begin(); itr != standings.end(); itr++) {
			for (int i = 0; i < itr->second.size(); i++) {
				cout << itr->second[i] << "," << - itr->first << endl;
			}
		}

		blank = true;

	}

	return 0;
}

Measured memory_bytes: 3156
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
  int i;
  int a,b,k;
  int p,q;

  scanf("%d %d %d",&a,&b,&k);

  for(i=1; i<=k; i++){
    if(i%2==1){
      if(a%2==0){
        p = a/2;
      }else if(a%2!=0){
        a = a-1;
        p = a/2;
      }
      a = p;
      b = b + p;
    }else{
      if(b%2==0){
        q = b/2;
      }else if(b%2!=0){
        b = b-1;
        q = b/2;
      }
      a = a + q;
      b = q;
    }
  }

  printf("%d %d\n",a,b);

  return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

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

    // 作る時はParentの値を全て-1にする
    // こうすると全てバラバラが表現できる。
    UnionFind(int N) {
      Parent = vector<int>(N, -1);
    }

    // Aがどのグループに属しているか調べる
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
    int size(int A) {
      return -Parent[root(A)]; // 親を取ってきたい
    }

    bool connect(int A, int B) {
      // AとBを直接繋ぐのではなく、root(A)をroot(B)をくっつける
      A = root(A);
      B = root(B);
      if(A == B) {
        //すでにくっついているからくっつけない
        return false;
      }

      // 大きい方に小さい方をくっつけたい
      // 代償が逆だったらひっくり返す
      if(size(A) < size(B)) swap(A, B);
      // Aのsizeを更新
      Parent[A] += Parent[B];
      // Bの親をAに変更する
      Parent[B] = A;

      return true;
    }
};

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

  vector<long long> ans(M);
  ans[M-1] = (long long)N*(N-1) / 2;
  UnionFind Uni(N);
  for(int i = M-1; i >= 1; --i) {
    if(Uni.root(A[i]) !=  Uni.root(B[i])) {
      ans[i-1] = ans[i] - (long long)Uni.size(A[i]) * Uni.size(B[i]);
      Uni.connect(A[i], B[i]);
    } else ans[i-1] = ans[i];
  }

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

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

int n, q;
char s[200010];
char t[200010];
char d[200010];
int nl, nr, ans;

int endState(const char s[], const char t[], const char d[], int n, int q, int p){
    // 0: left
    // 1: middle
    // 2: right
    for (int i = 0; i < q; ++i){
        if (s[p] == t[i]){
            if (d[i] == 'L') p--;
            else p++;
            if (p == -1) return 0;
            if (p == n) return 2;
        }
    }
    return 1;
}

int binarySearch(const char s[], const char t[], const char d[], int n, int q, int key, int imin, int imax){
    // key: end state
    if (imax < imin) return -1;
    else{
        int imid = imin + (imax - imin) / 2;
        int smid = endState(s, t, d, n, q, imid);
        if (smid > key){
            return binarySearch(s, t, d, n, q, key, imin, imid - 1);
        }
        else if (smid < key){
            return binarySearch(s, t, d, n, q, key, imid + 1, imax);
        }
        else{
            int snext = endState(s, t, d, n, q, imid+(1-key));
            if (snext != smid){
                return imid;
            }
            else{
                if (key == 0){
                    return binarySearch(s, t, d, n, q, key, imid + 1, imax);
                }
                else{
                    return binarySearch(s, t, d, n, q, key, imin, imid - 1);
                } 
            }
        }
    }
}

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

    for (int i = 0; i < q; ++i){
        cin >> t[i] >> d[i];
    }

    if (n == 1) cout << (endState(s, t, d, n, q, 0) == 1);
    else if (n == 2) cout << ((endState(s, t, d, n, q, 0) == 1) + (endState(s, t, d, n, q, 1) == 1));
    else{
        nl = binarySearch(s, t, d, n, q, 0, 0, n-1);
        nl = (nl >= 0) ? nl + 1 : 0;
        nr = binarySearch(s, t, d, n, q, 2, 0, n-1);
        nr = (nr >= 0) ? n - nr : 0;
        ans = n - (nl + nr);
        cout << ans;
    }
}

Measured memory_bytes: 768
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];


int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast
cin >> n >> k;
while(k--)
{
	cin >> m;
	while(m--)
	{
		cin >> l;
		a[l]++;
	}
}
ll ans = 0;
fr(i,1,1+n)
	if(a[i] == 0)
		ans++;
cout << ans;
  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
const ll nmax=1000000;


ll fac[nmax],finv[nmax],inv[nmax];

void comint(){
 fac[0]=fac[1]=1;
 finv[0]=finv[1]=1;
 inv[1]=1;
 for(ll i=2;i<nmax;i++){
  fac[i]=fac[i-1]*i%mod;
  inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  finv[i]=finv[i-1]*inv[i]%mod;
}
}

ll com(ll n, ll k){
 if(n<k||n<0||k<0) return 0;
 return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

void solve(){
  ll s;
  cin >> s;
  ll n=s/3;
  comint();
  mint ans=0;
  rep(k,1,n+1){
   ans+=com(s-k*3+k-1,s-3*k);
  }
  cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 27128
function main(input) {
    const numbers = input.split("\n")[0];
    const list = input.split("\n")[1].split(" ").map(v => Number(v));

    const maxList = Math.max(...list);
    const minList = Math.min(...list);
    const calcCost = (org, mod) => (org - mod) ** 2;

    const costs = [];
    for (let testNumber = minList; testNumber <= maxList; testNumber++) {
        let cost = 0;
        for (let i = 0; i < list.length; i++) {
            cost += calcCost(list[i], testNumber);
        }
        costs.push({ testNumber, cost });
    }
    let costsSort = costs.sort((a, b) => a.cost - b.cost)
    // console.log('costsSort', costsSort);
    console.log(costsSort[0].cost);

}

// let input = "2"+ '\n' + "4 8"; //8
// let input = "3" + '\n' + "1 1 3"; //3
// let input = "3" + '\n' + "4 2 5"; //5
// let input = "4" + '\n' + "-100 -100 -100 -100"; //0

// main(input);
main(require("fs").readFileSync("/dev/stdin","utf8"));
  

Measured memory_bytes: 31520
package main

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

func main() {
	scanInit()
	n := scanInt()
	a := make([]int,n+1) // 0はつかわないようにする
	// numbers := map[int]int{}
	for i:=1; i<=n; i++ {
		number := scanInt()
		a[i] = number
		//if _,ok := numbers[number]; !ok {
		//	numbers[number] = 0
		//}
		// numbers[number] += 1
	}
	// fmt.Println(numbers)
	sum := 0
	// j-Aj = Ai+i
	a_i := make(map[int]map[int]int)
	for i:= 1; i<=n; i++ {
		if _,ok := a_i[a[i]+i]; !ok{
			a_i[a[i]+i] = map[int]int{}
		}
		a_i[a[i]+i][i] = 1
	}
	for j:=1; j<=n; j++{
		if _,ok := a_i[j-a[j]]; ok{
			// まずその配列があるかどうか
			if _,ok := a_i[j-a[j]][j]; ok {
				sum += len(a_i[j-a[j]]) - 1
			} else {
				sum += len(a_i[j-a[j]])
			}
		}
	}
	fmt.Println(sum)

}
var sc = bufio.NewScanner(os.Stdin)
func scanInit () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
//func scan () string{
//  sc.Scan()
//	return sc.Text()
//}

Measured memory_bytes: 52080
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main() 
{
	while (1) 
	{
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0)break;
		map<int, string>s;
		s.insert(pair<int, string>(a + b, "A"));
		cin >> a >> b;
		s.insert(pair<int, string>(a + b, "B"));
		cin >> a >> b;
		s.insert(pair<int, string>(a + b, "C"));
		cin >> a >> b;
		s.insert(pair<int, string>(a + b, "D"));
		cin >> a >> b;
		s.insert(pair<int, string>(a + b, "E"));
		auto p = s.end();
		p--;
		cout << p->second << " " << p->first << endl;
	}
}

Measured memory_bytes: 2992
import io.StdIn._
 
object Main extends App {
  val regex = "[0-9a-zA-Z]+".r
  (readLine, readLine) match {
    case (l1, l2)
        if 1 <= l1.length && l1.length <= 10 && regex.matches(l1) && l2.startsWith(l1) && l1.length + 1 == l2.length =>
      println("Yes")
    case _ => println("No")
  }
}

Measured memory_bytes: 54612
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int N,Q;
int p[100000];
char op[100000];
int v[100000];
bool is_painted[100000];

/////////
int par[100000+10], ranks[100000+10];

void init(int m){
	REP(i,m){
		par[i]=i;
		ranks[i]=0;
	}
}

int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}

void unite(int x, int y){
	x=find(x); y=find(y);
	if(x==y) return;
	if(ranks[x]<ranks[y])par[x]=y;
	else{
		par[y]=x;
		if(ranks[x]==ranks[y])ranks[x]++;
	}
}

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

int main(){
	while(1){
		cin>>N>>Q;
		if(N==0&&Q==0)break;
		p[0]=0;
		FOR(i,1,N){
			scanf("%d", &p[i]);
			p[i]--;
		}
		REP(i,N) is_painted[i]=false;
		is_painted[0]=true;
		REP(i,Q){
			cin>>op[i]>>v[i];
			v[i]--;
			if(op[i]=='M'){
				if(is_painted[v[i]]){
					i--; Q--; continue;
				}
				is_painted[v[i]]=true;
			}
		}
		init(N);
		REP(i,N){
			if(!is_painted[i]) unite(i,p[i]);
		}
		ll res = 0;
		for(int i=Q-1;i>=0;i--){
			if(op[i]=='Q'){
				int nv = v[i];
				while(nv!=0&&same(nv,p[nv])) nv=p[nv];
				res+=nv+1;
				//dbg(nv);
			}else if(op[i]=='M'){
				unite(v[i],p[v[i]]);
				//dbg(v[i]);
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), sum(n + 1, 0);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= k;
    }
    if(k == 1) {
        cout << 0 << endl;
        return 0;
    }
    for(ll i = 0; i < n; i++) {
        // cout << sum[i] << ' ';
        sum[i + 1] = (sum[i] + a[i]) % k;
        assert(0 <= sum[i + 1] && sum[i + 1] < k);
    }
    // cout << sum[n] << endl;
    map<ll, ll> cnt;
    cnt[0] = 1;
    ll ans = 0;
    for(ll i = 1; i <= n; i++) {
        ll v = ((sum[i] - i) % k + k) % k;
        // cout << v << endl;
        assert(0 <= v && v < k);
        ans += cnt[v];
        cnt[v]++;
        if(i - k + 1 >= 0) {
            ll j = i - k + 1;
            ll w = ((sum[j] - j) % k + k) % k;
            assert(0 <= w && w < k);
            cnt[w]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Mat = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5+10;

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

    sort(all(a));
    printf("%lld\n",abs(a[n-1]-a[0]));
    return 0;
}


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

using namespace std;

struct Range
{
	int l,r,sz;
	Range(){}
}R[300001];

bool operator < (const Range &a, const Range &b)
{
	return a.sz < b.sz;
}

int n,m;
int ans[100011];
int Tree[100011];

void update(int x,int val)
{
	for(;x<=100010;x+=x&(-x))
		Tree[x] += val;
}

int query(int x)
{
	int ans = 0;
	for(;x>0;x-=x&(-x))
		ans += Tree[x];
	return ans;	
}

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

	cin >> n >> m;
	for (int i=1;i<=n;i++)
	{
		cin >> R[i].l >> R[i].r;
		R[i].sz = (R[i].r - R[i].l + 1);
	}	
	sort(R+1,R+1+n);
	int pos = 1;
	for (int i=1;i<=m;i++)
	{
		while(pos <= n && R[pos].sz < i)
		{
			update(R[pos].l,1);
			update(R[pos].r+1,-1);
			pos++;
		}
		ans[i] = (n - pos + 1);
		for (int j=i;j<=m;j+=i)
			ans[i] += query(j);
	}	
	for (int i=1;i<=m;i++)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 7920
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.charAt(0) == s.charAt(1) || s.charAt(2) == s.charAt(1)||s.charAt(3) == s.charAt(2)) {
			System.out.println("Bad");
		}else {
			System.out.println("Good");
		}
		
	}
}

Measured memory_bytes: 22228
#include <cstdio>
//#include <iostream>
//#include <string>

using namespace std;

// cl /EHsc xxx.cpp
inline char toc(int i)
{
	switch (i)
	{
	case 0:
		return 'S';
		break;
	case 1:
		return 'H';
		break;
	case 2:
		return 'C';
		break;
	case 3:
		return 'D';
		break;
	}
	return 'X';
}
int main(int argc, char *argv[])
{
	int n;
	scanf("%d ", &n);
	
	int cards[4][13] = {0};
	
	int t = n;
	while (t)
	{
		//scanf("%c %d ", &c0, &v);
		char buff[1024] = {0};
		gets(buff);
		//printf("%s\n", buff);
		
		char c0;
		int v;
		sscanf(buff, "%c %d", &c0, &v);
		switch (c0)
		{
		case 'S':
			cards[0][v-1] = 1;
			break;
		case 'H':
			cards[1][v-1] = 1;
			break;
		case 'C':
			cards[2][v-1] = 1;
			break;
		case 'D':
			cards[3][v-1] = 1;
			break;
		default:
			break;
			//printf("c0=%d\n", c0);
		}
		t--;
		//printf("!!!!!!t=%d\n", t);
	}
	
	for (int r = 0; r < 4; r++)
	{
		for (int c = 0; c < 13; c++)
		{
			if (cards[r][c] == 0)
			{
				printf("%c %d\n", toc(r),c+1);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M;
    cin >>N;
    map<string,ll>m;
    rep(i,N){
        string S;
        cin>>S;
        m[S]++;
    }
    cin>>M;
    rep(i,M){
        string S;
        cin>>S;
        m[S]--;
    }
    ll ans=0;
    for (const auto& [key, value] : m){
        chmax(ans,value);
    }

    cout << ans << endl;


    return 0;
    

}

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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#ifdef LOCAL
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else 
#define dump(x) true
#endif

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int L = TEN(6) + 10;

int main() {
	int N; cin >> N;
	V<int> A(N); rep(i, N-1) cin >> A[i];
	int M; cin >> M;

	deque<int> dp;
	rep(i, L) dp.pb(i);

	for (int i = 2; i < N-1; ++i) {
		for (int j = 1; j <= A[i]; ++j) {
			dp.push_front(dp[j*2-1]);
		}
	}

	rep(i, M) {
		int X;
		cin >> X;

		int ans;

		if (X >= dp.size()) {
			ans = dp.back() + (X - dp.size() + 1);
		} else {
			ans = dp[X];
		}

		ans += A[0] - A[1];
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 11148
inputs = []

while true
  h, w = $stdin.readline.split(" ").map {|s| s.to_i }

  if h == 0 && w == 0
    break
  end

  inputs.push([h, w])
end

inputs.each do |h, w|
  (1..h).each_with_index do |y, i|
    if i % 2 == 0
      (1..w).each do |x|
        if x % 2 == 0
          print "."
        else
          print "#"
        end
      end
      puts
    else
      (1..w).each do |x|
        if x % 2 == 0
          print "#"
        else
          print "."
        end
      end
      puts
    end
  end

  puts
end



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

int main(){
	long long n, k, x, y;
	cin >> n >> k >> x >> y;
	long long sum = 0;
	for (int i = 0; i < n; i++){
		if (i < k)
			sum += x;
		else
			sum += y;
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>


using namespace std;

class CSolver{
public:
	CSolver();
	int solve();
	int in_S_;
	int out_h_;
	int out_m_;
	int out_s_;
};

CSolver::CSolver(){
	in_S_ = 0;
};

int CSolver::solve(){
	scanf("%d", &in_S_);
	out_h_ = in_S_ / 3600;
	out_m_ = (in_S_ % 3600) / 60;
	out_s_ = (in_S_ % 3600) % 60;
	printf("%d:%d:%d\n", out_h_ , out_m_ , out_s_);
	return 0;
};

int main(){

	CSolver mysol;

	mysol.solve();

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

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

    string hoge; cin >> hoge;
    int slen = hoge.length();
    string s = "0";
    s += hoge;

    // sをi文字目まで見て、カウントをjまでつけるような場合の数
    vector< vector<ll> > dp(100005, vector<ll>(4, 0));
    dp[0][0] = 1;

    for(int i=0; i<slen; ++i){
        for(int j=0; j<4; ++j){
            if(s[i+1] != '?') dp[i+1][j] += dp[i][j];
            else { dp[i+1][j] += 3*dp[i][j]; chmod(dp[i+1][j]); }
        }
        if(s[i+1] == 'A'){
            // count
            dp[i+1][1] += dp[i][0];
        }
        else if(s[i+1] == 'B'){
            // count
            dp[i+1][2] += dp[i][1];
        }
        else if(s[i+1] == 'C'){
            // count
            dp[i+1][3] += dp[i][2];
        }
        else{
            // count
            dp[i+1][1] += dp[i][0];
            dp[i+1][2] += dp[i][1];
            dp[i+1][3] += dp[i][2];
        }

        for(int j=0; j<4; ++j) chmod(dp[i+1][j]);
    }

    cout << dp[slen][3] << endl;

    // for(int i=0; i<=slen; ++i){
    //     for(int j=0; j<4; ++j){
    //         cout << dp[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    
	return 0;
}


Measured memory_bytes: 7504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;

int main(){
  int i,j;
  ll n,k;
  cin>>n>>k;
  ll a[n];
  ll f[n];
  for(i=0;i<n;i++) cin>>a[i];
  for(i=0;i<n;i++) cin>>f[i];
  sort(a,a+n);
  sort(f,f+n,greater<ll>());
  ll le=-1;
  ll ri=INF;
  while(ri-le>1){
    ll mi=(ri+le)/2;
    ll cnt=0;
    for(i=0;i<n;i++){
      cnt+=max(0ll,a[i]-mi/f[i]);
    }
    if(cnt<=k) ri=mi;
    else le=mi;
  }
  cout<<ri<<endl;

}

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

int main() {
  int k, s, sum, ans = 0;
  int i = 0, j = 0;
  cin >> k >> s;
  for (i = 0; i <= k; i++) {
    for (j = 0; j <= k; j++) {
      int z = s - i - j;
      if(z >= 0 and z <= k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int n=0;
  while(n<10000000){
    if(n%60<=c&&c<=n%60+a){cout<<n/60*60+c<<endl;return 0;}
    n+=a+b;
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 1164
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner (System.in);
    int B[][]=new int[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        B[i][j]=sc.nextInt();}}
    int N =sc.nextInt();
    int M[]=new int[N];
    Integer[] P=new Integer[10];
    for(int k=0;k<N;k++){
      M[k]=sc.nextInt();
      loop:for(int l=0;l<3;l++){
        for(int m=0;m<3;m++){
          if(M[k]==B[l][m]){P[k]=3*l+m+1;break loop;}}}
    if(Arrays.asList(P).contains(1)){
        if(Arrays.asList(P).contains(2)&&Arrays.asList(P).contains(3)){System.out.println("Yes");System.exit(0);}
        else if(Arrays.asList(P).contains(4)&&Arrays.asList(P).contains(7)){System.out.println("Yes");System.exit(0);}
        else if(Arrays.asList(P).contains(5)&&Arrays.asList(P).contains(9)){System.out.println("Yes");System.exit(0);}}
      if(Arrays.asList(P).contains(5)){
        if(Arrays.asList(P).contains(2)&&Arrays.asList(P).contains(8)){System.out.println("Yes");System.exit(0);}
        if(Arrays.asList(P).contains(3)&&Arrays.asList(P).contains(7)){System.out.println("Yes");System.exit(0);}
        if(Arrays.asList(P).contains(4)&&Arrays.asList(P).contains(6)){System.out.println("Yes");System.exit(0);}}
      if(Arrays.asList(P).contains(9)){
        if(Arrays.asList(P).contains(3)&&Arrays.asList(P).contains(6)){System.out.println("Yes");System.exit(0);}
        if(Arrays.asList(P).contains(7)&&Arrays.asList(P).contains(8)){System.out.println("Yes");System.exit(0);}}}
    System.out.println("No");}
}

Measured memory_bytes: 23636