akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using CHY72;

namespace CHY72{

    public class PointXY<T>where T:IComparable {
        public T X , Y;
        public bool Flag = false;
        public PointXY(T _X,T _Y) {
            X = _X; Y = _Y;
        }
        public static bool operator ==(PointXY<T> P1, PointXY<T> P2) {
            return (P1.X.CompareTo( P2.X) == 0 && P1.Y.CompareTo (P2.Y) == 0);
        }
        public static bool operator !=(PointXY<T> P1, PointXY<T> P2) {return !(P1 ==P2);}
        public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}
        public override bool Equals(object obj) {
            if (obj == null || this.GetType() != obj.GetType()) {return false;}
            return (this == (PointXY<T>)obj);
        }         

    }

}    

public class Program {
    static bool ReadLine_1(ref int num1, bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str);
        return (Fin0 && num1 == 0);
    }
    static int  ReadLine_1() {
        return  int.Parse(Console.ReadLine());
    }
    static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true) {
        string str = Console.ReadLine();
        num1 = int.Parse(str.Split(Spliter)[0]);
        num2 = int.Parse(str.Split(Spliter)[1]);
        return (Fin0 && num1 == 0);
    }


    
    const int  DefaultMax = 727272;

    static void Main(string[] args) {
        while (true) {
            int Anum=0,Bnum=0;
            if (ReadLine_2(ref Anum, ref Bnum)) return;
            int[] A = new int [Anum]; 
            int[] B = new int [Bnum];
            for (int i = 0; i < Anum; i++) { A[i] = ReadLine_1(); }
            for (int i = 0; i < Bnum; i++) { B[i] = ReadLine_1(); }
            int SumA = A.Sum();
            int SumB = B.Sum();
            int ChangeA = DefaultMax, ChangeB = DefaultMax;
            for (int i = 0; i < Anum ; i++) {
                for (int j = 0; j < Bnum; j++) {
                    if (2 * A[i] - 2 * B[j] == SumA - SumB) {
                        if (ChangeA + ChangeB > A[i] + B[j]) {
                            ChangeA = A[i]; ChangeB = B[j];
                        }
                    }
                }
            }
            if (ChangeA == DefaultMax) Console.WriteLine(-1);
            else Console.WriteLine(ChangeA +" "+ChangeB);

        }


    }
}

Measured memory_bytes: 5856
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		long M = scn.nextLong();
		long ans = 0;
		if (N < 3 || M < 3) {
			if (N == 1) {
				if (M == 1) {
					ans = 1;
				} else {
					ans = M - 2;
				}
			} else {
				if (M == 1) {
					ans = N - 2;
				} else {
					ans = 0;
				}
			}
		} else {
			ans = (N - 2) * (M - 2);

		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 23252
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<string>

using namespace std;

int main(void) {

	int n, col[4] = {}, num = 0;

	cin >> n;

	string s;

	for (int i = 0; i < n; i++)
	{
		cin >> s[n];
		if (s[n] == 'P')col[0]++;
		if (s[n] == 'W')col[1]++;
		if (s[n] == 'G')col[2]++;
		if (s[n] == 'Y')col[3]++;
	}

	for (int i = 0; i < 4; i++)
	{
		if (col[i] >= 1)num++;
	}

	if (num == 3)cout << "Three\n";
	else cout << "Four\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[2][1000000];
int v[250];
int main()
{
	int n;
	for (int j = 0; j < 1000000; j++)
	{
		dp[0][j] = 999999;
		dp[1][j] = 999999;
	}
	dp[0][0] = 0;
	dp[1][0] = 0;
	for (int i = 1;i < 250; i++)
	{
		int k = i * (i + 1) * (i + 2) / 6;
		if (k >= 1000000)break;
		v[i - 1] = k;
	}
	for (int i = 0; i < 1000000; i++)
	{
		for (int j = 0;j < 250; j++)
		{
			if (i + v[j] >= 1000000)break;
			dp[0][i + v[j]] = min(dp[0][i + v[j]], dp[0][i] + 1);
			if (v[j] % 2 == 0)continue;
			dp[1][i + v[j]] = min(dp[1][i + v[j]], dp[1][i] + 1);
		}
	}
	while (cin >> n && n != 0)
	{
		cout << dp[0][n] << " " << dp[1][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8972
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <cstdlib>
#include <math.h>

using namespace std;

typedef long long ll;
#define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,a,b) for(long i=(a);i<(b);i++)
#define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
#define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
#define define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define X first
#define Y second
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int> >
#define vpl vector<pair<long, long> >
#define vppl vector<pair<long, pair<long, long> > >

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const ll LINF = 1e18;

int printYes() {
    cout << "Yes" << endl;
    return 0;
}

int printNo() {
    cout << "No" << endl;
    return 0;
}

int ans;

int printAns() {
    cout << ans << endl;
    return 0;
}


int pow(int x) {
	if (x == 0) {
		return 1;
	}
	else {
		return pow(x - 1) * 2;
	}
}

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int n = N;
    int sn = 0;
    while(n != 0){
        sn += n % 10;
        n = (n - n % 10) / 10;
    }
    if (N % sn == 0) {
        cout << "Yes" << endl;
    } else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define                          ll                          long long int
ll gcd(int a,int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

#define                          in(x)                       scanf("%lld",&x)
#define                          in2(x,y)                    scanf("%lld %lld",&x,&y)
#define                          in3(x,y,z)                  scanf("%lld %lld %lld",&x,&y,&z)
#define                          out(x)                      printf("%lld\n",x)
#define                          cy                          printf("YES\n")
#define                          cn                          printf("NO\n")
#define                          inf                         1e18
#define                          neg                         -1e18
#define                          maxn                          2111111
#define                          fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                          fi                          frist
#define                          si                          second
#define                          ce                          cout<<endl
#define                          pb                          push_back
#define                          vc(x)                       x.begin(),x.end()
#define                          pb                          push_back
#define                          pi                          pair<ll,ll>
#define                          debug                       printf("ok\n");
#define                          pg                          pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> >
vector<ll> vt[maxn];
ll vis[maxn];
ll cnt;
void dfs(ll u)
{
    cnt++;

    vis[u]=1;
    for(auto v:vt[u])
    {
        if(!vis[v])
        {
            dfs(v);
        }
    }


}
int main()
{
   ll i,j,t,k,ans=0;
    ll n,m;
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x>>y;
        vt[x].pb(y);
        vt[y].pb(x);
    }


    for(ll kk=1;kk<n;kk++)
    {
        cnt=0;
        if(!vis[kk])
        {

            dfs(kk);
        }

        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 67008
N,K = map(int,input().split())
src = list(map(int,input().split()))

cums = [0]
cump = [0]
for a in src:
    cums.append(cums[-1] + a)
    cump.append(cump[-1] + max(0,a))

ans = 0
for i in range(N-K+1):
    tmp = cump[i]
    tmp += max(0, cums[i+K] - cums[i])
    tmp += cump[N] - cump[i+K]
    ans = max(tmp, ans)
print(ans)


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

#define READ freopen("alu.txt", "r", stdin);
#define WRITE freopen("vorta.txt", "w", stdout);
#define INFLOOP puts("lup");getchar()
#define xx first
#define yy second

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<int>::iterator vi_i;
typedef pair<double, double> pff;

const int MAX = 3e5 + 5, MOD = 1e9 + 7;

int main()
{
	ll n, m, ans;
	scanf("%lld %lld", &n, &m);
	if(n > m) swap(n, m);
	if(n == 1){
		if(m == 1) ans = 1;
		else ans = m - 2;
	}
	else if(n == 2) ans = 0;
	else ans = (n - 2) * (m - 2);
	printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>

#define Maxn 200010

using namespace std;

inline int read() {
    int x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n;
char col[Maxn];

int main() {
    n = read();
    scanf("%s", col + 1);
    int l = 1, r = n, cnt = 0;
    while(true) {
        while(col[l] == 'R') ++l;
        while(col[r] == 'W') --r;
        if(l < r) ++cnt, ++l, --r;
        else break;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3860
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	A, B := sc.nextInt(), sc.nextInt()
	if A >= 13 {
		fmt.Println(B)
	} else if A >= 6 {
		fmt.Println(B / 2)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  // start-----------------------------------------------
  string s; cin >> s;
  vector<ll> nows(2020);
  vector<ll> rem(2020, 0);
  ll now = 0;
  ll t = 1;
  rem[0] = 1;
  for(int i = s.length()-1; i >= 0; i--){
    now += t * (s[i] - '0');
    now %= 2019;
    rem[now]++;
    t *= 10;
    t %= 2019;
  }
  ll ans = 0;
  for(int i = 0; i < 2019; i++){
    ans += rem[i] * (rem[i] - 1)/2;
  }
  cout << ans << endl;

  // end-----------------------------------------------
}


Measured memory_bytes: 3732
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int l;
    std::string S;
    cin >>l>> S;
    int ans=0;
    for (int i = 0;i < S.length()-2; i++) 
    {
        if(S[i]== 'A' && S[i+1]== 'B'  && S[i+2]=='C'){
                    ans++;
        }
    
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;

const int INF = 2 * (100000 + 1);
int N;
ll M;
vector<int> A;
vector<ll> B;

void input_init(void) {
	cin >> N >> M;
	A.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> A[i];
	sort(A.begin(), A.end());
	B.resize(N);
	B[N - 1] = (ll)A[N - 1];
	for (int i = N - 2; i >= 0; --i)
		B[i] += (ll)A[i] + B[i + 1];
}

ll getCount(int tot) {
	ll res = 0;
	for (int i = 0; i < N; ++i) {
		int Ay = tot - A[i];
		int idx = lower_bound(A.begin(), A.end(), Ay) - A.begin();
		res += N - idx;
	}
	return res;
}

int val_check(void) {
	int lo = 0, hi = INF;
	while (lo + 1 != hi) {
		int md = (lo + hi) / 2;
		if (M <= getCount(md))
			lo = md;
		else
			hi = md;
	}
	return lo;
}

ll getSum(int tot) {
	ll res = 0;
	for (int i = 0; i < N; ++i) {
		int Ay = tot - A[i];
		if (Ay > A[N - 1]) continue;
		int idx = lower_bound(A.begin(), A.end(), Ay) - A.begin();
		int cnt = N - idx;
		res += (ll)A[i] * cnt;
		res += B[idx];
	}
	return res;
}

int main(void) {
	input_init();
	int val = val_check();
	ll cnt = getCount(val);
	ll sum = getSum(val);
	ll ans = sum - val * (cnt - M);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 1408
A, B, C, X, Y = list(map(int, input().split()))

if A+B  <= 2*C:
    print(A*X + B*Y)
elif X > Y:
    print(2*C*Y + (X-Y) * min(2*C, A))
else:
    print(2*C*X + (Y-X) * min(2*C, B))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

int n;

int main() {
    cin >> n;
    while(n--) {
        int y, m, d; cin >> y >> m >> d;
        int normal = 39*5;
        int iregular = 20*10;
        int icnt = 999/3 - y/3;
        int irest = 0, nrest = 0;
        if(y%3 == 0) {
            // うるう年の途中
            int inow = (m-1)*20;
            inow += d;
            irest = iregular-inow;
        }else {
            int nnow = 0;
            for(int i = 1; i < m; ++i) {
                if(i%2 != 0) nnow += 20;
                else nnow += 19;
            }
            nnow += d;
            nrest = normal-nnow;
        }
        int ycnt = 999 - y;
        int ncnt = ycnt - icnt;
        int ans = ncnt*normal + icnt*iregular + irest + nrest + 1;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3104
#include<iostream>
#include<cstring>

using namespace std;

const int N = 25;

int n, v[N], c[N], memo[N][2];

int dp(int indx, bool prev){
	if(indx == n) return 0;
	else if(memo[indx][prev] != -1){
		return memo[indx][prev];
	}
	int val1, val2;
	val1 = dp(indx + 1, false);
	val2 = dp(indx + 1, true) + v[indx] - c[indx];
	return memo[indx][prev] = max(val1, val2);
}

int main(){
	memset(memo, -1, sizeof(memo));
	scanf("%d", &n);
	for(int i = 0 ; i < n ; i++){
		scanf("%d", v + i);
	}

	for(int i = 0 ; i< n ; i++){
		scanf("%d", c + i);
	}
	printf("%d", dp(0, false));
	return 0;
}


Measured memory_bytes: 256
import queue

INFTY=1<<21

#ダイクストラ法
def dijkstra(n,EdgeMatrix):

    NodeList=queue.PriorityQueue() #探索対象の頂点
    Distance=[INFTY]*n #頂点0からの最短経路
    used=[False]*n #頂点の使用情報

    Distance[0]=0 #0から0までの距離は0
    used[0]=True #0から探索を始める
    LastNode=0 #最新の頂点
    count=1 #つないだ頂点の数

    while count<n:
        for i in range(n):
            #探索していない頂点へ距離の短い辺があればキューに追加
            if EdgeMatrix[LastNode][i]!=INFTY and used[i]==False:
                if Distance[i]>Distance[LastNode]+EdgeMatrix[LastNode][i]:
                    Distance[i]=Distance[LastNode]+EdgeMatrix[LastNode][i]
                    NodeList.put([Distance[i],i])

        #最も近い探索していない頂点
        while True:
            minNode=NodeList.get()
            if used[minNode[1]]==False:
                break

        LastNode=minNode[1] #最新の頂点を更新
        used[minNode[1]]=True #頂点の使用情報を更新
        count+=1 #つないだ頂点の数を更新

    return Distance

#入力
n=int(input())

#辺の隣接行列
EdgeMatrix=[[INFTY]*n for i in range(n)]
for i in range(n):
    l=(list(map(int,input().split())))
    for j in range(l[1]):
        EdgeMatrix[l[0]][l[2*j+2]]=l[2*j+3]

#頂点0からの最短経路
Distance=dijkstra(n,EdgeMatrix)

for node,distance in enumerate(Distance):
    print(node,distance)



Measured memory_bytes: 7196
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<cstring>
#include<utility>
#include<queue>
#include<string>
#include<iomanip>
#include<unordered_map>
using namespace std;
#define int long long
#define pb push_back
#define ppb pop_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define cfM 998244353
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define inf 10000000000000000
#define sp setprecision(9)
float pi=3.14159265;
int max(int b,int a)
{if(b>a)return b;else return a;}
int min(int b,int a)
{if(b<a)return b;else return a;}
int ab(int b)
{if(b<0) return (-1*b);else return(b);}
void print(vector<pair<int,int> >&v)
{
	fr(i,v.size())
	cout<<v[i].F<<" "<<v[i].S<<endl;
	cout<<endl;
}
void print(int arr[],int n)
{
	for(int i=0;i<n;i++)
		cout<<arr[i]<<" ";}
int32_t main()
{
	int n,W;
	cin>>n>>W;
	int w[n],v[n];
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	int dp[n][W+1];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=W;i++)
	{
		if(w[0]<=i)
			dp[0][i]=v[0];
	}
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=W;j++)
		{
			dp[i][j] = dp[i-1][j];
		      if (j >= w[i]) {
		        dp[i][j] = max(dp[i][j], dp[i-1][j - w[i]] + v[i]);
		      }
		}
	}
	int ans=-1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<W+1;j++)
		{
			ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll unsigned long long

const int MOD = 1000000007;

int main() {
	//入力
	int n;
	cin >> n;

	//処理
	int ans = 0;
	for (int i = 1;i < n;++i) {
		ans += ceil(((double)n - i) / i);
	}

	//出力
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			ArrayList<Integer> t = new ArrayList<Integer>();
			ArrayList<Integer> h = new ArrayList<Integer>();
			for (int i = 0; i < N; ++i) {
				t.add(sc.nextInt());
			}
			for (int i = 1; i <= 2 * N; ++i) {
				if (!t.contains(i)) h.add(i);
			}
			int top = 0;
			int turn = 0;
			while (!t.isEmpty() && !h.isEmpty()) {
				ArrayList<Integer> hand = turn == 0 ? t : h;
				int min = Integer.MAX_VALUE;
				for (int v : hand) {
					if (v > top && v < min) min = v;
				}
				if (min == Integer.MAX_VALUE) {
					top = 0;
				} else {
					hand.remove(Integer.valueOf(min));
					top = min;
				}
				turn = 1 - turn;
			}
			System.out.println(h.size());
			System.out.println(t.size());
		}
	}
}

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

int f(int p, vector<int> &x) {
    int sum = 0;
    for (auto &q : x) {
        sum += (p - q) * (p - q);
    }
    return sum;
}

int main() {
    int n;
    while (cin >> n) {
        vector<int> x(n);
        for (auto &a : x) cin >> a;
        double minc = 1e18;
        int ans = 0;
        for (int i = 0; i <= 100; ++i) {
            double cost = f(i, x);
            if (minc > cost) {
                minc = cost;
                ans = i;
            }
        }
        cout << f(ans, x) << endl;
    }
}


Measured memory_bytes: 256
// by ynymxiaolongbao 
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define N 500010

//FenwickTree↓
int dat[N];
void init(){
    rep(i,N)dat[i]=0;
}
void add(int i,int x){
    for(;i<N;i+=i&-i)dat[i]+=x;
}
int sum(int i){
    int res=0;
    for(;i>0;i-=i&-i)res+=dat[i];
    return res;
}
int rangesum(int l,int r){//[l,r]
    return sum(r)-sum(l-1);
}
//FenwickTree↑

int a[N];
vector<int> ql[N],qid[N];
int ans[N];

int n,q,c[N];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>c[i];
    rep(i,q){
        int l,r;
        cin>>l>>r;
        ql[r].push_back(l);
        qid[r].push_back(i);
    }
    init();
    for(int i=1;i<=n;i++)a[i]=0;
    for(int i=1;i<=n;i++){
        if(a[c[i]]>0)add(a[c[i]],-1);
        add(i,+1);
        a[c[i]]=i;
        rep(j,ql[i].size()){
            ans[qid[i][j]]=rangesum(ql[i][j],i);
        }
    }
    rep(i,q)cout<<ans[i]<<"\n";
}


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

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007;

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

int main() {
	string s, t;
	cin >> s >> t;
	ll result = 0;

	vector<vector<ll>> mp(30);
	rep(i, s.length()) {
		mp[s[i] - 'a'].push_back(i);
	}
	ll now = 0;
	rep(i, t.length()) {
		ll idx = t[i] - 'a';
		auto iter = lower_bound(mp[idx].begin(),mp[idx].end(), now);
		if (iter == mp[idx].end()) {
			now = 0;
			result += s.length();
			iter = lower_bound(mp[idx].begin(),mp[idx].end(), now);
			if (iter == mp[idx].end()) {
				cout << -1 << endl;
				return 0;
			}
		}
		ll target = *iter;
		now = target + 1;
		if (i == t.length() - 1) {
			result += target;
		}
	}
	cout << result + 1 << endl;


}



Measured memory_bytes: 1724
program test
implicit none
integer :: i,n,a(300),aa(3)=0,nokori,i1,i2,i3
real(8) :: p(0:300,0:300,0:300)=0,e(0:300,0:300,0:300)=0,psum,esum

read(*,*) n
read(*,*) (a(i),i=1,n)

do i=1,n
	aa(a(i)) = aa(a(i)) + 1
enddo

nokori = aa(1)+aa(2)*2+aa(3)*3

!分岐の確率
p(aa(1),aa(2),aa(3)) = 1

esum = 0

do 
	
	do i3 = 0,int(nokori/3)
		do i2 = 0,int((nokori-i3*3)/2)
			i1 = nokori-i2*2-i3*3
			
			if(i1>=1) then
				p(i1-1,i2,i3) = p(i1-1,i2,i3) +  p(i1,i2,i3) * (i1)/dble(i1+i2+i3)
				e(i1-1,i2,i3) = e(i1-1,i2,i3) + n/dble(i1) * p(i1,i2,i3) * (i1)/dble(i1+i2+i3)
				esum = esum + n/dble(i1+i2+i3) * p(i1,i2,i3) * (i1)/dble(i1+i2+i3)
			endif
			
			if(i2>=1) then
				p(i1+1,i2-1,i3) = p(i1+1,i2-1,i3) +  p(i1,i2,i3) * (i2)/dble(i1+i2+i3)
				e(i1+1,i2-1,i3) = e(i1+1,i2-1,i3) + n/dble(i2) * p(i1,i2,i3) * (i2)/dble(i1+i2+i3)
				esum = esum + n/dble(i1+i2+i3) * p(i1,i2,i3) * (i2)/dble(i1+i2+i3)
			endif
			
			if(i3>=1) then
				p(i1,i2+1,i3-1) = p(i1,i2+1,i3-1) +  p(i1,i2,i3) * (i3)/dble(i1+i2+i3)
				e(i1,i2+1,i3-1) = e(i1,i2+1,i3-1) +  n/dble(i3) * p(i1,i2,i3) * (i3)/dble(i1+i2+i3)
				esum = esum +  n/dble(i1+i2+i3) * p(i1,i2,i3) * (i3)/dble(i1+i2+i3)
			endif
			
		enddo
	enddo
	
	nokori = nokori - 1
		
	if(nokori == 0)then
		goto 100
	endif
	
enddo

100 continue

write(*,*) esum

end program

Measured memory_bytes: 408448
readlines.each do |line|

    break if line[0..2] == "0 0"

    line = line.split.map(&:to_i)

    for height in 1..line[0]

      height.even? ? even = 1..line[1] : even = 0...line[1]

      for width in even
        width.even? ? print("#") : print(".")
      end

      puts ""

    end
    
    puts ""

  end


Measured memory_bytes: 6868
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int main() {
  int n,a[100005]={},m=1e9,lg[100005],rg[100005],ans=0;
  cin >> n;
  for(int i=1; i<=n; i++) {
    cin >> a[i];
  }
  for(int i=1; i<=n; i++) {
    lg[i]=__gcd(lg[i-1],a[i]);
  }
  for(int i=n; i>=1; i--) {
    rg[i]=__gcd(rg[i+1],a[i]);
  }
  for(int i=0; i<=n; i++) {
    ans=max(ans,__gcd(lg[i-1],rg[i+1]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let h: u32 = it.next().unwrap().parse().unwrap();
    let a: u32 = it.next().unwrap().parse().unwrap();

    println!("{}", (h as f32 / a as f32).ceil());
}

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

//  a^b % m
long long powmod(long long a, long long b, long long m)
{
    long long r = 1;
    for (; b>0; b>>=1, a=a*a%m)
        if (b&1)
            r = r*a%m;
    return r;
}

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

    vector<int> mu(K+1);
    for (int i=1; i<=K; i++)
    {
        int t = i;
        int c = 0;
        int f = 2;
        bool z = false;
        for (; f*f<=t; f++)
            while (t%f==0)
            {
                t /= f;
                c++;
                if (t%f==0)
                    z = true;
            }
        if (t>1)
            c++;
        if (z)
            mu[i] = 0;
        else if (c%2==0)
            mu[i] = 1;
        else
            mu[i] = -1;
    }

    long long ans = 0;
    long long M = 1000000007;

    vector<long long> P(K+1);
    for (int i=0; i<=K; i++)
        P[i] = powmod(i, N, M);

    for (int i=1; i<=K; i++)
    {
        for (int j=1; i*j<=K; j++)
        {
            ans += mu[j]*i*P[K/(i*j)];
            ans %= M;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3880
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)
#define int long long
int32_t main(){ fast;
	
	int n; cin>>n;
	vector<int> a(n);
	map<int, int> map;
	rep(i, n){
		cin>>a[i];
		map[a[i]]++;
	}
	int tot = 0;
	for(auto x: map){
		tot += x.second * (x.second - 1) / 2;
	}
	rep(k, n){
		cout<<tot - (map[a[k]] - 1)<<endl;
	}
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;

int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------
ll arr[3005][3005];
ll dp[3005][3005][5];
void solve()
{
    ll r,c,k;
    cin>>r>>c>>k;
    for(ll i=0;i<k;i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        arr[a][b]=c;
    }
    for(ll i=1;i<=r;i++)
    {
        for(ll j=1;j<=c;j++)
        {
            for(ll k=0;k<=3;k++)
            {
                dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
                dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][k]+arr[i][j]);
                dp[i][j][2]=max(dp[i][j][2],dp[i-1][j][k]+arr[i][j]);
                dp[i][j][3]=max(dp[i][j][3],dp[i-1][j][k]+arr[i][j]);
                if(k>0)
                {
                    dp[i][j][k]=max(dp[i][j][k],max(dp[i][j-1][k-1]+arr[i][j],dp[i][j-1][k]));
                }
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<4;i++)
    {
        ans=max(ans,dp[r][c][i]);
    }
    cout<<ans<<endl;
}

int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);
}


Measured memory_bytes: 426128
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	public static void main(String[] args) {
		int a=scan.nextInt();
		String str=scan.next();
		System.out.println(a>=3200?str:"red");
	}
}


Measured memory_bytes: 21844
def solve():
    INF = float('inf')

    def max2(x, y): return x if x >= y else y

    N = int(input())
    As = [(A, i) for i, A in enumerate(map(int, input().split()))]

    As.sort(reverse=True)

    dp = [[-INF]*(N+1) for _ in range(N+1)]
    dp[0][0] = 0
    for no, (A, pos) in enumerate(As):
        for i in range(no+1):
            j = no-i
            dp[i+1][j] = max2(dp[i+1][j], dp[i][j] + A*abs(pos-i))
            dp[i][j+1] = max2(dp[i][j+1], dp[i][j] + A*abs(pos-(N-1-j)))

    ans = 0
    for i in range(N+1):
        j = N-i
        ans = max2(ans, dp[i][j])

    print(ans)


solve()


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


int main(){

int i,d,n1,n2,sum,c;

int a,b;

while(cin >> n1 >> n2){
    if(n1 == -1 or n2 == -1)  break;
   while(n1 < 0 or n1 > 1000000 or n2 < 0 or n2 > 1000000){
      cin >> n1 >> n2;
   }
   if(n1 >= 0 and n1 <= 1000000 and n2 >= 0 and n2 <= 1000000){
       a=n1;
       b=n2;
       c=0;
       sum=a+b;
       while((sum/10)!=0){
           c++;
           sum=sum/10;
        }
       cout << c+1 << "\n";
   }
}
return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define INPUTL(i,n) for(ll i=0 ; i<n ; i++)
const int MOD = 1000000007 ; // 1000000009 , 1000000023 ,998244353
const ll INF = (1e18);
const ll infinity = (1e9);
const ld PI = 4*atan((ld)1);


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

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

int main() {
    #ifdef AVI  
        freopen("input.txt" , "r" , stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    
    ll n , k;
    cin >> n >> k;
    vector<ll>ar(n) ;
    unordered_map<ll,bool>dp;
    dp[0] = 0;
    for(auto &x:ar)cin >> x;
    for(ll i=1 ; i<=k ; i++){
      for(auto &x:ar){
        if(!dp[i-x] && x<=i)dp[i] = 1;
      }
    }
    //for(ll i=0 ; i<=k ; i++)cout << dp[i] << ' ';
    cout << (dp[k]?"First" : "Second");
}

Measured memory_bytes: 8520
// Aizu Vol0 0049: Blood Groups
// 2017.7.29

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);

#define MAX 50

int blood[MAX + 5];
int cnt[5];

int main()
{
	char buf[100], *p;
	int k, t;

	for (k = 0; k <= MAX; k++) blood[k] = 0;
	for (k = 1; k < 5; k++) cnt[k] = 0;
	while (gets(buf) != NULL) {
		p = buf;

		while (isspace(*p)) p++;
		k = *p++ - '0';
		if (isdigit(*p)) k = k * 10 + (*p++ - '0');

		while (isspace(*p)) p++;  // ','
		p++;

		while (isspace(*p)) p++;
		if (*p == 'A' && *(p + 1) == 'B') t = 3;
		else if (*p == 'B') t = 2;
		else if (*p == 'O') t = 4;
		else t = 1;

		if (blood[k] == 0) {
			blood[k] = t;
			cnt[t]++;
		} else if (blood[k] != t) while (1);
	}
	for (k = 1; k < 5; k++) printf("%d\n", cnt[k]);
	return 0;
}

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

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = s.nextInt();
		int b = s.nextInt();
		int c = s.nextInt();
		String ans = "No";

		if(a<=c&&c<=b) {
			ans = "Yes";
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
import math

def calc_max_distance(guess_x,guess_y,data):
    max_distance = 0
    for x,y in data:
        distance = math.sqrt((guess_x-x)**2 + (guess_y-y)**2)
        max_distance = max(max_distance,distance)
    
    return max_distance



EPS = pow(10,-9)

def iterate(x,data):
    left = 0.0
    right = 1000.0
    while (right-left) > EPS:
        left_mid = left + (right-left)/3
        right_mid = right - (right-left)/3
        if calc_max_distance(x,left_mid,data) > calc_max_distance(x,right_mid,data):
            left = left_mid
        else:
            right = right_mid
            
    return calc_max_distance(x,left,data)
    


def outer_iterate(data):
    left = 0.0
    right = 1000.0
    while (right-left) > EPS:
        left_mid = left + (right-left)/3
        right_mid = right - (right-left)/3
        if iterate(left_mid,data) > iterate(right_mid,data):
            left = left_mid
        else:
            right = right_mid
            
    return iterate(left,data)


    
    




n = int(input())

data = []

for _ in range(n):
    a,b = map(int,input().split())
    data.append([a,b])


#print ( n,data )
        
print (outer_iterate(data))



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,a[100005],m1,m2;

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

void fuck(){
	puts("No");exit(0);
}

void shit(){
	puts("Yes");exit(0);
}

int main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read();
	m1=m2=a[1];
	for(int i=2;i<=n;i++) m1=max(m1,a[i]),m2=min(m2,a[i]);
	if(m1>m2+1) fuck();
	if(m1==m2){
		if(2*m1<=n||m1==n-1) shit();
		else fuck();
	}
	if(m1!=m2){
		int ge=0;
		for(int i=1;i<=n;i++) if(a[i]==m2) ge++;
		if(2*(m1-ge)<=n-ge&&m1-ge>0) shit();
		else fuck();
	}
	
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <list>
#include <string>
using namespace std;

int main() {
	int n,key;
	char buf[20];
	string command;
	list<int> lst;
	scanf("%d",&n);
	for(int i=0; i<n; ++i) {
		scanf("%s",buf);
		command = buf;
		if(command=="insert") {
			scanf("%d",&key);
			lst.push_front(key);
		} else if(command=="delete") {
			scanf("%d",&key);
			for(auto itr=lst.begin(); itr!=lst.end(); ++itr) {
				if((*itr)==key) {
					lst.erase(itr);
					break;
				}
			}
		} else if(command=="deleteFirst") {
			lst.pop_front();
		} else if(command=="deleteLast") {
			lst.pop_back();
		}
	}

	for(auto itr=lst.begin(); itr!=--(lst.end()); ++itr) {
		printf("%d ",*itr);
	}
	printf("%d\n",lst.back());
	return 0;
}

Measured memory_bytes: 34500
package main

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

var (
	scanner = bufio.NewScanner(os.Stdin)
	w       = bufio.NewWriter(os.Stdout)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}
func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	a := make(map[string]interface{}, n)
	for i := 0; i < n; i++ {
		key := readString()
		a[key] = 1
	}

	fmt.Println(len(a))

}

Measured memory_bytes: 15616
a,b,x = list(map(int,input().split()))
import math
if x >= a*a*b/2:
  print(math.atan(2*(a*a*b-x)/(a*a*a)) * 180/math.pi)
else:
  print(math.atan(a*b*b/(2*x)) * 180/math.pi)
  

Measured memory_bytes: 2940
import java.util.*;

public class Main{
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      
      int[][] array = new int[N][2];
      for (int i = 0; i < N; ++i) {
          // i番目のx座標
          array[i][0] = sc.nextInt();
          // i番目のy座標
          array[i][1] = sc.nextInt();
      }
      
      double total = 0.0d;
      
      // 全道の長さの和を求める
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          if (i < j) continue;
          total += Math.sqrt(nijo(array[i][0] - array[j][0]) + nijo(array[i][1] - array[j][1]));
        }
      }
      
      System.out.println(2.0d * total / N);
      
    }
  
  private static int nijo(int x) { return x * x;}
}

Measured memory_bytes: 21588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>
#include <math.h>

using namespace std;
const long long INF = (long long) (1e18)+1;

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

  int l = n % 10;
  if (l == 2 || l == 4 || l ==5 || l == 7 || l == 9) {
    cout << "hon" << endl;
  } else if (l == 0 || l == 1 || l == 6 || l == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;

public class Main {

	private static void solve(){
		//Implement solution here.
		int n = ni();
		if(n/100 == 9) {
			n -= 800;
		}else {
			n += 800;
		}
		
		if(n%100/10 == 9) {
			n -= 80;
		}else {
			n += 80;
		}
		
		if(n%10 == 9) {
			n -= 8;
		} else {
			n += 8;
		}
		
		System.out.println(n);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    string s;
    cin >> s;
    ll cnt = 0;
    ll ans = 0;
    rep(i, 3){
        if(s[i] == 'R'){
            cnt++;
        } else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}

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

int main()
{
  string S; cin >> S;
  string SS[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  int T[7] = {7, 6, 5, 4, 3, 2, 1};
  
  for (int i = 0; i < 7; i++)
  {
    if (S == SS[i])
      cout << T[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

void solve()
{
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    int n, m;
    cin >> n >> m;
    int G[10][10];
    memset(G, 0, sizeof(G));
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a][b] = 1;
        G[b][a] = 1;
    }

    vector<int> path;
    rep(i, n) path.push_back(i);

    int ans = 0;
    do
    {
        if (path[0] != 0)
            continue;
        bool isExistPath = true;
        rep(i, n - 1)
        {
            if (!G[path[i]][path[i + 1]])
                isExistPath = false;
        }

        if (isExistPath)
            ans++;

    } while (next_permutation(ALL(path)));

    cout << ans << endl;
}

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


Measured memory_bytes: 256
N,K = map(int,input().split())
# iこの入れる場所の選び方(N-K+1)Ci,Kこの間にi-1この仕切を入れると考える
# よって(N-K+1)Ci * (K-1)C(i-1)が求める答えになる
ans = 0
L = 10**9 + 7
# pythonは一行ずつ前からしか読めないからそこんとこ注意
import math
# ライブラリは実行される前に書いておくこと
def comb(n,i):
    ans = 1
    for j in range(i):
        ans *= (n-j)
        ans %= L
    div = math.factorial(i)
    div %= L
    div = pow(div,L-2,L)
    ans *= div
    ans %= L
    return ans

for i in range(1,K+1):
    ans = comb(N-K+1,i) * comb(K-1,i-1)
    ans %= L
    print(ans)







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

using namespace std;

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

const int INF = 2e18;
const int MB = 31;
const int MOD = 1e9 + 7;

void solve() {
    int n, a, b, c;
    cin >> n >> a >> b >> c;

    vector<string> in(n);
    for (int i = 0; i < n; i++) cin >> in[i];
    vector<char> ans(n);

    for (int i = 0; i < n; i++) {
        if (in[i] == "AB") {
            if (!a && !b) {
                cout << "No\n";
                return;
            }
            if (a == b) {   
                if (i < n - 1 && in[i + 1] == "AC") {
                    a++;
                    b--;
                    ans[i] = 'A';
                }
                else {
                    a--;
                    b++;
                    ans[i] = 'B';
                }
            }
            else if (a < b) {
                a++;
                b--;
                ans[i] = 'A';
            }
            else {
                a--;
                b++;
                ans[i] = 'B';
            }
        }
        else if (in[i] == "AC") {
            if (!a && !c) {
                cout << "No\n";
                return;
            }
            if (a == c) {
                if (i < n - 1 && in[i + 1] == "AB") {
                    a++;
                    c--;
                    ans[i] = 'A';
                }
                else {
                    a--;
                    c++;
                    ans[i] = 'C';
                }
            }
            else if (a < c) {
                a++;
                c--;
                ans[i] = 'A';
            }
            else {
                a--;
                c++;
                ans[i] = 'C';
            }
        }
        else if (in[i] == "BC") {
            if (!b && !c) {
                cout << "No\n";
                return;
            }
            if (b == c) {
                if (i < n - 1 && in[i + 1] == "AB") {
                    b++;
                    c--;
                    ans[i] = 'B';
                }
                else {
                    b--;
                    c++;
                    ans[i] = 'C';
                }
            }
            else if (b < c) {
                b++;
                c--;
                ans[i] = 'B';
            }
            else {
                b--;
                c++;
                ans[i] = 'C';
            }
        }
    }
    cout << "Yes\n";
    for (char c : ans) cout << c << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //srand(time(0));
    cout.precision(12);
    cout << fixed;
    // int t;
    //cin >> t;
    int t = 1;
    while (t--) solve();
}


Measured memory_bytes: 6656
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		
		int circle=input.nextInt();
		for(int i=0;i<circle;i++){
			int a=input.nextInt();
			int b=input.nextInt();
			int c=input.nextInt();
			
			if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a)
				System.out.println("YES");
			else
				System.out.println("NO");
		}
	}
}

Measured memory_bytes: 34828
import sys

n, T, *t = map(int, sys.stdin.read().split())

def main():
    start = 0
    will_stop = T
    running_time = 0
    for i in range(1, n):
        cur = t[i]
        if cur < will_stop:
            running_time += cur - start
        else:
            running_time += T
        start = cur
        will_stop = cur + T
    running_time += T

    return running_time

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main(){
int N;
   cin>>N;
  vector<int>A(N);
  vector<int>d(N);
  
  int ans=0;
  for(int i=0; i<N; i++){
   cin>>A[i];
    while(A[i]%2==0){
     A[i]/=2;
      d[i]++;
    }
  }
  ans=*min_element(d.begin(), d.end());
  cout<<ans;
}

Measured memory_bytes: 256