akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[n];
    int count = 1;
    for (int i=0;i<n;i++){
      a[i] = scan.nextInt();
      b[i] = scan.nextInt();
      c[i] = i;
      count *= (i+1);
    }

    double sum = 0;
    ArrayList<String> g = new ArrayList<String>();
    sum = permutation(c,n,g,sum,a,b);

    double p = (double) sum/count;
    System.out.println(p);


  }

  static double permutation(int[] a, int n, ArrayList<String> g, double sum,int[] c, int[] b){
    if (g.size() == n){
      for (int k=0;k<g.size()-1;k++){
        int a1 = Integer.parseInt(g.get(k));
        int a2 = Integer.parseInt(g.get(k+1));
        sum += calculate(c[a1],b[a1],c[a2],b[a2]);
      }
      return sum;
    }

    for (int i = 0; i<n; i++){
      if (g.contains(a[i]+"") == false){
        g.add(a[i]+"");
        sum = permutation(a,n,g,sum,c,b);
        g.remove(a[i]+"");
      }
    }
    return sum;
  }

  static double calculate(int a, int b, int c, int d){
    int len = (int) (a-c)*(a-c) + (b-d)*(b-d);
    double gg = (double) Math.sqrt(len);
    return gg;
  }

}


Measured memory_bytes: 63112
//Author : Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define REPN(i,a,b) for(ll i = a; i <= b; ++i)
#define REPV(i,a,b) for(ll i = a; i >= b; --i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define with_tests int t; cin>>t; while(t--){ solve(); }
#define without_tests solve();
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 100000000
#define ff first
#define ss second
const int M=1e9+7;


void solve()
{
	string s;
	cin>>s;
	vector<int> dp(26,0);
	REP(i,0,s.length())
	{
		dp[s[i]-'0'-49]++;
	}
	REP(i,0,26)
	{
		if(dp[i] == 0)
		{
			cout<<char('a'+i)<<"\n";
			return;
		}
	}
	cout<<"None";
}

int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  //with_tests;
  without_tests;
  return 0;
}

Measured memory_bytes: 3664
using System;
using System.Linq;

namespace AtCoder
{
    class Program2
    {

        static void Main(string[] args)
        {
            //lee una linea con numeros
            //var cantidades = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var K = Int64.Parse(Console.ReadLine());

            Int64 suma = 0;

            for (int i = 1; i<= K; i++)
            {
                for (int j = 1; j <= K; j++)
                {
                    for (int h = 1; h <= K; h++)
                    {
                        int[] array = { i,j,h};
                            suma += GCD(array);
                    }
                }
            }

            Console.WriteLine(suma.ToString());
        }

        static int GCD(int[] numbers)
        {
            return numbers.Aggregate(GCD);
        }

        static int GCD(int a, int b)
        {
            return (a == 0 || b == 0) ? a | b : GCD(Math.Min(a, b), Math.Max(a, b) % Math.Min(a, b));
        }
    }
}

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

using namespace std;

int main(){
    while(true){
        int n, r;
        cin >> n >> r;
        if(n==0 && r==0) return 0;
        vector<int> deck(n);

        for(int i=0;i<deck.size();i++){
            deck[i] = deck.size() - i;
        }

        //      for(int k=0;k<n;k++) cerr << deck[k];
//        cerr << endl;

        for(int i=0;i<r;i++){
            int p,c;
            cin >> p >> c;
            vector<int> cdeck = deck;

            for(int j=0;j<c;j++){
                deck[j] = cdeck[p-1+j];
            }

            for(int j=0;j<p-1;j++){
                deck[c+j] = cdeck[j];
            }

            //for(int k=0;k<n;k++) cerr << deck[k];
//            cerr << endl;
        }
        cout << deck[0] << endl;
    }
}

Measured memory_bytes: 1216
class Dice
  def initialize(dice = [])
    @dice = dice
  end

  def getTop
    return @dice[0]
  end

  def getRight(f)
    case f  
    when @dice[0]
      raise
    when @dice[1]
      return @dice[2]
    when @dice[2]
      return @dice[4]
    when @dice[3]
      return @dice[1]
    when @dice[4]
      return @dice[3]
    when @dice[5]
      raise
    end
  end

  def setTop(t)
    case t
    when @dice[0]
      return
    when @dice[1]
      self.role("N")
      return
    when @dice[2]
      self.role("W")
    when @dice[3]
      self.role("E")
    when @dice[4]
      self.role("S")
    when @dice[5]
      self.role("N")
      self.role("N")
    end
  end

  def role(c)
    case c
    when "N"
      @dice = 
        [
          @dice[1],
          @dice[5],
          @dice[2],
          @dice[3],
          @dice[0],
          @dice[4]
        ]

    when "S"
      @dice = 
        [
          @dice[4],
          @dice[0],
          @dice[2],
          @dice[3],
          @dice[5],
          @dice[1]
        ]
    
    when "E"
      @dice = 
        [
          @dice[3],
          @dice[1],
          @dice[0],
          @dice[5],
          @dice[4],
          @dice[2]
        ]
    
    when "W"
      @dice = 
        [
          @dice[2],
          @dice[1],
          @dice[5],
          @dice[0],
          @dice[4],
          @dice[3]
        ]
    end
  end
end

dice_arr = gets.split.map(&:to_i)
@dice = Dice.new(dice_arr)
q = gets.to_i

(3...3+q).each do |i|
  t, f = gets.split.map(&:to_i)
  @dice.setTop(t)
  puts @dice.getRight(f)
end

Measured memory_bytes: 6124
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
const LL N=100005;
LL a[N];
LL n;
int main()
{
	scanf("%lld",&n);
	for (LL u=1;u<=n;u++) scanf("%lld",&a[u]);
	sort(a+1,a+1+n);
	if (n&1)//奇数 
	{
		LL mx1=0,mx2=0;
		LL cnt=n/2;
		for (LL u=1;u<=cnt;u++) mx2=mx2-a[u]*2;
		for (LL u=cnt+3;u<=n;u++) mx2=mx2+a[u]*2;
		mx2=mx2+a[cnt+1]+a[cnt+2];
		
		cnt++;
		for (LL u=cnt+1;u<=n;u++) mx1=mx1+a[u]*2;
		for (LL u=1;u<=cnt-2;u++) mx1=mx1-a[u]*2;
		mx1=mx1-a[cnt]-a[cnt-1];
		printf("%lld\n",max(mx1,mx2));
	}
	else//偶数 
	{
		LL ans=0;
		LL cnt=n/2;
		for (LL u=cnt+2;u<=n;u++) ans=ans+a[u]*2;
		ans=ans+a[cnt+1];
		for (LL u=1;u<cnt;u++) ans=ans-a[u]*2;
		ans=ans-a[cnt];
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main() {
	int n,x;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) cout << " " << i;
        else{
            x=i;
            while(x){
                if(x%10==3){
                    cout<<" "<<i;
                    break;
                }
                x/=10;
            }
        }
	}
	cout<<endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	rep(i, n) {
		int ai;
		cin >> ai;
		a[i] = make_pair(ai, i);
	}
	sort(a.begin(), a.end());
	bool b = false;
	int ans;
	if (a[0].first == 1) {
		b = true;
		ans = 1;
		int c = a[0].second;
		for (int i = 1; i < n; i++) {
			if (a[i].first == ans + 1 && a[i].second > c) {
				ans++;
				c = a[i].second;
			}
		}
	}
	if (b) cout << n - ans << endl;
	else cout << -1 << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define MAXN 100005
using namespace std;
int n,k;
int a[MAXN];
int main()
{
    scanf("%d %d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int cnt=0;
    while(n>0)
    {
        cnt++;
        if(n-k==0)
        {
            break;
        }
        n=n-k+1;
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 640
#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int A,B;
    cin >> A >> B;
    int out = -1;
    for(int i = 10; i <= 1013; i++){
        int a,b;
        a = i * 0.08;
        b = i * 0.1;
        if(a == A && b == B){
            out = i;
            break;
        }
    }
    cout << out << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int k, n;

	while(scanf("%d%d", &k, &n)==2)
	{
		vi a(n+1);

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

		int d=0;
		for(int i=0;i<n;i++) d=max(d, a[i+1]-a[i]);

		printf("%d\n", k-d);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

int hoko[4]={0,1,2,3};

using namespace std;

int main(void)
{
	int n;
	int nn,d;

	int i1,i2;

	while(1){
		cin >> n;
		if(n==0) break;

		vector<int> vx;
		vector<int> vy;
		vx.push_back(0);
		vy.push_back(0);

		for(i1=1;i1<n;i1++){
			cin >> nn >> d;

			if(d==0) {
				vx.push_back(vx[nn]-1);
				vy.push_back(vy[nn]);
			}
			else if(d==1) {
				vx.push_back(vx[nn]);
				vy.push_back(vy[nn]-1);
			}
			else if(d==2) {
				vx.push_back(vx[nn]+1);
				vy.push_back(vy[nn]);
			}
			else if(d==3) {
				vx.push_back(vx[nn]);
				vy.push_back(vy[nn]+1);
			}

			//cout << vx[i1] << " " << vy[i1] << endl;
		}

		sort(vx.begin(),vx.end());
		sort(vy.begin(),vy.end());

		cout << vx[n-1]-vx[0]+1 << " " << vy[n-1]-vy[0]+1 << endl;


	}

	return 0;
}

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

const int maxn = 1e6;

int t[maxn];

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

	int n, c, k;
	cin >> n >> c >> k;

	for(int i = 0; i < n; i++)
		cin >> t[i];

	sort(t, t+n);

	int l = 0, ans = 0;
	for(int i = 0; i < n; i++)
		if(t[i]-t[l] > k || i-l+1 > c)
			ans++, l = i;

	if(l < n) ans++;

	cout << ans;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int N,Q;
vector<vector<int>> edge;
vector<bool> visited;

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

  edge.resize(N+1);
  visited.resize(N+1,false);

  REP(i,N-1){
    int a,b;
    cin >> a >> b;
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
  }
  vector<int> x(N+1,0);
  vector<int> c(N+1,0);

  REP(i,Q){
    int pp,xx;
    cin >> pp >> xx;
    x[pp] += xx;
  }

  stack<int> st;

  st.push(1);
  c[1] = x[1];
  visited[1] = true;

  while(!st.empty()){
    int v = st.top(); st.pop();
    REP(i,edge[v].size()){
      if(visited[edge[v][i]])continue;

      c[edge[v][i]] = c[v] + x[edge[v][i]];

      st.push(edge[v][i]);
      visited[edge[v][i]]=true;
    }
  }

  FOR(i,1,N+1){
    cout << c[i] << (i == N ? "\n" : " ");
  }
}



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

typedef long long ll;
typedef pair<ll,ll> pll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
ll t;


int main()
{
    int a,b,c,d,e,f,g,i,j;
    cin>>a;
    b=a/500;
    f=0;
    f+=(b*1000);
    a=a%500;
    b=a/5;
    f+=(b*5);
    cout<<f<<endl;
}



Measured memory_bytes: 256
def calc(n):
    ret = 0
    for x in range(1, 10 ** 2 + 1):
        for y in range(x, 10 ** 2 + 1):
            rest = n - x * x - y * y - x * y  # z*(x+y+z)
            if rest < 0: break
            for z in range(y, 10 ** 2):
                t = z * (x + y + z)
                if t > rest: break
                if t == rest:
                    if x == y == z:
                        ret += 1
                    elif x == y or y == z or z == x:
                        ret += 3
                    else:
                        ret += 6
                    break
    return ret


def main():
    N = int(input())

    ans = []
    for n in range(1, N + 1):
        ans.append(calc(n))

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 70616
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int all = Integer.parseInt(br.readLine());
		for (int i = 0; i < all; i++) {
			String var = br.readLine();
			char[] s = var.toCharArray();
			Arrays.sort(s);
			char[] rev = new char[s.length];
			for (int j = 0; j < s.length; j++) {
				rev[j] = s[s.length - j - 1];
			}

			int min = Integer.parseInt(String.valueOf(s));
			int max = Integer.parseInt(String.valueOf(rev));
			System.out.println(max - min);

		}
	}
}

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

#define f first
#define s second
#define pb push_back

#define ll long long

#define mp make_pair

#define int ll

using namespace std;
                        

const int inf = 1e9 + 7;

const ll ll_inf = 1e18 + 7;
const int K = 18;
const int N = 1e6 + 100;
                        

/*ll binpow (ll a, ll n)
{
    ll res = 1;
    while (n) {
        if (n & 1)
        {
            res *= a;
            res %= inf;
        }
        a *= a;
        n >>= 1;
        a %= inf;
    }                      	
    return res;
}   */

void boost()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int n,k;  

main()
{
	cin >> n >> k;
	int ans = n;
	if (n == 0)
	{
		cout << ans;
		return 0;
	}
	ans = min(ans,min(n % k,k - n % k));
	cout<< ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
vector<i64>d;
void generate_divisors(i64 n){
    d.clear();
    for(i64 i=1;i*i<=n;i++){
        if(n%i==0){
            d.push_back(i);
            if(n/i != i) d.push_back(n/i);
        }
    }
}

int digits(i64 n){
    int cnt = 0;
    while(n>0){
        cnt++;
        n/=10LL;
    }
    return cnt;
}
int solve(i64 n){
    generate_divisors(n);
    int nod = d.size();
    int minVal = INT_MAX;
    for(int i=0;i<nod;i++){
        for(int j=i;j<nod;j++){
            if(d[i]*d[j]==n) minVal = min(minVal, max(digits(d[i]) , digits(d[j])));
        }
    }
    return minVal;
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    */
    // #ifndef ONLINE_JUDGE
    //     fread();
    // #endif
    
    i64 n;   
    while(scanf("%lld",&n)==1){
        //init(n);
        printf("%d\n", solve(n));
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int n,sum = 0,ans,sumkeep;
  
  while(cin >> n){
    if(n == 0)break;
    
    ans = 0;
    sumkeep = 0;

    int a[n];
    
    for(int i = 0;i < n;i++){
      cin >> a[i];
    }
    
    for(int i = 0;i < n;i++){
      sumkeep = 0;
      for(int j = i;j < n;j++){
	sumkeep += a[j];
	if(i == 0 && j == 0){
	  ans = sumkeep;
	}
	else if(ans < sumkeep){
	  ans = sumkeep;
	}
      }
    }
    cout << ans << endl;
  }
}
	

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s;
  cin >> n >> s;

  REP(i, (int)s.size()) {
    char c = s[i];
    c += (char)n;
    if(c > 'Z') c -= ('Z' - 'A' + 1);
    s[i] = c;
  }
  cout << s << '\n';
  return 0;
}


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

typedef long long ll;
const int maxn=1005;
//ll a[maxn], b[maxn], c[maxn];

bool cmp(const ll &x, const ll &y){
    return x>y;
}

ll calc(int n, int *b){
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(ans%10==0) {
            ans+=b[i];
        }
        else{
            ans+=(b[i]/10+1)*10;
        }
    }
    return ans;
}

int main()
{
    string s= "01234";
    int a[5], b[5];
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    ll ans = 0x3f3f3f3f3f3f;
    do{
        for(int i=0;i<5;i++){
            b[i] = a[s[i] - '0'];
        }
        ans = min(ans, calc(5, b));
    }while(next_permutation(s.begin(), s.end()));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int N,K;cin>>N>>K;
    vector<int> P(N),C(N);
    for(int i=0;i<N;i++) cin >> P[i],--P[i];
    for(int i=0;i<N;i++) cin >> C[i];
    ll ans = -1000000000000000000;
    for(int i=0;i<N;i++){
        int v = i;
        int cycle_cnt = 0;
        ll cycle_score = 0;
        while(true){
            cycle_cnt++;
            cycle_score += C[v];
            v = P[v];
            if(v==i) break;
        }
        int cnt = 0;
        ll score = 0;
        while(true){
            cnt++;
            score += C[v];
            v = P[v];
            if(cnt > K) break;
            int num = (K - cnt) / cycle_cnt;
            ans = max(ans,score + max(0ll,cycle_score) * num);
            if(v==i) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

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

    long M = 1_000_000_007;
    int N = scanner.nextInt();
    int K = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    long[][] dp = new long[N][K + 1];
    for (int i = 0; i <= a[0]; i++) dp[0][i] = 1;
    for (int i = 1; i < N; i++) {
      long sum = 0;
      for (int j = 0; j <= a[i]; j++) {
        sum += dp[i - 1][j];
        if (sum > M) sum -= M;
        dp[i][j] = sum;
      }
      for (int j = a[i] + 1; j <= K; j++) {
        sum += dp[i - 1][j];
        if (sum > M) sum -= M;
        sum -= dp[i - 1][j - a[i] - 1];
        if (sum < 0) sum += M;
        dp[i][j] = sum;
      }
    }
    System.out.println(dp[N - 1][K]);
  }
}


Measured memory_bytes: 126036
// https://atcoder.jp/contests/abc064/tasks/abc064_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    REP(i, n) cin >> v[i];
    sort(ALL(v));
    cout << v.back() - v.front() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    map<int, vector<int>> mp;
    int cursum = 0;
    mp[cursum] = vector<int>{0};
    vector<int> sum(n + 1);

    for(int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        cursum += a - 1;
        cursum %= k;
        if(mp.find(cursum) == mp.end()) {
            mp[cursum] = vector<int>();
        }
        mp[cursum].push_back(i);
        sum[i] = sum[i - 1] + cursum;
    }

    int ans = 0;
    for(auto curv : mp) {
        for(auto x : curv.second) {
            ans += lower_bound(all(curv.second), x + k) - upper_bound(all(curv.second), x);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long int

signed main() {
    int t = 1;
    //cin >> t;
    while(t--) {
        string s, t;
        cin >> s >> t;
        int cnt = 0;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] != t[i])    cnt++;
        }
        cout << cnt;
    }
}

Measured memory_bytes: 3844
package main

import "fmt"

func main() {
	in := make([]int, 4)
	for i := range in {
		fmt.Scan(&in[i])
	}
	fmt.Println(robo(in))
}

func robo(in []int) int {
	return max(0, min(in[1], in[3])-max(in[0], in[2]))
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 512
S=input();T=input()
for cap in range(ord("a"),ord("z")+1):
  c=chr(cap)
  list_s=[]
  for i in range(len(S)):
    if S[i]==c:
      list_s.append(i)
  
  list_t=[]
  if list_s != []:
    c=T[list_s[0]]  
    for i in range(len(T)):
      if T[i]==c:
        list_t.append(i)
        
  if list_s!=list_t:
    print("No");exit()
    
print("Yes")

Measured memory_bytes: 55996
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main(){
 
    ll n,x,t;
    cin>>n>>x>>t;
    ll res = 0;
    while(n>0){
        n-=x;
        res+=t;
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int count=0;
    int n=0;
    for(int i=1;i<4;i++){
      if(s.charAt(0)==s.charAt(i)){
        count=count+1;
        n=i;
      }
    }
    if(n==1){
      if(s.charAt(2)==s.charAt(3)){
        count=count+1;
      }
    }
    if(n==2){
      if(s.charAt(1)==s.charAt(3)){
        count=count+1;
      }
    }
    if(n==3){
      if(s.charAt(1)==s.charAt(2)){
        count=count+1;
      }
    }
    if(count==2){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

typedef long long LL;
typedef pair < int, int > pa;

const int MAXN = 3005;
const int INF = 0x3f3f3f3f;

struct edge { int to, nxt; } e[MAXN << 1];
int head[MAXN], e_cnt, fa[MAXN], n, a[MAXN];
bool g[MAXN], dp[MAXN];

inline void add(int x, int y) { e[ ++e_cnt ] = { y, head[ x ] }; head[ x ] = e_cnt; }
inline void addedge(int x, int y) { add( x, y ); add( y, x ); }

inline void dfs(int x)
{
	for( int i = head[ x ] ; i ; i = e[ i ].nxt )
		if( e[ i ].to ^ fa[ x ] )
			fa[ e[ i ].to ] = x, dfs( e[ i ].to ), dp[ x ] |= ( !dp[ e[ i ].to ] && a[ x ] > a[ e[ i ].to ] );
}

inline void dfs2(int x)
{
	vector < int > v; int cnt = 0, pre = 0, suf = 0;
	for( int i = head[ x ] ; i ; i = e[ i ].nxt )
		if( e[ i ].to ^ fa[ x ] ) v.pb( e[ i ].to ), cnt++;
	for( int i = 0 ; i < cnt ; i++ ) suf += ( !dp[ v[ i ] ] && a[ x ] > a[ v[ i ] ] );
	for( int i = 0 ; i < cnt ; i++ )
	{
		if( i ) pre += ( !dp[ v[ i - 1 ] ] && a[ x ] > a[ v[ i - 1 ] ] );
		suf -= ( !dp[ v[ i ] ] && a[ x ] > a[ v[ i ] ] );
		//printf( "%d -> %d pre = %d suf = %d\n", x, v[ i ], pre, suf );
		if( ( !g[ x ] && a[ x ] > a[ fa[ x ] ] ) | pre | suf ) g[ v[ i ] ] = 1;
		dfs2( v[ i ] );
	}
}

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	scanf( "%d", &n );
	for( int i = 1 ; i <= n ; i++ ) scanf( "%d", &a[ i ] );
	for( int i = 1, x, y ; i < n ; i++ ) scanf( "%d%d", &x, &y ), addedge( x, y );
	a[ 0 ] = INF; dfs( 1 ); dfs2( 1 );
	//for( int i = 1 ; i <= n ; i++ ) printf( "%d\n", g[ i ] );
	for( int i = 1 ; i <= n ; i++ )
		if( dp[ i ] || ( !g[ i ] && a[ i ] > a[ fa[ i ] ] ) )
				printf( "%d ", i );
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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


int main() {
    ll n, h; cin >> n >> h;
    Vl a(n), b(n);
    ll a_mx = 0;
    rep(i, 0, n) cin >> a[i] >> b[i], chmax(a_mx, a[i]);
    ll sumb = 0;
    ll ans = 0;
    Vl vb;
    rep(i, 0, n){
        if(b[i] > a_mx) vb.push_back(b[i]);
    } 
    sort(ALL(vb), greater<ll>());
    rep(i, 0, sz(vb)){
        h -= vb[i]; ans++;
        if(h <= 0){
            co(ans);
            return 0;
        }
    }
    ans += ((h+a_mx-1)/a_mx);
    co(ans);

    return 0;
}


Measured memory_bytes: 5884
#include <bits/stdc++.h>
#define PII pair<int, int>
#define LL long long
using namespace std;
const LL MOD = (LL) 1e9 + 7;
const int MAXN = 600005;

LL fac[MAXN], inv[MAXN];

LL qpow(LL a, LL pw) {
	LL res = 1;
	while (pw) {
		if (pw & 1) res = res * a % MOD;
		a = a * a % MOD;
		pw >>= 1;
	}
	return res;
}

LL C(int n, int k) {
	return fac[n] * inv[k] % MOD * inv[n - k] % MOD;
}

LL H(int n, int k) {
	return fac[n + k - 1] * inv[k - 1] % MOD * inv[n] % MOD;
}

LL N, M, L, R;

LL solve(LL S) {
	LL n1 = M, n2 = N - M, all = H(S, N + 1), sub = 0;
	for (int i = 1; i * n2 <= S; i++) {
		LL dist = S - i * n2, res1 = 0, res2 = 0;
		for (int j = 0; j <= n1 && j * i <= dist; j++) {
			LL to_add = C(n1, j) * H(dist - j * i, N + 1) % MOD * (j % 2 == 1 ? -1 : 1) % MOD;
			res1 = (res1 + to_add + MOD) % MOD;
		}
		
		if (dist >= n2) {
			dist -= n2;
			for (int j = 0; j <= n1 && j * i <= dist; j++) {
				LL to_add = C(n1, j) * H(dist - j * i, N + 1) % MOD * (j % 2 == 1 ? -1 : 1) % MOD;
				res2 = (res2 + to_add + MOD) % MOD;
			}
		}
		
		LL final = (res1 - res2 + MOD) % MOD * C(N, n1) % MOD;
		sub = (sub + final) % MOD;
	}
	
	return (all - sub + MOD) % MOD;
}

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

	fac[0] = inv[0] = 1;
	for (LL i = 1; i < MAXN; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = qpow(fac[i], MOD - 2);
	}

	cin >> N >> M >> L >> R;
	M = N - M;
	cout << (solve(R) - solve(L - 1) % MOD + MOD) % MOD << '\n';

	return 0;
}


Measured memory_bytes: 9728
import java.util.Scanner;
import java.util.Arrays;

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

        int p[] = new int[3]; 
        p[0] = sc.nextInt();
        p[1] = sc.nextInt();
        p[2] = sc.nextInt();
        sc.close();

        Arrays.sort(p);
        System.out.println(p[2] * 10 + p[1] + p[0]);
    }
}


Measured memory_bytes: 21844
import bisect

def bl(A,x):
    return bisect.bisect_left(A,x)

A,B,Q = map(int,input().split())

INF = 10 ** 18
S,T = [-INF],[-INF]
for i in range(A): S.append(int(input()))
for i in range(B): T.append(int(input()))
S.append(INF)
T.append(INF)

O = []
for i in range(Q):
    x = int(input())    
    xs = bl(S,x)
    xt = bl(T,x)
    res = INF
    for s in [S[xs-1],S[xs]]:
        for t in [T[xt-1],T[xt]]:
            d1,d2 = abs(x-s)+abs(s-t),abs(x-t)+abs(t-s)
            res = min(res,d1,d2)
    O.append(res)
    
for o in O:
    print(o)

Measured memory_bytes: 16920
using System;

namespace _81
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(calculate (n));
           
        }

        static string calculate(int n)
        {
            for (int i=1; i < 10; i++)
            {
                if(n/i < 10 && n%i == 0)
                    return "Yes";
            }

            return "No";
        }
    }
}


Measured memory_bytes: 11092
//by xiqiao
#include<bits/stdc++.h>
#define maxn 200005
#define MOD 1000000007
#define inf 1000000007
using namespace std;
typedef long long ll;
int n;
pair <int,int> p[maxn];
struct node{
	ll s;
	int wh;
}b[maxn];
int id[maxn],f[maxn],l[maxn],r[maxn];
bool cmp(node a,node b){
	if(a.s!=b.s)return a.s<b.s;
	return a.wh<b.wh;
}
int a[maxn];
int lowbit(int x){return x&(-x);}
void add(int x,int y){
	for(int i=x;i<=n+1;i+=lowbit(i)){
		a[i]=(a[i]+y)%MOD;
	}
}
int query(int x){
	int ret=0;
	for(int i=x;i;i-=lowbit(i))ret+=a[i],ret%=MOD;
	return ret;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x,v;scanf("%d%d",&x,&v);
		p[i]=make_pair(x,v);
	}
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		b[i].s=p[i].first+1ll*p[i].second*inf;
		b[i].wh=i;
	}
	sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;i++)id[b[i].wh]=i;
	for(int i=1;i<=n;i++){
		r[i]=id[i];
		if(i!=1)r[i]=max(r[i],r[i-1]);
	}
	for(int i=n;i>=1;i--){
		l[i]=id[i];
		if(i!=n)l[i]=min(l[i],l[i+1]);
	}
	add(1,1);
	for(int i=1;i<=n;i++){
	//	cout<<i<<" "<<l[i]<<" "<<r[i]<<endl;
		int sum=(query(r[i]+1)-query(l[i]-1)+MOD)%MOD;
		f[r[i]]=(f[r[i]]+sum)%MOD;
		add(r[i]+1,sum);
	}
	printf("%d\n",f[n]);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<ll> yaku(n + 1, 1);
  for (int i = 2; i <= n; i++) {
    yaku[i]++;
    for (ll j = i * 2; j <= n; j += i) {
      yaku[j]++;
    }
  }
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += i * yaku[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 81372
N,X = list(map(int, input().split()))
L = list(map(int, input().split()))

D = 0
ans = 0
for i in range(N):
    if D > X:
        break
    D = D+L[i]
    ans = ans + 1
if D <= X:
    ans = ans + 1
print(ans)

Measured memory_bytes: 3064
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>


using namespace std;

int main(){
    ll K,A,B;
    cin >> K >> A >> B;

    if( B-2<=A ){
        cout << 1+K << endl;
    }
    else{
        K = K-(A-1);
        ll change = floor(K/2);
        cout << A+(B-A)*change + K%2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
program abc168c
      implicit none
      double precision::a,b,h,m
      double precision::si,t_time,xa,xb,ya,yb
      double precision,parameter::pi=acos(-1d0)

         read *, a,b,h,m

         t_time=60d0*h+m
         xa=a*cos(pi*t_time/360d0)
         ya=a*sin(pi*t_time/360d0)
         xb=b*cos(pi*m/30d0)
         yb=b*sin(pi*m/30d0)

         print *, sqrt( (xa-xb)**2 + (ya-yb)**2 )

   end program abc168c

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

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

int main()
{
	int n,r; cin>>n>>r;
	if(n>=10) cout<<r<<endl;
	else cout<<r+100*(10-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
lis = [int(i) for i in sys.stdin.readline().split()]
res = [0,abs(lis[1]-lis[0])]
for i in range(2,N):
    tmp = min(abs(lis[i]-lis[i-1]) + res[i-1],abs(lis[i] - lis[i-2]) + res[i-2])
    res.append(tmp)
print(res[-1])

Measured memory_bytes: 13888
quit() = exit(0)
in_1() = parse(Int, readline())
in_a() = [parse(Int,s) for s in split(readline())]
yesno(b) = b ? "Yes" : "No"
function main()
  N, M = in_a()
  sc = [(in_a()...,) for _ in 1:M]
  for n in 0:999
    ns = string(n)
    length(ns) == N || continue
    all(parse(Int, ns[s])==c for (s,c) in sc) || continue
    println(n)
    return
  end
  println(-1)
end

isempty(ARGS) && main()


Measured memory_bytes: 127776
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        fast;

        int t=1;
      //  cin>>t;
        while(t--)
        {
                 ll n;
                cin>>n;
                string s;

                while(n!=0)
                {
                        n--;
                        s+=('a'+n%26);
                        n/=26;
                }
                reverse(s.begin(),s.end());
                cout<<s<<endl;
        }
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main(){
	int n;
	cin >> n;
	string str[256];
	for(int i = 0; i < n; i++){
		cin >> str[i];
	}
	int m;
	cin >> m;
	int cnt=0;
	for(int j = 0; j < m; j++){
		string str2;
		cin >> str2;
		for(int k = 0; k < n; k++){
			if(str[k] == str2){
				cnt++;
				if(cnt % 2 == 1) cout << "Opened by " << str2 << endl;
				else cout << "Closed by " << str2 << endl;
				break;
			}
			if(k == n-1){
				cout << "Unknown " << str2 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

int main()
{
	string s,t;cin>>s>>t;
	int ans=1e9;int len=s.size()-t.size();
	for(int i=0;i<=len;i++){
		int c=0;
		for(int j=0;j<t.size();j++) if(s[i+j]!=t[j]) c++;
		ans=min(ans,c);
	}
	cout<<ans;
	return 0;	
} 

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
int r[100000][3];
int main()
{
    int b;
    cin >> b;
    int n[b][3];
    for(int i = 0; i < b; i++)
    {
    	for(int j = 0; j < 3; j++)
    	{
    		cin >> n[i][j];
		}
	}
	r[0][0] = n[0][0];
	r[0][1] = n[0][1];
	r[0][2] = n[0][2];
    for(int i = 1; i < b; i++)
    {
    	r[i][0] = n[i][0] + max(r[i-1][1], r[i-1][2]);
    	r[i][1] = n[i][1] + max(r[i-1][0], r[i-1][2]);
    	r[i][2] = n[i][2] + max(r[i-1][1], r[i-1][0]);
	}
	cout << max(r[b-1][0], max(r[b-1][1], r[b-1][2])) <<endl;
}



Measured memory_bytes: 2560
#!/usr/bin/env python3
S = input()
ans = 0
for l in range(len(S)):
    for r in range(1, len(S) + 1):
        if l < r and all(S[k] in list('ACGT') for k in range(l, r)):
            ans = max(ans, r - l)
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  long long int array[N], max = 1e18, p = 1, f = 0, z = 0;
  
  for (int i = 0; i < N; i++) {
    scanf("%lld", &array[i]);
    f = (array[i] > max) ? 1 : f;
    p *= array[i];
    (array[i]) ? max /= array[i] : z = 1;
  }

  (z) ? puts("0") : ((f) ? puts("-1") : printf("%lld\n", p));
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  //vector<vector<char>> matrix(H, vector<char>(W));
  //cout << hoge << endl;
  vector<string> kuji(N);
  for (int i=0; i<N; i++){
      cin >> kuji.at(i);
  }

  sort(kuji.begin(), kuji.end()); //ここが一番計算時間かかる

  int count = 1; //種類をカウントする変数
  for (int i = 0; i < N-1; i++){
      if (kuji.at(i) != kuji.at(i+1)){
          count++;
      }
  }
  cout << count << endl;
}

  


Measured memory_bytes: 9544
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll m,k,g,i,ans,l,n;
    	cin>>n;
    	ans=0;
    	ll a[n],b[n+1]={0};
    	rep(i,0,n)
    	{
    		cin>>a[i];
    		b[a[i]]++;
		}
    	repi(i,1,n)
    	if(b[i]>0)
  		ans+=((b[i]*(b[i]-1))/2);
    	rep(j,0,n)
    	{
    		i=a[j];
    		if(b[i]>2)
    		cout<<ans+((((b[i]-1)*(b[i]-2)))/2)-((b[i]*(b[i]-1))/2);
    		else if(b[i]>0)
    		cout<<ans-((b[i]*(b[i]-1))/2);
    		else
    		cout<<ans;
    		cout<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int mxn = 8*1e3+100;
string s;
int ar[mxn];
int X ,Y;
vector< int > vx , vy;
int  dp[4004][mxn];
int solve(int pos , int amount)
{
	if(dp[pos][amount]!=-1) return dp[pos][amount];
    if(pos==(int)vx.size()) return dp[pos][amount] = amount == X;
    if(dp[pos][amount]!=-1) return dp[pos][amount];
    return dp[pos][amount] = (solve(pos+1 , amount + vx[pos] ) || solve(pos+1 , amount - vx[pos]));
}
int solve1(int pos , int amount)
{
	if(dp[pos][amount]!=-1) return dp[pos][amount];
    if(pos==(int)vy.size()) return dp[pos][amount] = amount == Y;
    return dp[pos][amount] = (solve1(pos+1 , amount + vy[pos] ) || solve1(pos+1 , amount - vy[pos]));
}
int main()
{
    cin>>s;
    cin>>X>>Y;
    int d = 0;
    int tot_x = 0;
    vx.clear();
    vy.clear();
    for(int i = 0; i < (int) s.size(); i++)
    {
        if(s[i]=='T')
        {
			if(d==0)
			{
				vx.push_back(tot_x);
				d = 1;
				tot_x = 0;
			}
			else
			{
				vy.push_back(tot_x);
				d = 0;
				tot_x = 0;
			}
        }
        else
        {
            tot_x++;
        }

	}
	if(d==0)
    vx.push_back(tot_x);
    else
    vy.push_back(tot_x);
    memset(dp , -1 , sizeof dp);
    int ret1 = solve( 1 , vx[0]);
    memset(dp , -1 , sizeof dp);
    int ret2 = solve1(0 , 0);
    if(ret1&&ret2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 127232
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int now = scanner.nextInt();
		if(n<10) {
			System.out.println(now+100*(10-n));
		}else {
			System.out.println(now);
		}
	}	
	
}

Measured memory_bytes: 21844
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
gsb_A = LIST()
gsb_B = LIST()
gsb_delta = {}
# for i in range(3):
# 		if min(gsb_A[i], gsb_B[i]) in gsb_delta:
# 			gsb_delta[min(gsb_A[i], gsb_B[i])] = max(max(gsb_A[i], gsb_B[i]), gsb_delta[min(gsb_A[i], gsb_B[i])])
# 		else:
# 			gsb_delta[min(gsb_A[i], gsb_B[i])] = max(gsb_A[i], gsb_B[i])
# print(gsb_delta)
dp = [0] * (N+1)
for i in range(N+1):
	if i-gsb_A[0] >= 0:
		dp[i] = max(dp[i], dp[i-gsb_A[0]]+gsb_B[0])
	if i-gsb_A[1] >= 0:
		dp[i] = max(dp[i], dp[i-gsb_A[1]]+gsb_B[1])
	if i-gsb_A[2] >= 0:
		dp[i] = max(dp[i], dp[i-gsb_A[2]]+gsb_B[2])
	if i >= 1 and i-gsb_A[0] < 0 and i-gsb_A[1] < 0 and i-gsb_A[2] < 0:
		dp[i] = dp[i-1]+1
# print(dp)
# print(dp[N])
M = max(N, dp[N])
dp = [0] * (M+1)
for i in range(M+1):
	if i-gsb_B[0] >= 0:
		dp[i] = max(dp[i], dp[i-gsb_B[0]]+gsb_A[0])
	if i-gsb_B[1] >= 0:
		dp[i] = max(dp[i], dp[i-gsb_B[1]]+gsb_A[1])
	if i-gsb_B[2] >= 0:
		dp[i] = max(dp[i], dp[i-gsb_B[2]]+gsb_A[2])
	if i >= 1 and i-gsb_B[0] < 0 and i-gsb_B[1] < 0 and i-gsb_B[2] < 0:
		dp[i] = dp[i-1]+1
# print(dp)
print(max(M, dp[M]))


Measured memory_bytes: 240620
N=int(input())
count=0
PN=[]

Prime=[2]
for i in range(2,55555):
    for j in range(len(Prime)):
        if i%Prime[j]==0:
            break;
        else:
            if j==len(Prime)-1:
                Prime.append(i)
                if i%5==1:
                    PN.append(i)
                    count=count+1
        if count==N:
            break;
for i in range(N):
    print(PN[i],end=" ")

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    string s; cin >> s;
    int N = s.size();
    cout << s[0] << N-2 << s[N-1] << '\n';
    return 0;
}

Measured memory_bytes: 384
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        y_: usize,
    }
    let mut x = -1i32;
    let mut y = -1i32;
    let mut z = -1i32;
    for a in 0..n + 1 {
        for b in 0..n - a + 1 {
            let c = n - a - b;
            let total = 10000 * a + 5000 * b + 1000 * c;
            if a + b + c == n && total == y_ {
                x = a as i32;
                y = b as i32;
                z = c as i32;
            }
        }
    }
    println!("{} {} {}", x, y, z)
}


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

using namespace std;
using ll = long long;

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

const int mod = 1e9 + 7;

ll modpow(ll k, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * k % mod;
    k = k * k % mod;
    n /= 2;
  }
  return res;
}

ll choose(ll n, ll k) {
  ll x = 1, y = 1;
  rep(i, k) {
    x = x * (n - i) % mod;
    y = y * (i + 1) % mod;
  }
  return x * modpow(y, mod - 2) % mod;
}

int main() {
  int x, y;
  cin >> x >> y;

  if ((x + y) % 3 != 0) {
    puts("0");
    return 0;
  }

  int z = (x + y) / 3;
  int r = x - z;
  int u = y - z;

  if (r < 0 || u < 0) {
    puts("0");
    return 0;
  }

  ll ans = choose(r + u, r);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;
 
int main()
{
    int  a=1, i = 0, j = 0, k = 0;
    char su;//0??????1??????2??????3??????
    cin >> a;
    int b[4][13];
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            b[i][j]=1;
            }
        }
    for(i=0;i<a;i++){
        cin >> su >> k;
        if(su=='S'){
            b[0][k-1]=0;//??????????????0
            }
        if(su=='H'){
            b[1][k-1]=0;//??????????????0
            }
        if(su=='C'){
            b[2][k-1]=0;//??????????????0
            }
        if(su=='D'){
            b[3][k-1]=0;//??????????????0
            }
        }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(b[i][j]==1){
                if(i==0){
                    cout << 'S' << ' ' << j+1 << endl;
                }
                if(i==1){
                    cout << 'H' << ' ' << j+1 << endl;
                }
                if(i==2){
                    cout << 'C' << ' ' << j+1 << endl;
                }
                if(i==3){
                    cout << 'D' << ' ' << j+1 << endl;
                }
            }
        }
    }
 
 
 
 
}

Measured memory_bytes: 1160