akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll l,r,mid;
ll n,m;
ll a[200010],b[200010];
bool check()
{
	vector<ll> v;
	//cout <<mid<<" ##\n";
	for (int i=0;i<n;i++)
	{
		v.push_back(max((ll)0,a[i]-mid/b[i]));
		//cout <<v.back()<<" "; 
	}
	//cout <<"\n";
	sort(v.begin(),v.end());
	ll t=0;
	for (int i=0;i<n;i++) t+=v[i];
	return t<=m;
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) scanf("%lld",&a[i]);
	for (int i=0;i<n;i++) scanf("%lld",&b[i]);
	sort(a,a+n);
	sort(b,b+n),reverse(b,b+n);
	l=0,r=1e12;
	while (l<r)
	{
		mid=(l+r)>>1;
		if (check()) r=mid;
		else l=mid+1;
	}
	printf("%lld",l);
	return 0;
}

Measured memory_bytes: 9012
N = int(input())
A = list(map(int, input().split()))
dct = {}
for i in range(-1,10**5+1):
  dct[i] = 0
for i in A:
  dct[i-1] += 1
  dct[i] += 1
  dct[i+1] += 1

sorted_dct = sorted(dct.items(), key=lambda x:-x[1])
print(sorted_dct[0][1])

Measured memory_bytes: 65384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Double r = Double.parseDouble(sc.next());
		sc.close();
		
		//累乗の計算
		int ans = (int) Math.pow(r,2);
		System.out.println(ans);
	}
}

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

vector<int>v;
int n, k;

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	sort(v.rbegin(), v.rend());
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

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

#define int long long 
#define MOD 1000000007

using namespace std;


signed main(){

	int N;
	cin >>N;
	
	int a[N];
	int sum=0;
	
	for(int i=0;i<N;i++){
		cin >> a[i];
	} 	
 	
 	for(int i=0;i<N;i++){
 		sum += a[i];
 	}
 	
 	double m;
 	m  = sum/(double)N;
 	
 	//cout <<m <<endl;

 	double k=300;
 	int index=0;
 	
 	for(int i=0;i<N;i++){
 		double temp = abs(double(m-a[i]));
 		if(temp<k){
 			k = temp;
 			index = i;
 		}
 		if(k==0){
 			cout << i <<endl;
 			return 0;
 		}
 	
 	}	
 	
 	cout <<index <<endl;
 	
 	return 0;
	

}

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

#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

using namespace std;

ll dp[109][100010];
int main()
{
    fastio;
    ll N, W;
    cin >> N >> W;
    pair <ll, ll> p[N];
    for (int i = 0; i < N; i++)
    {
    	cin >> p[i].first >> p[i].second;
    }

    for (int i = 0; i <= N; i++)
    {
    	for (int j = 0; j <= W; j++)
    	{
    		if (i == 0 or j == 0) dp[i][j] = 0;
    		else if (j - p[i - 1].first < 0)
    		{
    			dp[i][j] = dp[i - 1][j];
    		}
			else
			{
				dp[i][j] = max(dp[i - 1][j], p[i - 1].second + dp[i - 1][j - p[i - 1].first]);
			}

    		//cout << dp[i][j] << " ";
    	}
    	//cout << endl;
    }

    cout << dp[N][W];
    return 0;
}




Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

vector<pair<int,int>> e[50];

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

bool dfs(int v,int p,int g,ll &edge){
    if(v==g)return true;
    for(auto nx:e[v]){
        int u=nx.first;
        int id=nx.second;
        if(p!=u){
            if(dfs(u,v,g,edge)){
                edge+=(1LL<<id);
                return true;
            }
        }
    }
    return false;
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int s,t;
        cin>>s>>t;
        --s,--t;
        e[s].push_back({t,i});
        e[t].push_back({s,i});
    }
    ll edge[n][n]={};
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            dfs(i,-1,j,edge[i][j]);
        }
    }
    int m;
    cin>>m;
    int u[m];
    int v[m];
    for(int i=0;i<m;i++){
        cin>>u[i]>>v[i];
        --u[i],--v[i];
        if(u[i]>v[i])swap(u[i],v[i]);
    }
    ll ans=0;
    for(int s=0;s<1<<m;s++){
        ll bit=0;
        int cnt=0;
        for(int i=0;i<m;i++){
            if((s>>i)&1){
                bit|=edge[u[i]][v[i]];
                cnt++;
            }
        }
        int t=0;
        for(int i=0;i<n-1;i++){
            if(!((bit>>i)&1LL)){
                t++;
            }
        }
        if(cnt%2==0){
            ans+=(1LL<<t);
        }
        else{
            ans-=1LL<<t;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
from math import gcd

n, m = map(int, input().split())
A = list(map(int, input().split()))
A = [a//2 for a in  A]
lcm = 1

for i in range(n):
    lcm = lcm * A[i] // gcd(lcm, A[i])
    if lcm > m:
        print(0)
        exit()
        
for a in A:
    if lcm // a % 2 == 0:
        print(0)
        exit()

print((m//lcm + 1) // 2)


Measured memory_bytes: 20128
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());

            int player1 = 0;
            int player2 = 0;
            for (int i = 0; i < count; i++)
            {
                string[] data = Console.ReadLine().Split(' ');

                if (0 < data[0].CompareTo(data[1]))
                {
                    player1 += 3;
                }
                else if (0 < data[1].CompareTo(data[0]))
                {
                    player2 += 3;
                }
                else
                {
                    player1++;
                    player2++;
                }
            }

            Console.WriteLine("{0} {1}", player1, player2);
        }
    }

}

Measured memory_bytes: 9940
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


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

const int _ = 200007;

char s[_];

int main()
{
	fread(s,1,_,stdin);
	
	long long ans=0,cnta=0;
	for(int i=0;s[i];i++)
	{
		if(s[i]=='A')cnta++;
		else if(s[i]=='B' && s[i+1]=='C')ans+=cnta,i++;
		else cnta=0;
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 384
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
mt = [1]*n
Mt = [None]*n
ma = [1]*n
Ma = [None]*n
v = -1
for i,h in enumerate(t):
    if h>v:
        mt[i] = Mt[i] = h
    else:
        Mt[i] = h
    v = h
v = -1
for i,h in enumerate(reversed(a)):
    if h>v:
        ma[n-1-i] = Ma[n-1-i] = h
    else:
        Ma[n-1-i] = h
    v = h
ans = 1
M = 10**9+7
for i in range(n):
    val = min(Mt[i], Ma[i]) - max(mt[i], ma[i]) + 1
    if val<=0:
        ans = 0
        break
    ans *= val
    ans %= M
print(ans)

Measured memory_bytes: 24480
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
   
   int A, B;
   cin >> A >> B;
   int ans = 0;
   ans = max(A + B, A - B);
   ans = max(ans, A * B);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
def main():
    n,k = map(int,input().split())
    have = []
    for i in range(k):
        d = int(input())
        a = list(map(int,input().split()))
        for j in range(d):
            if a[j] not in have:
                have.append(a[j])
    print(n-len(have))


if __name__ == "__main__":
    main()

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

int main(void) {
    const int group[12] = {0, 1, 0, 2, 0, 2 ,0, 0, 2, 0, 2};
    int x, y;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> y;
    cout << (group[x - 1] == group[y - 1]? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define rep(i,e) for(int i=0;i<(e);++i)

int w, h, lx, ly, rx, ry, nlx, nly, nrx, nry;
int t, lsx, lsy, rsx, rsy;
char l[50][50], r[50][50];
int drx[4]={0,1,0,-1}, dy[4]={1,0,-1,0}, dlx[4]={0,-1,0,1};

int main() {
  while(true){
    cin>>w>>h;
    if(w==0)break;

    bool visited[50][50][50][50]={};
    bool ans = false;
    int t, lsx, lsy, rsx, rsy;

    rep(i,h){
      rep(j,w){
        cin>>l[i][j];
        if(l[i][j]=='L') lsx=j, lsy=i;
      }
      rep(j,w){
        cin>>r[i][j];
        if(r[i][j]=='R') rsx=j, rsy=i;
      }
    }
    //cout<<lsx<<" "<<lsy<<" "<<rsx<<" "<<rsy<<endl;

    queue<tuple<int, int, int, int>> q;
    q.push(make_tuple(lsx, lsy, rsx, rsy));
    visited[lsx][lsy][rsx][rsy] = true;
    while(q.size()){
      tie(lx, ly, rx, ry) = q.front(); q.pop();
      //cout<<lx<<" "<<ly<<" "<<rx<<" "<<ry<<endl;

      rep(i,4){
        nlx = lx+dlx[i], nly = ly+dy[i];
        nrx = rx+drx[i], nry = ry+dy[i];
        if(nlx<0 or nlx>=w) nlx = lx;
        if(nrx<0 or nrx>=w) nrx = rx;
        if(nly<0 or nly>=h) nly = ly;
        if(nry<0 or nry>=h) nry = ry;
        if(l[nly][nlx]=='\%' and r[nry][nrx]=='\%'){
          ans = true; break;
        }
        else if(l[nly][nlx]=='\%' or r[nry][nrx]=='\%') continue;
        else if(l[nly][nlx]=='#' and r[nry][nrx]=='#') continue;
        else if(l[nly][nlx]=='#'){
          nly = ly, nlx = lx;
        }
        else if(r[nry][nrx]=='#'){
          nry = ry, nrx = rx;
        }
        if(visited[nlx][nly][nrx][nry]==false){
          q.push(make_tuple(nlx, nly, nrx, nry));
          visited[nlx][nly][nrx][nry] = true;
        }
      }
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 10032
fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    val T = next()
    var n = 0
    while (n < N) {
        var m = N - n
        while (m > 0) {
            if (S.substring(n) == T.substring(0, m)) {
                println(N + N - m)
                return
            }
            m--
        }
        n++
    }
    println(N+n)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())


Measured memory_bytes: 33664
#include <iostream>
#include <string>

using namespace std;

void solve()
{
	string str;
	while(cin >> str)
	{
		int n = str.size();
		int count = 0;
		for(int i = 0; i < n - 2; ++i)
		{
			if(str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I')
			{
				count++;
			}
		}
		cout << count << endl;
		count = 0;
		for(int i = 0; i < n - 2; ++i)
		{
			if(str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I')
			{
				count++;
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
import sys


def prepare(n, MOD):
    facts = [1]
    t = 1
    for i in range(1, n + 1):
        t = t * i % MOD
        facts.append(t)
    invs = [1] * (n + 1)
    t = pow(t, MOD - 2, MOD)
    invs[n] = t
    for i in range(n, 1, -1):
        t = t * i % MOD
        invs[i - 1] = t
    return facts, invs


MOD = 1000003
facts, factinvs = prepare(MOD - 1, MOD)

q = int(input())
ans = []
for line in sys.stdin:
    x, d, n = map(int, line.split())

    if x == 0:
        ans.append(0)
        continue
    if d == 0:
        ans.append(pow(x, n, MOD))
        continue

    invd = pow(d, MOD - 2, MOD)

    xd = x * invd % MOD
    limit = MOD - xd

    if n > limit:
        ans.append(0)
        continue

    r = xd + n - 1
    l = xd - 1
    dn = pow(d, n, MOD)
    ans.append(facts[r] * factinvs[l] * dn % MOD)

print('\n'.join(map(str, ans)))


Measured memory_bytes: 92928
# coding: utf-8
N,S=map(int,input().split())
A=list(map(int,input().split()))
MOD=998244353

dp=[[0 for j in range(S+1)] for i in range(N+1)]

dp[0][0]=1

for i in range(1,N+1):
    a=A[i-1]
    for j in range(0,S+1):
        dp[i][j]+=dp[i-1][j]*2
        if j-a>=0:
            dp[i][j]+=dp[i-1][j-a]
        dp[i][j]=dp[i][j]%MOD


print(dp[N][S])

Measured memory_bytes: 147016
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

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

	long long int a;
	cin>>a;
	map<string , int> m ;
	forr(i,0,a)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<m.size();
	
	return 0;
}

Measured memory_bytes: 19244
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_STR_MAX		100000									// 最大文字数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 改行カット
// 戻り値：文字数
int
fCutCrLf(
	char *pcpStr				// <I> 文字列
)
{
	int i;

	for (i = 0; pcpStr[i] != '\0'; i++) {
		if (pcpStr[i] == '\n') {
			pcpStr[i] = '\0';
			break;
		}
	}

	return i;
}

// パターン１(XX)取得
int
fGetPtn1(
	char *pcpStr				// <I> 文字列
	, int piLen					// <I> 文字列長
)
{
	int i;

	for (i = 1; i < piLen; i++) {
		if (pcpStr[i] == pcpStr[i - 1]) {
			return i;
		}
	}

	return -1;
}

// パターン２(XYX)取得
int
fGetPtn2(
	char *pcpStr				// <I> 文字列
	, int piLen					// <I> 文字列長
)
{
	int i;

	for (i = 2; i < piLen; i++) {
		if (pcpStr[i] == pcpStr[i - 2]) {
			return i - 1;
		}
	}

	return -1;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 文字列取得
	char lc1Str[D_STR_MAX + 5];
#ifdef D_TEST
	fgets(lc1Str, sizeof(lc1Str), szpFpT);
#else
	fgets(lc1Str, sizeof(lc1Str), stdin);
#endif

	// 長さ取得
	int liLen = fCutCrLf(lc1Str);

	// パターン１(XX)取得
	int liNo = fGetPtn1(lc1Str, liLen);
	int liNo2;
	if (liNo > 0) {
		liNo2 = liNo + 1;
	}
	else {

		// パターン２(XYX)取得
		liNo = fGetPtn2(lc1Str, liLen);
		if (liNo > 0) {
			liNo2 = liNo + 2;
		}
		else {
			liNo2 = -1;
		}
	}

	// 結果セット
	sprintf(lc1Out, "%d %d\n", liNo, liNo2);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();
		
		long loop = n / (a+b);
		long mod = n % (a+b);
		
		if(mod > a) {
			System.out.println(loop*a+a);
		}else {
			System.out.println(loop*a+mod);
		}
		
	}
}


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

int main(){
    int n;
    cin >> n;
    int v[n];
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v,v+n);

    double ans;
    ans = v[0];
    for(int i=1; i<n; i++){
        ans = (ans+v[i])/2;
    }

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


Measured memory_bytes: 256
import sys
from io import StringIO
import unittest


def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    loop_list = []
    loop_set = set()
    now = 0

    if k > n:
        for _ in range(k):
            now = a[now] - 1

            if now + 1 in loop_set:
                s_index = loop_list.index(now + 1)
                before_loop = s_index
                loop_list = loop_list[s_index:]
                break
            else:
                loop_list.append(now + 1)
                loop_set.add(now + 1)

        l = len(loop_list)
        k -= before_loop

        # print(loop_list, l, before_loop)
        print(loop_list[k % l - 1])
    else:
        for _ in range(k):
            now = a[now] - 1

        print(now + 1)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 5
3 2 4 1"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """6 727202214173249351
6 5 2 5 3 2"""
        output = """2"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 47832
// https://beta.atcoder.jp/contests/abc104

#define SUBMIT

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#include <unordered_map>
#include <map>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    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>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int n;
  cin >> n;
  map<string,ll>mp;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll cnt=0;
  for(auto p:mp){
    cnt+=p.second*(p.second-1)/2;
  }
  cout << cnt << endl;
  return 0;     
}


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

int main()
{
    int x,y,z ;
    cin >> x >> y >> z ;
    cout << z << " " << x << " " << y << endl ;
}

Measured memory_bytes: 3560
import bisect

n,x = map(int, input().split())
l = tuple(map(int, input().split()))

d = [-1]*(n+1)
d[0] = 0
for i in range(1, n+1):
    d[i] = d[i-1] + l[i-1]
res = bisect.bisect_right(sorted(d), x)
print(res)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(void)
{
   int n,i,a[1000];
   double s;

   scanf("%d",&n);

   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
   }

   s=0;
   for(i=0;i<n;i++){
      s=1/(double)a[i]+s;
   }

   printf("%lf\n",1/s);

   return 0;
}


Measured memory_bytes: 128
import numpy as np
N,W = map(int,input().split())
l = [list(map(int,input().split()))for i in range(N)]
dp = np.zeros(shape=(N,W + 1),dtype = int)
for i in range(l[0][0],W + 1):
    dp[0][i] = l[0][1]
for i in range(1,N):
    weight = l[i][0]
    value = l[i][1]
    dp[i][:weight] = dp[i - 1][:weight]
    dp[i][weight:] = np.maximum(dp[i - 1][weight:], value + dp[i - 1][:-weight])
print(dp[N - 1][W])

Measured memory_bytes: 92052
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int nCount = 0;
    for(int i = 0; i < n; i++){
        int a;
        scanf("%d", &a);
        if(i % 2 == 0 && a % 2 == 1){
            nCount++;
        }
    }
    
    printf("%d", nCount);
    return 0;
}


Measured memory_bytes: 3224
import java.util.Arrays;
import java.util.NavigableSet;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

    static class Job implements Comparable<Job> {
        int days;
        int reward;

        public Job(int days, int reward) {
            this.days = days;
            this.reward = reward;
        }

        @Override
        public int compareTo(Job other) {
            return other.reward - this.reward;
        }
    }

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

        Job[] jobs = new Job[N];

        for (int i = 0; i < N; i++) {
            jobs[i] = new Job(sc.nextInt(), sc.nextInt());
        }

        Arrays.sort(jobs);

        NavigableSet<Integer> free = new TreeSet<>();
        for (int i = 0; i < M; i++) free.add(i);

        int sol = 0;

        for (Job job : jobs) {
            Integer day = free.floor(M - job.days);
            if (day == null) continue;
            sol += job.reward;
            free.remove(day);
        }

        System.out.println(sol);
    }
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

LL gcd(const LL a, const LL b)
{
    if (b == 0)
        return a;
    else 
        return gcd(b,a%b);
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    LL a,b;
    while (cin >> a >> b) {
        LL g = gcd(a,b); set<LL> P;
        for (LL f = 2; f*f <= g; f++) {
            while (g % f == 0) {
                g /= f;
                P.insert(f);
            }
        }
        if (g != 1)
            P.insert(g);
        cout <<  P.size()+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var t=sc.S;
		int p=t.Length>>1;
		int ans=0;
		for(int i = 0;i<p;i++) {
			if(t[i]!=t[t.Length-i-1]){ans++;}
		}
		Console.WriteLine("{0}",ans);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>

using namespace std;

char a[100][100],b[100][100];
int n,m;

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	  for (int j=1;j<=n;j++)
	    {
	    	scanf("%c",&a[i][j]);
	    	if (a[i][j]=='\n'||a[i][j]==' ') scanf("%c",&a[i][j]);
	    }
	    
	for (int i=1;i<=m;i++)
	  for (int j=1;j<=m;j++)
	    {
	    	scanf("%c",&b[i][j]);
	    	if (b[i][j]=='\n'||b[i][j]==' ') scanf("%c",&b[i][j]);
	    } 
	for (register int i=1;i<=n-m+1;i++)
	  for (register int j=1;j<=n-m+1;j++)
	    {
	    	int cnt=0;
	    	for (register int k=i;k<=i+m-1;k++)
	    	  {
	    	  	if (cnt==1) break;
	    	    for (register int l=j;l<=j+m-1;l++)
	    	      if (a[k][l]!=b[k-i+1][l-j+1])
	    	        {
	    	      	  cnt=1;
	    	      	  break;
	    	        }
	    	  }
	    	if (cnt==0) 
			  {
			  	printf("Yes");
			  	return 0;
			  } 
	    }
	printf("No");    
	return 0;	   
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    x = int(input())
    ans = (x // 11) * 2
    x %= 11

    if x > 0:
        if x > 6:
            ans += 2
        else:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int num = 0;

    if(a == b && b == c){
        num = 1;
    }
    else if(a == b && b != c || b == c && c != a || c == a && a != b){
        num = 2;
    }
    else{
        num = 3;
    }

    cout << num << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int min1(int c4,int c5){
    if(c4>c5){
        return c5;
    }
    else{
        return c4;
    }
}
int abs_diff(int m6,int m7){
    int w=m6-m7;
    if(w<0){
        w=0-w;
    }
    return w;
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int j=0;j<n;j++){
        cin>>arr[j];
    }
    int dp[n+1]={-1};
    dp[1]=0;dp[2]=abs_diff(arr[1],arr[0]);
    for(int j=3;j<=n;j++){
        dp[j]=min1((dp[j-1]+abs_diff(arr[j-1],arr[j-2])),(dp[j-2]+abs_diff(arr[j-1],arr[j-3])));
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 4320
N = int(input())
S = input()

m = 1000000007

d = {}
for c in S:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

result = 1
for x in d.values():
    result *= x + 1
    result %= m
result += m - 1
result %= m

print(result)


Measured memory_bytes: 9224
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

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

class Data
{
public:
    int y, x;
    bitset<5> bs;
    Data(int y0, int x0, bitset<5> bs0){
        y = y0;
        x = x0;
        bs = bs0;
    }
};

int main()
{
    int h, w;
    cin >> w >> h;

    vector<string> s(h+4, string(w+4, '#'));
    vector<vector<int> > fear(h+4, vector<int>(w+4, 1));
    int sy, sx;
    int n = 0;
    for(int y=2; y<h+2; ++y){
        for(int x=2; x<w+2; ++x){
            cin >> s[y][x];
            if(s[y][x] == 'S'){
                sy = y;
                sx = x;
            }else if(s[y][x] == 'M'){
                s[y][x] = '0' + n;
                ++ n;
            }else if(s[y][x] == '#'){
                for(int i=-2; i<=2; ++i){
                    for(int j=-2; j<=2; ++j){
                        fear[y+i][x+j] = max(fear[y+i][x+j], 4 - max(abs(i), abs(j)));
                    }
                }
            }
        }
    }
    h += 4;
    w += 4;

    vector<vector<vector<int> > > dp(h, vector<vector<int> >(w, vector<int>(1<<n, INF)));
    dp[sy][sx][0] = 0;
    multimap<int, Data> mm;
    mm.insert(make_pair(0, Data(sy, sx, 0)));

    for(;;){
        int cost0 = mm.begin()->first;
        int y0 = mm.begin()->second.y;
        int x0 = mm.begin()->second.x;
        bitset<5> bs0 = mm.begin()->second.bs;
        mm.erase(mm.begin());
        if(cost0 > dp[y0][x0][bs0.to_ulong()])
            continue;

        if(s[y0][x0] == 'G' && bs0.count() == n){
            cout << cost0 << endl;
            return 0;
        }

        for(int i=0; i<4; ++i){
            int cost = cost0 + fear[y0][x0];
            int y = y0 + dy[i];
            int x = x0 + dx[i];
            bitset<5> bs = bs0;
            if(s[y][x] == '#')
                continue;
            if(isdigit(s[y][x]))
                bs[s[y][x]-'0'] = true;

            if(cost < dp[y][x][bs.to_ulong()]){
                dp[y][x][bs.to_ulong()] = cost;
                mm.insert(make_pair(cost, Data(y, x, bs)));
            }
        }
    }
}

Measured memory_bytes: 3236
#include<iostream>
using namespace std;
int main(){
    int h, w;
    while(1){
      cin >> h >> w;
      if(h == 0)break;
      for(int i = 0; i < h; i++){
          for(int j = 0; j < w; j++){
              cout << '#';
          }
          cout << endl;
      }
      cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> A(N);
    int n=0;
    REP(i,N){
        cin>>A[i];
        n+=A[i];
    }
    vector<int> enum_list=enum_div(n);
    enum_list.push_back(n);
    sort(enum_list.begin(),enum_list.end());
    int ans=1;
    REP(i,enum_list.size()){
        vector<int> plus(N),minus(N);
        vector<int> sum_plus(N+1),sum_minus(N+1);
        REP(j,N){
            plus[j]=A[j]%enum_list[i];
        }
        sort(plus.begin(),plus.end());
        REP(j,N){
            minus[j]=(enum_list[i]-plus[j])%enum_list[i];
        }
        sum_plus[0]=0;
        sum_minus[N]=0;

        REP2(j,1,N+1){
            sum_plus[j]=sum_plus[j-1]+plus[j-1];
            sum_minus[N-j]=sum_minus[N+1-j]+minus[N-j];
        }

        int cnt=0;
        REP(j,N){
            if(j==0) continue;
            if(sum_plus[j]==sum_minus[j]&&sum_plus[j]<=K){
                ans=max(ans,enum_list[i]);
            }
        }
    }
    cout<<ans<<endl;
    
}

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

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, n) cout << a[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,i,k;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0) break;
    int place[m];
    for(i=0;i<m;i++) place[i]=0;
    for(i=0;i<n;i++)
      for(int j=0;j<m;j++) {
	cin>>k;
	if(k==1) place[j]++;
      }
    for(i=0; i<m; i++) {
      k=0;
      for(n=1; n<m; n++) {
	if(place[n] > place[k]) k=n;
      }
      cout<<k+1;
      if(i<m-1)cout<<" ";
      place[k]=0;
    }
    cout<<"\n";
  }
}

Measured memory_bytes: 860
import sys
input = sys.stdin.readline  # NOQA


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = input().rstrip()

    can_jump_R = True  # '##'
    can_jump_B = False  # '...'
    for i in range(A + 1, N - 1):
        if S[i] == S[i+1] == "#":
            if A < i < C or B < i < D:
                can_jump_R = False
        if S[i-1] == S[i] == S[i+1] == ".":
            if B <= i < C and i-1 != D:
                can_jump_B = True

    if C < D:
        if can_jump_R:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if can_jump_R and can_jump_B:
            ans = "Yes"
        else:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        long at = 0;
        for (int i=0;i<n;i++)at+=sc.nextInt();
        if (h<=at)System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 58216
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,pi
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？


n=ii()

print(2*pi*n)






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

int main() {
    vector<char> num(3);
    int count = 0;
    for (int i = 0; i < 3; i++) {
        cin >> num.at(i);
        if (num.at(i)=='1')
            count++;
    }
    cout << count;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)

const int SIZE = 100000	+ 10;

int main() {
  vector<bool> isprime(SIZE, true);
  isprime[0] = isprime[1] = false;
  for(int i = 2; i < SIZE; i++) {
    if(isprime[i]) {
      for(int j	= i+i; j < SIZE; j += i) isprime[j] = false;
    }
  }

  vector<int> l2017(SIZE,0), sum(SIZE,0);
  for(int i = 1; i < SIZE; i+= 2) {
    if(isprime[i] && isprime[(i+1)/2]) l2017[i] = 1;
  }
  for(int i = 1; i < SIZE; i++) {
    sum[i] = sum[i-1] +	l2017[i];
  }

  int Q;
  cin >> Q;

  while( -- Q>=	0) {
    int	l, r;  cin>>l>>r;
    cout << sum[r] - sum[l-1] << endl;

  }
  return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    string S;
    cin >> S;
    int size = S.size();
    int cnt=0;
    int longest=0 ;
    for(int i=0;i<size;i++){
        if( (S[i]=='A'||S[i]=='C') || (S[i]=='G'||S[i]=='T') ){
            cnt++;
            if(i==size-1){               // 最後の文字がA C G Tのどれかだとカウントされなくなってしまう。
                if(cnt > longest){
                    longest = cnt;
                }
            }
        }
        
        else{
            if( cnt > longest ){
                longest = cnt;
            }
            cnt = 0;
        }
    }
    cout << longest << endl;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n; cin>>n;
	pair<int,int> a[100],b[100];
	rep(i,n) cin>>a[i].first>>a[i].second;
	rep(i,n) cin>>b[i].first>>b[i].second;

	sort(a,a+n,[](auto x,auto y){ return x.first>y.first; });
	sort(b,b+n,[](auto x,auto y){ return x.second<y.second; });

	int ans=0;
	bool used[100]={};
	rep(i,n){
		rep(j,n) if(!used[j] && a[i].first<b[j].first && a[i].second<b[j].second) {
			used[j]=true;
			ans++;
			break;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define pub push_back
#define mp make_pair
#define fir first
#define sec second
#define res resize
const int big=((llint)1<<30);


int main(void){
	string ans="Possible",no="Impossible";
	int n,i,q,w;
	vector<int> su;
	vector<int> ikt;
	cin>>n;
	ikt.resize(n);
	for(i=0;i<n;i++){
		cin>>q;
		su.pub(q);
		ikt[q]++;
	}
	sort(su.begin(),su.end());
	if(su.front()!=(su.back()+1)/2){ ans=no; }
	for(i=su.back();i>su.front();i--){if(ikt[i]<2){ ans=no; }}
	if(su.back()%2==0){ if(ikt[su.front()]!=1){ ans=no; } }
	else{ if(ikt[su.front()]!=2){ ans=no; } }
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  double L;
  cin >> L;
  double side = L / 3;
  double ans = pow(side, 3);
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 4232
#include <stdio.h>
int main(void){
    int i;
    char str[20]={};
    
    for(i=0; i<20; i++){
        scanf("%c", &str[i]);
    }
    
    for(i=19; i>=0; i--){
        if(str[i]!=EOF){
            printf("%c", str[i]);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2028
H,W = map(int,input().split())
A = [""] * H
for i in range(H):
  A[i] = input()
  
row = [False] * H
col = [False] * W

for j in range(H):
  for k in range(W):
    if A[j][k] == "#":
      row[j] = True
      col[k] = True
      
for l in range(H):
  if row[l]:
    for m in range(W):
      if col[m]:
        print(A[l][m], end = "")
    print()

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> a(n);
   int ans = 0;
   f(i,0,n){
      cin >> a[i];
   }
   f(i,0,n){
      f(j,i+1,n){
         ans += (a[i]*a[j]);
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n;
LL b[100111],a[100111];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get2(a[i],b[i]);
	
	LL add=0;
	for(int i=n;i>=1;i--)
	{
		a[i]+=add;
		add+=(b[i]-a[i]%b[i])%b[i];
	}
	printendl(add);
	return 0;
}

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

using namespace std;

#define int long long
#define MOD 1000000007

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}

//typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 100005
//#define int long long

int r;

signed main()
{
    cin >> r;

    cout << r * r << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
import itertools

input = sys.stdin.readline
n, a, b, c = map(int, input().split())
l_list = [int(input()) for _ in range(n)]
comb_list = list(itertools.product(range(4), repeat=n))
mp = 10**9+1
for comb in comb_list:
    tmp_a, tmp_b, tmp_c = 0, 0, 0
    cnt_a, cnt_b, cnt_c = 0, 0, 0
    for i, k in enumerate(comb):
        if k > 0:
            if k == 1:
                tmp_a += l_list[i]
                cnt_a += 1
            elif k == 2:
                tmp_b += l_list[i]
                cnt_b += 1
            else:
                tmp_c += l_list[i]
                cnt_c += 1
    if cnt_a > 0 and cnt_b > 0 and cnt_c > 0:
        tmp = abs(a-tmp_a) + abs(b-tmp_b) + abs(c-tmp_c) + (cnt_a-1)*10 + (cnt_b-1)*10 + (cnt_c-1)*10
        mp = min(mp, tmp)
print(mp)


Measured memory_bytes: 10996
import java.util.*;

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

        while (true) {
            int n = scan.nextInt();
            int x = scan.nextInt();
            if (n == 0 && x == 0) break;
            int count = 0;


            for (int i = 1; i < n; ++i) {
                for (int j = i; j < n; ++j) {
                    if (i == j) continue;
                    int num = x - (i + j);
                    if (num < 1) break;
                    if (num < j) break;
                    if (i != num && j != num && num <= n) count++;
                    num = 0;
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 26184