akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    set<int> sqr;
    for (int i = 0; i <= 10000; i++)
        sqr.insert(i * i);

    int n, d, t;
    vector<vector<int>> vvi;
    cin >> n >> d;
    for (int i = 0; i < n; i++)
    {
        vector<int> tmp;
        for (int j = 0; j < d; j++)
            cin >> t, tmp.push_back(t);
        vvi.push_back(tmp);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
        {
            int sum = 0;
            for (int k = 0; k < d; k++)
                sum += (vvi[i][k] - vvi[j][k]) * (vvi[i][k] - vvi[j][k]);
            ans += sqr.count(sum);
        }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args)
	{
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int p = sc.nextInt();
	int x = 3*a + p;
	System.out.println(x/2);
	}
}


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

#define iiii tuple<int, int, int, int>
#define pii pair<int, int>
#define x first
#define y second

const int N = 505;

int n, m;
int A[N][N];

int main() {
    scanf("%d %d", &n, &m);
    vector<iiii> V;
    for(int i = 1; i <= n; ++i) for(int j = 1; j <= m; ++j) {
        int ret; scanf("%d", &ret);
        A[i][j] += ret;
        if(j != m) if(A[i][j] & 1) A[i][j+1]++, V.emplace_back(i, j, i, j+1);
    }
    for(int i = 1; i < n; ++i) if(A[i][m] & 1) A[i+1][m]++, V.emplace_back(i, m, i+1, m);
    printf("%d\n", (int)V.size());
    for(auto x : V) {
        int a, b, c, d; tie(a, b, c, d) = x;
        printf("%d %d %d %d\n", a, b, c, d);
    }
}

Measured memory_bytes: 5232
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define CLEAR(a) memset(a,0,sizeof a)
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define fr freopen("input.txt", "r", stdin);
#define fw freopen("output.txt", "w", stdout);
#define int long long 
typedef long long LL;
typedef pair<int,int> pii;
const int MOD = 1e9 + 7;
const int MAX = 1e5 + 5;


 main() {
    //fr;fw;
    int a, b, c;
    cin >> a >> b >> c;
    if(a%2 == 0){
      cout << 0;
      return 0;
    }

    if(b%2 == 0){
      cout << 0;
      return 0;
    }
    
    if(c%2 == 0){
      cout << 0;
      return 0;
    }

    int mx = max(a, max(b, c));

    int ret = 0;

    if(mx == a){
      cout << b*c;
      return 0;
    }

    if(mx == b){
      cout << a*c;
      return 0;
    }

    
    if(mx == c){
      cout << b*a;
      return 0;
    }

    

    return 0;
}

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

using namespace std;

int main(){
  int n; cin >> n;
  int k; cin >> k;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  //i番目に到達するために必要なコストの最小値をdp[i]とする。
  int dp[n+5];
  for(int i=0;i<n+5;i++){
    dp[i]=1000000000;
  }
  //dpテーブルの初期化
  dp[1]=0;
  for(int i=1;i<n;i++){
    for(int j=1;j<=min(k,n-i);j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j-1]-h[i-1]));
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000

using namespace std;

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

vector<int> G[100000];
vector<int> articulation;
int ord[100000], low[100000];
bool checked[100000];

int k;

void dfs(int v, int p)
{
	checked[v] = true;
	ord[v] = k++;
	low[v] = ord[v];

	bool isArticulation = false;
	int ct = 0;

	for (int i = 0; i != G[v].size(); i++)
	{
		if (!checked[G[v][i]])
		{
			ct++;
			dfs(G[v][i], v);
			low[v] = min(low[v], low[G[v][i]]);
			if (p != -1 && ord[v] <= low[G[v][i]])
			{
				isArticulation = true;
			}
		}
		else if (G[v][i] != p)
		{
			low[v] = min(low[v], ord[G[v][i]]);
		}
	}

	if (p == -1 && ct > 1)
	{
		isArticulation = true;
	}
	if (isArticulation)
	{
		articulation.push_back(v);
	}
}

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

	int V, E;
	scanf("%d %d", &V, &E);

	for (int i = 0; i < E; i++)
	{
		int s, t;
		scanf("%d %d", &s, &t);

		G[s].push_back(t);
		G[t].push_back(s);
	}

	dfs(0, -1);

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

	for (auto& n : articulation)
	{
		printf("%d\n", n);
	}
	return 0;
}


Measured memory_bytes: 7108
n = list(map(int,input().split()))
k = [list(map(int,input().split())) for i in range(n[1])]
num = [1]
def has_duplicates(seq):
    return len(seq) != len(set(seq))
def has_duplicates2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) != len(unique_list)
if has_duplicates([k[l][0] for l in range(len(k))]):
  if has_duplicates2(k):
    m =1
  else:
    print(-1)
    exit()
if n[1] == 0:
  if n[0] == 1:
    print(0)
    exit()
for l in range(n[0] - 1):
  num.append(0)
for l in range(len(k)):
  num[ k[l][0] - 1 ] = k[l][1]
if len(num) == 1:
  print(''.join(map(str, num)))
else:
  if num[0] == 0:
    print(-1)
  else:
    print(''.join(map(str, num)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		ll l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
import bisect
input = sys.stdin.readline
def 解():
    N,Q=[int(_) for _ in input().split()]
    S = input()
    aC = [-1]
    iC = 0
    bF = False
    for s in S:
        iC += 1
        if s == 'A':
            bF = True
        elif s == 'C' :
            if bF:
                aC.append(iC)
            bF = False
        else:
            bF = False

    aC.append(10**9)
    aAns = []
    for _ in range(Q):
        l,r = [int(_) for _ in input().split()]
        iL = bisect.bisect_left(aC,l)
        if l == aC[iL]:
            iL += 1
        iR = bisect.bisect_left(aC,r)
        if aC[iR] <= r:
            iR += 1
        aAns.append(iR-iL)
    print(*aAns,sep="\n")
解()


Measured memory_bytes: 11588
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int dp[100010];
    dp[0] = 0;
    for(int n = 1; n <= 100000; n++) {
        dp[n] = 999999999;
        int power = 1;
        while(power <= n){
            dp[n] = min(dp[n],dp[n-power] + 1);
            power *= 6;
        }
        power = 1;
        while(power <= n){
            dp[n] = min(dp[n],dp[n-power] + 1);
            power *= 9;
        }
    }
    int N;
    cin >> N;
    cout << dp[N] << endl;
    return 0;
}


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

using namespace std;

int N;
vector<int> h;
int detectDivision(){
    int segment = 0;
    bool connect = false;
    for (int i = 0; i < N; i++){
        if(h[i]>0){
            if(!connect){
                connect = true;
                segment++;
            }
        }else{
            if(connect){
                connect = false;
            }
        }
        h[i]--;
    }
    return segment;
}

int main(){
    int max = 0;
    int result = 0;
    cin >> N;
    h.resize(N);
    for (int i = 0; i < N; i++){
        cin >> h[i];
        if(max < h[i]){
            max = h[i];
        }
    }
    for (int i = 0; i < max; i++){
        result += detectDivision();
    }

    cout << result << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys
import bisect


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(input())

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数で合計
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if ((i >> j) & 1) == 1:
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val


"""ここからメインコード"""


def main():
    """クラス呼び出し等行うよ"""
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""

    """コピーコードです。"""
    n = ip.I()
    s = ''
    while True:
        r = n % (-2)
        n //= -2
        if r < 0:
            r += 2
            n += 1
        s += str(r)
        if n == 0: break
    print(s[::-1])


main()


Measured memory_bytes: 3316
import java.util.*;
import java.io.*;
public class Main {
	static Long [][] memo;
	static long [] value,cost;
	static int n , h;
  public static void main(String[] args) throws IOException,InterruptedException{
	Scanner sc =new Scanner(System.in);
	PrintWriter pw = new PrintWriter(System.out);
	 n =sc.nextInt();h=sc.nextInt();
	 memo =new Long[n+1][h+1];
	 cost=new long [n+1];
	 value=new long [n+1];
	 for (int i =0;i<n;++i) {
		 cost[i]=sc.nextInt();
		 value[i]=sc.nextInt();
	 }
	 pw.println(dp(0, h));	
	pw.flush();
	}
  public static long dp (int index ,long width) {
	  if (index==n)
		  return 0;
	  if (width<0)
		  return -(int)1e9;
	  if (memo[(int)index][(int)width]!=null)
		  return memo[(int)index][(int)width];
	  long ans =0;
	  if (width-cost[(int)index]<0)
		  ans =dp(index+1,width);
	  else
		  ans =Math.max(dp(index+1, width), dp(index+1, width-cost[index])+value[index]);
	  return memo[(int)index][(int)width]=ans;
  }
  static class Scanner {
		StringTokenizer stringTokenizer;
		BufferedReader bfBufferedReader;
		public Scanner(InputStream system) {
			bfBufferedReader=new BufferedReader(new InputStreamReader( system));
		}
		 public Scanner(String file) throws Exception {
	            bfBufferedReader = new BufferedReader(new FileReader( file));
	        }			 
	        public String next() throws IOException {
	            while (stringTokenizer == null || !stringTokenizer.hasMoreTokens())
	                stringTokenizer = new StringTokenizer( bfBufferedReader.readLine());
	            return stringTokenizer.nextToken();
	        }
	 
	        public String nextLine() throws IOException {
	            return bfBufferedReader.readLine();
	        }
	 
	        public int nextInt() throws IOException {
	            return Integer.parseInt(next());
	        }
	 
	        public double nextDouble() throws IOException {
	            return Double.parseDouble(next());
	        }
	 
	        public char nextChar() throws IOException {
	            return next().charAt(0);
	        }
	 
	        public Long nextLong() throws IOException {
	            return Long.parseLong(next());
	        }
	 
	        public boolean ready() throws IOException {
	            return bfBufferedReader.ready();
	        }
	 
	        public void waitForInput() throws InterruptedException {
	            Thread.sleep(3000);
	        }
  }
  }

Measured memory_bytes: 289008
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a[10];
	for(int i=0;i<10;i++){
		cin>>a[i];
	}
	sort(a,a+10);
	for(int i=9;i>6;i--){
		cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> b(n+1);
    vector<int> ans;
    for (int i = n; i >= 1; i--) {
        int sum = 0;
        for (int j = i; j <= n; j += i) {
            sum += b[j];
        }
        if (sum % 2 != a[i]) {
            b[i]++;
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (int x : ans) {
        cout << x << " ";
    }
    cout << endl;
}

Measured memory_bytes: 5380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readS(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readS(String str) {
		for (char c : str.toCharArray()) {
			System.out.print((char) ((c - 'A' + N) % 26 + 'A'));
		}
		System.out.println();
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 22740
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n;
Int nxt[20][220000];

vector<Int> calc(vector<Int> &a, Int v){
    Int jump = 0;
    for(;;){
        Int last = 0;
        for(Int j = 0;j < n;j++){
            if(j == n-1 || abs(a[j+1] - a[j]) > v){
                for(Int k = last;k <= j;k++)
                    nxt[jump][k] = j+1;
                last = j+1;
            }
        }
        jump++;
        if(v == 0)break;
        v/=2;
    }
    vector<Int> dp(1 << jump, 0);
    for(Int i = 0;i < (1 << jump);i++){
        for(Int j = 0;j < jump;j++){
            if((1 << j) & i)continue;
            dp[(1 << j) | i] = max(dp[(1 << j) | i], nxt[j][dp[i]]);
        }
    }
    return dp;
}

Int ok[1 << 20];

int main(){
    Int v;
    cin >> n >> v;
   
    vector<Int> a(n);
    for(auto &x:a)cin >> x;
    reverse(a.begin(), a.end());
    auto rev_dp = calc(a, v);
    reverse(a.begin(), a.end());
    auto dp = calc(a, v);

    Int not_zero = dp.size() - 2;
    for(Int l = 0;l <= not_zero;l += 2){
        Int r = not_zero - l;
        if(nxt[0][dp[l]] + rev_dp[r] >= n){
            ok[dp[l]]++;
            ok[nxt[0][dp[l]]]--;
        }
    }
    for(Int i = 1;i < n;i++)ok[i] += ok[i-1];
    for(Int i = n-2;i >= 0;i--){
        if(ok[i+1] && abs(a[i+1] - a[i]) <= v)ok[i] = true;
    }
    for(Int i = 0;i < n;i++){
        if(ok[i])cout << "Possible" << endl;
        else cout << "Impossible" << endl;
    }
    return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
    int n; cin >> n;
    ll ans = 1;
    ll l_1 = 2, l_2 = 1; 
    FOR(i, 1, n) {
        ans = l_1 + l_2;
        l_1 = l_2;
        l_2 = ans;
    }
    cout << ans << endl;
}


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


class Program {

	static int testN = 3;
	static long mod = 1000000007;
	//static long mod =998244353; 
	static System.IO.StringReader sr;
		static void Main(string[] args) {
			char[] cs = new char[] { ' ' };
		//char[] cs = new char[] { ' ', ',' };

		//int n = int.Parse(Console.ReadLine());
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res = "";

		int res = 0;

		int[] vals = parseAry(Console.ReadLine().Split(cs));
		int k = vals[0];
		int n = vals[1];
		vals = parseAry(Console.ReadLine().Split(cs));

		int dir = k - vals[n - 1]+vals[0];

		res = Math.Min(vals[n - 1] - vals[0], k - vals[0]);
		for(int i = 1; i < n; i++) {
			int t = k - (vals[i] - vals[i - 1]);
			res = Math.Min(res, t);
		}








		Console.WriteLine(res);
			return;

		
	}


	//	文字列strをindex番目からdで上書き
	static string strOverWrite(string str, int i, string s) {
		return str.Remove(i, s.Length).Insert(i, s);
	}

	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { nums[i] = long.Parse(str[i]); }
		return nums;
	}

	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for ( int i = 0; i < str.Length; i++ ) { re[i] = str[i].ToString(); }
		return re;
	}



}

Measured memory_bytes: 34524
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int N;
    cin >> N;
    int sum = 0;
    vector<int> a;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end(), greater<int>());
    for (int i = 0; i < N; i++) {
        if ((i % 2) == 0) {
            sum += a[i];
        } else {
            sum -= a[i];
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3576
import statistics
n=int(input())
r=set([])
x=[[]]*n
for i in range(n):
  a,b=list(map(int,input().split()))
  x[i]=[a,b]
r0=statistics.median([x[z][0] for z in range(n)])
r1=statistics.median([x[z][1] for z in range(n)])
addnum = 1
if ((r0*2) % 2)>0 and ((r1*2) % 2)>0:
  mult=2
  addnum = 1
elif ((r0*2) % 2)>0:
  mult=2
  addnum = 0  
elif ((r1*2) % 2)>0:
  mult=2
  addnum = 0  
else:
  mult=1
  addnum = 1
#print(r0)
#print(r1)
if n%2 ==0:
  mult=2
else:
  mult=1
addnum=1
mult=int((r1-r0)*mult+addnum)
print(mult)
  #r=r|

Measured memory_bytes: 44724
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <complex>
#include <string.h>
#include <iomanip>
using namespace std;

typedef long long ll;

struct edge { int to, cost; };
typedef pair<int, int> P;

const int inf = 1000000000;
const int max_v = 6000;
int V;
//map<string, vector<edge> > G1;
vector<edge> G1[max_v];
//map<string, vector<edge> > G2;
vector<edge> G2[max_v];
set<string> allcities;
map<string, int> ind;
int d[max_v];


void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+V, inf);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (edge e : G1[v]) {
      if (d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}

void dijkstra2(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d+V, inf);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (edge e : G2[v]) {
      if (d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);

  while (true) {
    int n, m, cap;
    cin >> n >> m >> cap;
    if (n == 0 && m == 0 && cap == 0) break;
    string src, dest;
    cin >> src >> dest;
    for (int i = 0; i < n; i++) {
      string c1, c2;
      int dis;
      cin >> c1 >> c2 >> dis;
      int i1, i2;
      if (allcities.find(c1) == allcities.end()) {
	i1 = allcities.size();
	allcities.insert(c1);
	ind[c1] = i1;
      } else {
	i1 = ind[c1];
      }
      if (allcities.find(c2) == allcities.end()) {
	i2 = allcities.size();
	allcities.insert(c2);
	ind[c2] = i2;
      } else {
	i2 = ind[c2];
      }
      G1[i1].push_back((edge){i2, dis});
      G1[i2].push_back((edge){i1, dis});
    }
    V = allcities.size();
    vector<int> lpg(m+2);
    for (int i = 0; i < m; i++) {
      string s;
      cin >> s;
      lpg[i] = ind[s];
    }
    lpg[m] = ind[src]; lpg[m+1] = ind[dest];
    for (int i = 0; i < m+2; i++) {
      dijkstra(lpg[i]);
      for (int j = 0; j < m+2; j++) {
	if (j == i) continue;
	if (d[lpg[j]] <= 10 * cap)
	  G2[lpg[i]].push_back((edge){lpg[j], d[lpg[j]]});
      }
    }
    dijkstra2(lpg[m]);
    if (d[lpg[m+1]] >= inf)
      cout << -1 << endl;
    else
      cout << d[lpg[m+1]] << endl;
    for (int i = 0; i < V; i++) {
      G1[i].clear();
      G2[i].clear();
    }
    allcities.clear();
  }
}

Measured memory_bytes: 14388
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	var s string
	fmt.Scan(&s)

	fmt.Println(s[:k-1] + strings.ToLower(string(s[k-1])) + s[k:])
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
  int W, a, b;
  cin >> W >> a >> b;
  if(a + W >= b && a <= b + W) cout << 0 << endl;
  else cout << min(min(abs(b-a-W),abs(b-a)),min(abs(a-b-W),abs(a-b))) << endl;;
  return 0;
}


Measured memory_bytes: 256
/*input
*/
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define ff first
#define ss second
#define pb push_back
 
using ll = long long;
using pii = pair<int, int>;
using ld = long double;
 
template<typename T> using V = vector<T>;

map< vector<int>, int > mp;

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int n; cin >> n;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		vector<int> cnt(26, 0);
		for (auto c : s)
			++cnt[c - 'a'];
		++mp[cnt];
	}
	ll ans = 0;
	for (auto x : mp) {
		ans += ((ll)x.ss * (x.ss - 1)) / 2;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 19072
package main

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

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func main() {
	buf.Split(bufio.ScanWords)

	a := scanInt()
	b := scanInt()

	result := ""
	if a < b {
		aString := strconv.Itoa(a)
		for i := 0; i < b; i++ {
			result += aString
		}
	} else {
		bString := strconv.Itoa(b)
		for i := 0; i < a; i++ {
			result += bString
		}
	}

	fmt.Printf("%s", result)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define arr array

using namespace std;

const int e = 2e6 + 69;
const ll mod = 1e9 + 7;

ll a[e], pre[e];

//beginner 1999 129

int n;

int main()
{
     cin >> n;
     for(int i=1; i<=n; i++){
        cin >> a[i];
        pre[i] = pre[i-1] + a[i];
     }
     ll minn = 1e9;
     for(int i=1; i<=n; i++){
         minn = min(minn, abs(pre[i] - pre[n] + pre[i]));
     }
     cout << minn;
}


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

int main()
{
    int sx, sy, tx, ty;
    scanf("%d%d%d%d", &sx, &sy, &tx, &ty);
    for(int i = 0; i < abs(ty-sy); i++)printf("U");
    for(int i = 0; i < abs(tx-sx); i++)printf("R");
    for(int i = 0; i < abs(ty-sy); i++)printf("D");
    for(int i = 0; i < abs(tx-sx); i++)printf("L");
    printf("L");
    for(int i = 0; i <= abs(ty-sy); i++)printf("U");
    for(int i = 0; i <= abs(tx-sx); i++)printf("R");
    printf("DR");
    for(int i = 0; i <= abs(ty-sy); i++)printf("D");
    for(int i = 0; i <= abs(tx-sx); i++)printf("L");
    printf("U");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int input[] = new int[4];
		for (int i = 0; i < 4; i++) {
			input[i] = sc.nextInt();
		}

		int distance = input[3];
		if (Math.abs(input[0] - input[2]) <= distance) {
			System.out.println("Yes");
			return;
		}
		if ((Math.abs(input[0] - input[1]) <= distance) && (Math.abs(input[1] - input[2]) <= distance)) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 20948
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int H,M,S;
	while(cin>>H>>M>>S,H!=-1 && M!=-1 && S!=-1){
		S += M*60+H*3600;
		S = 2*3600-S;
		printf("%02d:%02d:%02d\n",S/3600,S/60%60,S%60);
		S *= 3;
		printf("%02d:%02d:%02d\n",S/3600,S/60%60,S%60);
	}
	return 0;
}

Measured memory_bytes: 1160
//  1 2 3 4 5 6
#include<stdio.h>
int main()
{
    int n,d,e,acm;
    while(~scanf("%d%d",&n,&d))
    {
        acm=0;
        e=d*2+1;
        if(n%e==0)
            acm=n/e;
        else
            acm=n/e+1;
        printf("%d\n",acm);
    }
    return 0;
}


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

int a;
string s;

int main(){

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

    cin>>a;
    cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }

    return 0;
}

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


int main(){
  int n,i;
  cin >> n;
  vector<int> a(n);
  int ans=0;
  for(i=0;i<n;++i){
    cin >> a[i];
    ans+=a[i];
    ans--;
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define N 10000

int c[N][N];

int LCS(char *com, char *com2){
  int i,j,m,n;
  m = strlen(com)-1;
  n = strlen(com2)-1;
  
  for(i=1;i<=m;i++){
    c[i][0] = 0;
  }
  for(j=0;j<=n;j++){
    c[0][j] = 0;
  }
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(com[i] == com2[j]){
	c[i][j] = c[i-1][j-1] + 1;
      }else if(c[i-1][j] >= c[i][j-1]){
	c[i][j] = c[i-1][j];
      }else{
	c[i][j] = c[i][j-1];
      }
    }
  }
  return c[m][n];
}
      

int main(){
  int q,i;
  char com[N],com2[N];
  scanf("%d",&q);
  for(i=0;i<q;i++){
    com[0] = ' ';
    com2[0] = ' ';
    scanf("%s",&com[1]);
    scanf("%s",&com2[1]);
    printf("%d\n",LCS(com,com2));
  }

  return 0;
}

  



Measured memory_bytes: 9744
import itertools
N,M,X = map(int,input().split())
L = [i for i in range(0,2)]
c_list = list(itertools.product(L, repeat=N)) #重複あり組み合わせ
Alg = []
for i in range(N):
    Alg.append(list(map(int,input().split())))
Ans = 1<<50
Money = 0
def judge(per):
    Money = 0
    tryAlg = [0]*M
    for i in range(len(per)):
        if per[i] == 1:
            Money += Alg[i][0]
            for j in range(1,M+1):
                tryAlg[j-1] += Alg[i][j]
    for m in tryAlg:
        if m < X:
            Money = -1
            break
    return Money
for per in c_list:
    An = judge(per)
    if An != -1:
        Ans  = min(An,Ans)
if Ans == 1<<50:
    Ans = -1
print(Ans)

Measured memory_bytes: 9612
#include<stdio.h>
int j,i,n,x=0;
int main(){while(scanf("%d",&n)!=EOF){for(i=n-1;;i--){for(j=2;j*j<=i;j++){ if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d ",i); goto q;} x=0;}q:for(i=n+1;;i++){for(j=2;j*j<=i;j++){  if(j!=i){if(i%j==0){x=1;}}}if(x==0) {printf("%d\n",i); goto r;} x=0;} r:; }return 0;}

Measured memory_bytes: 596
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	map<int, int> m;
	rep(i, n)++m[a[i]];
	int ans = 0;
	for (const auto& aa : m) {
		ans += (aa.second >= aa.first ? aa.second - aa.first : aa.second);
	}
	printf("%d\n", ans);

	Please AC;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define MOD 1000000007
#define mod 998244353
#define pie 3.14159265358979323846264338327950L
#define N 200009
#define M 2000009
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define umap unordered_map<int, int>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}
 






void test_case() {
    int n;
    cin>>n;

    cout<<n*n<<endl;
    
}
    

signed main ()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toInt() }
    println(problem064b(n, a))
}

fun problem064b(n: Int, a: List<Int>): Int {
    return a.max()!! - a.min()!!
}

Measured memory_bytes: 31520
n, q=map(int, input().split())
s=input()


z=[0]*n
count=0
for i in range(n):
    z[i]=count
    if s[i]=="A" and i<=n-2:
        if s[i+1]=="C":
            count+=1
            z[i]+=1

for i in range(q):
    l, r =map(int,input().split())
    #r文字目までのACの数-(l-1)文字目まで
    if l==1:
        ans=z[r-2]
    elif r-l==1:
        if s[l-1]=="A" and s[l]=="C":
            ans=1
        else:
            ans=0
    else:
        ans=z[r-2]-z[l-2]
    print(ans)


Measured memory_bytes: 9304
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")


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

	string s;
	cin >> s;
	int keta = 0;

	ll ans = INF;

	for (int i = 2; i < s.size(); i++)
	{
		ll val = s[i]-'1'+1 + (s[i - 1]-'1'+1) * 10 + (s[i - 2]-'1'+1) * 100;
		ans = min(ans, abs(753 - val));
	}

	cout << ans << endl;


}

Measured memory_bytes: 256
while True:
    points = list(map(int,input().split()))
    if points==[-1,-1,-1]: break
    sum_pt = sum(points[0:2])
    if points[0]==-1 or points[1]==-1 or sum_pt<30: print('F')
    elif sum_pt<50 and points[2]<50: print('D')
    elif sum_pt<65: print('C')
    elif sum_pt<80: print('B')
    else: print('A')

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

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


Measured memory_bytes: 256
// abc113_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    vector<pair<int, P>> info(M);
    REP(i, M){
        cin >> info[i].second.first >> info[i].first;
        info[i].second.second = i;
    }
    sort(ALL(info));

    vector<int> cnts(N, 1);

    vector<string> ans(M);
    REP(i, M){
        ll p = info[i].second.first;
        ll idx = cnts[p-1];

        ll num = (ll)1e6 * p + idx;
        ostringstream ss;
        ss << setw(12) << setfill('0') << num;

        ans[info[i].second.second] = ss.str();
        cnts[p-1]++;
    }

    REP(i, M){
        print(ans[i]);
    }



    return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int even[100010];
int odd[100010];

int main(){
    int n,t;cin >> n;
    REP(i,n){
        cin >> t;
        if(i%2==0)odd[t]++;
        else even[t]++;
    }
    int odd1,odd2,odd_num1,odd_num2;
    int max1 = 0;
    REP(i,100010){
        if(max1<odd[i]){
            max1 = odd[i];
            odd_num1 = i;
        }
        odd1 = max1;
    }
    int max2 = 0;
    REP(i,100010){
        if(max2<odd[i]){
            if(i==odd_num1)continue;
            max2 = odd[i];
            odd_num2 = i;
        }
        odd2 = max2;
    }
    //odd1,odd2は個数,odd_num1,odd_num2はその数
    //evenも同様に
    int even1,even2,even_num1,even_num2;
    int max3 = 0;
    REP(i,100010){
        if(max3<even[i]){
            max3 = even[i];
            even_num1 = i;
        }
        even1 = max3;
    }
    int max4 = 0;
    REP(i,100009){
        if(max4<even[i]){
            if(i==even_num1)continue;
            max4 = even[i];
            even_num2 = i;
        }
        even2 = max4;
    }
    int ans = 0;
    //cout << odd1 << " " << odd2 << " " << even1 << " " << even2 << endl;
    
    if(odd_num1!=even_num1)ans = n-odd1-even1;
    else ans = min(n-(odd1+even2),n-(even1+odd2));
    COUT(ans);
    return 0;
}

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

int main() {
    int n, t, a;
    cin >> n >> t >> a;
    int ans = 1;
    double x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        x[i] = abs(t - x[i] * 0.006 - a);
    }
    cout << 1 + (min_element(x, x + n) - x) << endl;
    return 0;
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n,m;
    cin >> n;
    map<string,int> s;
    string str;
    rep(i,n){
        cin >> str;
        s[str]++;
    }

    cin >> m;
    map<string,int> t;
    rep(i,m){
        cin >> str;
        t[str]++;
    }

    int ans =0;
    for(auto a:s){
        int x = a.second;
        int c = t.count(a.first);
        if(c==0){
            ans = max(ans,x);
        }else{
            ans = max(ans,x-t[a.first]);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void){

  while(1){ 
    int a = 1;//上
    int b = 2;//南
    int c = 3;//東
    string s;
    int n;
    cin >> n;
    if( n == 0 )break;
    int sum = 1;
    for( int i = 0 ; i < n ; i++ ){
     
      cin >> s;

      if( s == "North" ) {
	int temp1 = b;
	b = 7 - a;
	a = temp1;
	sum += a;
      }
      else if( s == "East" ){
	int temp2 = c;
	c = a;
	a = 7 - temp2;
	sum += a;
      }
      else if( s == "West" ){
	int temp3 = c;
	c = 7 - a;
	a = temp3;
	sum += a;
      }
      else if( s == "South" ){
	int temp4 = a;
	a = 7 - b;
	b = temp4;
	sum += a;
      }
      else if( s == "Right" ){
	int temp5 = b;
	b = c;
	c = 7 - temp5;
	sum += a;
      }
      else if( s == "Left" ){
	int temp6 = c;
	c = b;
	b = 7 - temp6;
	sum += a;
      }
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
package main

import "fmt"

func main(){
	var n string
	fmt.Scan(&n)
	flag := false
	for i:=0 ; i<3 ; i++{
		if (n[i:i+1] == "7") {
			flag = true
		}
	}
	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=9000000009;
const double eps=1e-10;

signed main(){
  int n,m;
  cin>>n>>m;
  int ans=0;
  if(n-2>=0&&m-2>=0)ans+=(n-2)*(m-2);
  if(n==1&&m==1)ans++;
  else if(n==1||m==1){
    ans+=(max(n,m)-2);
  };
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
S = input()
if S[0] == ">":
  S = "<" + S
if S[-1] == ">":
  S = S + "<"
elif S[-1] == "<":
  S = S + "><"
L = []
T = []

now = S[0]
for i in range(len(S)):
  if now == ">" and S[i] == "<":
    now = S[i]
    L.append(2)
  elif now == "<" and S[i] == ">":
    now = S[i]
    L.append(1)
  else:
    L.append(0)    
if L.count(2) == 0:
  L.append(2)
  
countl, countr = 0, 0
flag = 0
for i in range(len(L)):
  if L[i] == 0 and flag == 0:
    countl += 1
  elif L[i] == 0 and flag == 1:
    countr += 1
  elif L[i] == 1:
    flag = 1
    countr += 1
  else: # L[i] == 2
    if countl > countr:
      T.append((countl)*(countl+1)//2)
      T.append((countr)*(countr-1)//2)
    else:
      T.append((countl)*(countl-1)//2)
      T.append((countr)*(countr+1)//2)
    flag = 0
    countl, countr = 1, 0

print(sum(T))



Measured memory_bytes: 10288
using System;
using System.Collections.Generic;

    class Program
    {
        static void Main(string[] args)
        {
            List<int> heights = new List<int>(10);
            for (int i = 0; i < 10; ++i)
            {
                heights.Add(Int32.Parse(Console.ReadLine()));
            }

            heights.Sort();

            for (int i = 9; i >= 7; --i)
            {
                Console.WriteLine(heights[i]);
            }
        }
    }

Measured memory_bytes: 9300
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

struct student{
	int score;
	int id;
};

bool asc( const struct student& left,const struct student& right){
	return left.score == right.score ? left.id < right.id : left.score < right.score;
}

int main()
{
	int n;
	cin>>n;
	struct student *studentList = new struct student[n];
	for(int i = 0; i < n; i++){
		int studentId = i + 1;
		int score;
		cin>>score;
		studentList[i].id = studentId;
		studentList[i].score = score;		
	}
	sort(studentList,studentList + n,asc);
	cout<<studentList[0].id;
	for(int i = 1; i < n; i++){
		cout<<" "<<studentList[i].id;
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 1664
import numpy as np
N,D = map(int,input().split())
point_list = np.zeros((N,D))

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

cnt=0
for i in range(N-1):
  temp_point_list = point_list[i+1:,:].copy()
  temp_point_list = temp_point_list - point_list[i,:]
  temp_point_list = np.sqrt(np.sum(temp_point_list*temp_point_list, axis=1))
  for i in range(temp_point_list.shape[0]):
    if temp_point_list[i] == int(temp_point_list[i]):
      cnt+=1
      
print(cnt)
  

Measured memory_bytes: 12424
import java.util.Scanner;
import java.math.BigInteger;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    BigInteger bf = BigInteger.valueOf(1);
    for (int i = 1; i < n+1; i++) {
      bf = bf.multiply(BigInteger.valueOf(i));
    }
    System.out.println(bf.toString());
  }
}

Measured memory_bytes: 11000
K,S = map(int, input().split(" "))
count=0
for a in range(K+1):
    if S<a:
        break
    for b in range(K+1):
        c=S-(a+b)
        if c==0:
            count+=1
            break
        elif c>K:
            continue
        count+=1
print(count)


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

int main() {
    string S, T, s, t;
    cin >> S;
    T=S;
    reverse(T.begin(), T.end());
    if (S!=T) {
        cout << "No";
        return 0;
    }
    s = S.substr(0, (S.size()-1)/2);
    t = s;
    reverse(t.begin(), t.end());
    if (s!=t) {
        cout << "No";
        return 0;
    }
    s = S.substr(((S.size()+3)/2)-1);
    t = s;
    reverse(t.begin(), t.end());
    if (s!=t) {
        cout << "No";
        return 0;
    }
    cout << "Yes";
}

Measured memory_bytes: 256