akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;

class data{
public:
	string str;
	int id;
	data(){}
	data(string ss,int index){
		str=ss;
		id=index;
	}
};

int n,m;
string str[101];
vector<data> G[100001];
int parent[100001];
string name[100001];

int check(string str){
	int now=0;
	string str2="";
	for(int j=1;j<str.size();j++){
		if(str[j]=='/'){
			if(str2==".");
			else if(str2==".."){
				if(now==0)return -1;
				now=parent[now];
			}else{
				int k;
				for(k=0;k<G[now].size();k++){
					if(G[now][k].str==str2){
						now=G[now][k].id;
						break;
					}
					if(k==G[now].size()-1)return -1;
				}
				if(G[now].size()==0)return -1;
			}
			str2="";
		}else{
			str2+=str[j];
		}
	}
	if(str2==".");
	else if(str2==".."){
		if(now==0)return -1;
		now=parent[now];
	}else if(str2!=""){
		int k;
		for(k=0;k<G[now].size();k++){
			if(G[now][k].str==str2){
				now=G[now][k].id;
				break;
			}
			if(k==G[now].size()-1)return -1;
		}
	}
	for(int k=0;k<G[now].size();k++){
		if(G[now][k].str=="index.html" && G[G[now][k].id].size()==0){
			now=G[now][k].id;
			break;
		}
		if(k==G[now].size()-1 && str[str.size()-1]=='/')return -1;
	}
	if(G[now].size()!=0)return -1;
	return now;
}
int all;
int main(void){
	while(1){
		scanf("%d %d",&n,&m);
		if(n+m==0)break;
		for(int i=0;i<=all;i++){
			G[i].clear();
		}
		memset(parent,0,sizeof(parent));
		for(int i=0;i<n;i++){
			cin >> str[i];
		}
		all=0;
		for(int i=0;i<n;i++){
			string str2="";
			int now=0;
			for(int j=1;j<str[i].size();j++){
				if(str[i][j]=='/'){
					if(str2==".");
					else if(str2==".."){
						now=parent[now];
					}else{
						int k;
						for(k=0;k<G[now].size();k++){
							if(G[now][k].str==str2)break;
						}
						if(k!=G[now].size()){
							now=G[now][k].id;
							str2="";
							continue;
						}
						parent[all+1]=now;
						name[all+1]=str2;
						G[now].push_back(data(str2,all+1));
						now=all+1;
						all++;
					}
					str2="";
				}else{
					str2+=str[i][j];
				}
			}
			if(str2!="" && str2!="." && str2!=".."){
				int k;
				for(k=0;k<G[now].size();k++){
					if(G[now][k].str==str2)break;
				}
				if(k!=G[now].size())continue;
				parent[all+1]=now;
				name[all+1]=str2;
				G[now].push_back(data(str2,all+1));
				now=all+1;
				all++;
			}
		}
		for(int i=0;i<m;i++){
			string str,str2;
			cin >> str;
			cin >> str2;
			int now=check(str);
			int now2=check(str2);
			//printf("%d %d\n",now,now2);
			if(now==-1|| now2==-1)printf("not found\n");
			else printf("%s\n",now==now2?"yes":"no");
		}
	}
	return 0;
}

Measured memory_bytes: 4768
import static java.lang.Math.max;
import static java.lang.Math.min;
import java.util.Scanner;


public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    final int h = scanner.nextInt();
    final int n = scanner.nextInt();
    final int[] a = new int[n];
    final int[] b = new int[n];
    int max = 0;

    for (int i = 0; i < n; i++) {
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
      max = max(max, a[i]);
    }

    final long[][] dp = new long[n][h+max];

    dp[0][0] = b[0];
    for (int i = 1; i < h+max; i++) {
      dp[0][i] = b[0] * (long) Math.ceil((double) i /(double) a[0]);
    }
    for (int i = 1; i < n; i++) {
      for (int j = 0; j < h+max ; j++) {
        if(j > a[i]) {
          dp[i][j] = min(dp[i][j-a[i]] + b[i] , dp[i-1][j]);
        } else {
          dp[i][j] = min(dp[i-1][j], b[i]);
        }
      }
    }

    long min = Long.MAX_VALUE;
    for (int i = h; i < h+max; i++) {
      min = min(min, dp[n-1][i]);
    }
    System.out.println(min);

//    for (int i = 0; i < n; i++) {
//      for (int j = 0; j < h + max; j++) {
//        System.out.print(dp[i][j]);
//      }
//      System.out.println();
//    }

  }
}


Measured memory_bytes: 129888
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>
#include <queue>

constexpr long long INFLL = 1e18;

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int k;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0)
    {
        cout << -1 << endl;
    }
    else
    {
        if (k % 7 == 0)
        {
            k /= 7;
        }

        int x = 1 % k;
        int count = 1;

        while (x != 0)
        {
            x = x * 10 + 1;
            x %= k;
            count++;
        }
        cout << count << endl;
    }

    return 0;
}

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

signed main(){
  int N;
  cin>>N;
  int A[8];
  int over=0;
  rep(i,8)A[i]=0;
  rep(i,N){
    int C;
    cin>>C;
    if(C<400)A[0]+=1;
    if(C>=400&&C<800)A[1]+=1;
    if(C>=800&&C<1200)A[2]+=1;
    if(C>=1200&&C<1600)A[3]+=1;
    if(C>=1600&&C<2000)A[4]+=1;
    if(C>=2000&&C<2400)A[5]+=1;
    if(C>=2400&&C<2800)A[6]+=1;
    if(C>=2800&&C<3200)A[7]+=1;
    if(C>=3200)over+=1;
  }
  int ans=0,minans=0,maxans=0;
  rep(i,8){
    if(A[i]!=0)ans+=1;
  }
  minans=ans;
  if(minans==0&&over>=1)minans=1;
  maxans=ans+over;
  cout<<minans<<" "<<maxans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define RER(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
const ll INF = 1LL << 62;

typedef pair<ll, ll> P;
ll n, x, a[MAX_N];

signed main(){
	cin >> n >> x;
	REP(i, n) cin >> a[i];
	ll min_cost[MAX_N]; fill(min_cost, min_cost+MAX_N, INF);

	ll ret = INF;
	REP(i, n){
		REP(j, n){
			min_cost[j] = min(min_cost[j], a[(j-i>=0) ? j-i : j-i+n]);
			// if(min_cost[j] > a[(i+j+n)%n] + i * x){
			// 	min_cost[j] = a[(i+j+n)%n];
			// }
		}
		ll tmp = 0;
		REP(j, n) tmp += min_cost[j];
		// REP(j, n) cout << min_cost[j] << endl;
		ret = min(ret, tmp + i * x);
	}
	cout << ret << endl;
    return 0;
}

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

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    if (s[0] == t[0])
        cnt++;
    if (s[1] == t[1])
        cnt++;
    if (s[2] == t[2])
        cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3616
#sizeありversion
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}
        self._size = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0
        self._size[x] = 1

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
            self._size[x] += self._size[y]
            self._size[y] = 0
        else:
            self.p[x] = y
            self._size[y] += self._size[x]
            self._size[x] = 0
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    #頂点xが属するグループと同じグループに属する頂点数を得る
    def size(self, x):
        return self._size[self.findSet(x)]

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]


N, M = map(int, input().split())
l = [[int(i) for i in input().split()] for i in range(M)]

ds = DisjointSet()
for i in range(N):
    ds.makeSet(i+1)

ans = [0] * M
ans[M-1] = N * (N - 1) // 2

for i in range(M-1, 0, -1):
    a, b = l[i]
    if ds.same(a, b):
        ans[i-1] = ans[i]
    else:
        x = ds.size(a)
        y = ds.size(b)
        ans[i-1] = ans[i] - x * y
        ds.unite(a, b)

for a in ans:
    print(a)

Measured memory_bytes: 47988
#include "bits/stdc++.h"

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

signed main(){
    
    int c[26] = {0};
    int n;
    cin >> n;

    string x;
    cin >> x;
    REP(i,x.size()){
        c[x[i]-'a']++;
    }
  	
  	//REP(i,26)cerr << c[i];
  
    REP(i,n-1){
        string y;
        cin >> y;
        int d[26] = {0};
        REP(j,y.size()){
            d[y[j]-'a']++;
        }
        REP(j,26) c[j] = min(c[j],d[j]);
    }
    
    for(char C = 'a';C <= 'z';C++){
        REP(j,c[C-'a']) {
          cout << C;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <list>
#include <vector>
#include <map>
#include <time.h>
#include <cstdlib>
#include <iomanip>
#include <array>

#pragma warning(disable:4996)

using namespace std;

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



int main(void) {
	string str;
	int n,sum=0;

	cin >> str;
	cin >> n;

	
	FOR(i, 0, str.length()) {
		if (str[i] != 'a') {
			if ('z' - str[i]+1 <= n) {
				n -= 'z' - str[i]+1;
				str[i] = 'a';
			}
		}
	}
	if(n>0)str[str.length() - 1] = 'a' + (str[str.length() - 1] - 'a' + n) % ('z' - 'a'+1);

	cout << str << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String keyence = "keyence";
        String ans = "YES";
        if (-1 < S.indexOf("keyence")) {
            if (!S.substring(0, 7).equals("keyence") && !S.substring(S.length()-7, S.length()).equals("keyence")) {
                ans = "NO";
            }
        } else {
            boolean order = true;
            for (int i = 0; i < 7; i++) {
                if (S.charAt(i) == keyence.charAt(i) && order) {
                    continue;
                } else {
                    order = false;
                    if (S.charAt(S.length()-7+i) == keyence.charAt(i)) {
                        continue;
                    } else {
                        ans = "NO";
                    }
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cmath>

using namespace std;

int main() {
	int n, sum = 0, preMax;
	int B[100];
	cin >> n;
	
	for (int i = 0; i < n - 1; i++) {
		cin >> B[i];
	}
	B[n - 1] = B[n - 2];
	sum += B[0];
	for (int i = 1; i < n; i++) {
		if (B[i] > B[i - 1]) {
			sum += B[i - 1];
		}
		else {
			sum += B[i];
		}

	}
	cout << sum;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int dp[102][2][4]={};
    dp[0][0][0]=1;
    string n;
    int K;
    cin>>n>>K;
    for(int i=0;i<n.size();i++)
        for(int j=0;j<2;j++)
            for(int k=0;k<4;k++)
                for(int x=0;x<=(j?9:n[i]-'0');x++)
                    if(k!=3||x==0)
                        dp[i+1][j||x<n[i]-'0'][k+(x!=0)]+=dp[i][j][k];
    cout<<dp[n.size()][0][K]+dp[n.size()][1][K]<<endl;
}


Measured memory_bytes: 256
function Main(input){
	input = input.split("\n");
	var mem = input[0].split(" ").map(Number);
	var arr = input[1].split(" ").map(Number);
	var p = Math.abs(mem[1]-arr[0]);
	for(var i=1;i<arr.length;i++){
		p = gcd(p,Math.abs(arr[i]-mem[1]))
	}
	function gcd(a, b) {
    if (b === 0){
        return a
    }
    return gcd(b, a % b)
}
console.log(p)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 17484
#include<bits/stdc++.h>
using namespace std;
long long tot[2105],z[200010];
int main()
{
	string s;
	int i;
	long long x=1,ans;
	cin>>s;
	for(i=s.size()-1;i>=0;i--)
	{
		z[i]=(z[i+1]+(s[i]-'0')*x)%2019;
		x=x*10%2019;
		tot[z[i]]++;
	}
	ans=tot[0];
	for(i=0;i<2019;i++)
		ans+=tot[i]*(tot[i]-1)/2;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5296
#include <stdio.h>
#include <string.h>
#define LEN 100005
typedef struct pp{
  char name[100];
  int t;
}T_p;
T_p Q[LEN + 1];
int head, tail, n;
void enqueue(T_p);
T_p dequeue();
int main(){
  int elaps = 0, c;
  int i, q;
  T_p u;
  scanf("%d %d", &n, &q);
  for(i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1, tail = n + 1;
  int sum = 0;
  int cnt = 0;
  while(head != tail){
    if(Q[head].t <= q){
      sum += Q[head].t;
      printf("%s %d\n", Q[head].name, sum);
      dequeue();
    }
    else{
      sum += q;
      Q[head].t -= q;
      enqueue(dequeue());
    }
    cnt++;
    if(!(cnt % 10)){
      char c;
      scanf("%c", &c);
    }
  }
  return 0;
}

void enqueue(T_p x){
  Q[tail] = x;
  tail++;
  if(tail > LEN)
    tail = 0;
}

T_p dequeue(){
  T_p tmp = Q[head];
  head++;
  if(head > LEN)
    head = 0;
  return tmp;
}

Measured memory_bytes: 10756
#include <iostream>
#include <stdio.h>
#include <string>

struct Node {
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;
int n;

Node * getSuccessor(Node *u) {
    Node *x = u->right;
    while (x->left != NIL) {
        x = x->left;
    }
    return x;
}

void insert(int val) {
    Node *x = root;
    Node *y = NIL;
    Node *z;
    
    z = new Node();
    z->key = val;
    z->left = NIL;
    z->right = NIL;
    
    while (x != NIL) {
        y = x;
        if (x->key > val) {
            x = x->left;
        } else if (x->key <= val) {
            x = x->right;
        }
    }
    
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else if (y->key > z->key) {
        y->left = z;
    } else if (y->key <= z->key) {
        y->right = z;
    }
    
}

void delete_Node(Node *u) {
    Node *y;
    Node *x;
    if (u->left != NIL && u->right != NIL) {
        y = getSuccessor(u);
    } else {
        y = u;
    }
    
    if (y->left != NIL) {
        x = y->left;
    } else {
        x = y->right;
    }
    
    if (x != NIL) {
        x->parent = y->parent;
    }
    
    if (y->parent == NIL) {
        root = x;
    } else if (y == y->parent->left) {
        y->parent->left = x;
    } else {
        y->parent->right = x;
    }
    
    if (y != u) {
        u->key = y->key;
    }
    
    delete y;
}


Node * Find(Node *u, int val) {
    while (u != NIL) {
        if (u->key == val) return u;
        
        if (u->key > val) {
            u = u->left;
        } else if ( u->key <= val ) {
            u = u->right;
        }
    }
    return u;
}

void inorder(Node *u) {
    if (u == NIL) return;
    
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

void print() {
    inorder(root);
    printf("\n");
    preorder(root);
    printf("\n");
}

int main() {
    int val;
    char moji[10];
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%s", moji);
        if (moji[0] == 'i') {
            scanf("%d", &val);
            insert(val);
        } else if (moji[0] == 'p') {
            print();
        } else if (moji[0] == 'f') {
            scanf("%d", &val);
            Node *u = Find(root, val);
            if (u == NIL) printf("no\n");
            else printf("yes\n");
        } else if (moji[0] == 'd') {
            scanf("%d", &val);
            delete_Node(Find(root, val));
        }
    }
    
    return 0;
}



Measured memory_bytes: 21928
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L];

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + key % (M - 1);}

int find(char str[]){
  long long trip; 
  int i = 0;
  long long sum = getKey(str);

  while(1){
    trip = (h1(sum)+ i * h2(sum)) % M;
    if(strcmp(H[trip], str) == 0) return 1;
    if(H[trip][0] == '\0') return 0;
    i++;
  }
  return 0;
}

void insert(char str[]){
  int  i = 0;
  long long ago;
  long long sum = getKey(str);

  while(1){
    ago = (h1(sum)+ i * h2(sum)) % M;
    if(H[ago][0] == '\0' || strcmp(H[ago],str) == 0){
      strcpy(H[ago], str);
      break;
    }
    i++;
  }
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14280
#include <bits/stdc++.h>
using namespace std;
int n,m,a[1005][1005],b[1005],c[1005];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=m;i++) scanf("%d",&b[i]);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            c[i]+=a[i][j]*b[j];
        printf("%d\n",c[i]);
    }
}



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

const int MOD = 1e9 + 7;

int i, x, y;

int fact(int x) {
  if(x <= 1) return 1;
  return (1LL * fact(x - 1) * x) % MOD;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> x >> y;

  if(x + y == 1) return cout << "1\n", 0;

  if(abs(x - y) > 1) return cout << "0\n", 0;

  if(x == y) return cout << (2LL * (1LL * fact(x) * fact(y)) % MOD) % MOD << '\n', 0;

  cout << (1LL * fact(x) * fact(y)) % MOD << '\n';

  return 0;
}

Measured memory_bytes: 1792
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Collections;
import java.util.Arrays;
import java.lang.Math;

public class Main {
	static final int MOD = 1000000007;
	public static void main(String[] args) {
		FS reader = new FS();
		// write reader
		int H = reader.nextInt();
		int W = reader.nextInt();
		int N = reader.nextInt();
		int[] A = new int[N+1];
		for(int i=0; i<N; i++) A[i] = reader.nextInt();

		solver(H, W, N, A);
	}
	
	public static void solver(int H, int W, int N, int[] A) {
		// write logic
		int[][] board = new int[H][W];
		int color = 0;
		int remain = 0;
		for(int i=0; i<H; i++) {
		    for(int j=0; j<W; j++) {
		        if(remain == 0) {
		            remain = A[color];
		            color++;
		        }
		        if(i%2 == 0) board[i][j] = color;
		        else board[i][W-1-j] = color;
		        remain--;
		    }
		}
		for(int i=0; i<H; i++) {
		    for(int j=0; j<W; j++) {
		        System.out.print(board[i][j]);
		        if(j != W-1) System.out.print(" ");
		    }
		    System.out.println();
		}
	}
	
	// Read Class
	static class FS {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
	
		private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
		private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
		private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	
		public boolean hasNext() { skipUnprintable(); return hasNextByte();}
		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while(isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
		public int nextInt() {
			return (int)nextLong();
		}
		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if(b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 24912
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define ld long double
#define INF 1e+8
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end
using namespace std;
typedef pair<int, int>PA;
/*?????????????????????*/
typedef complex<double>P;
double dot(P a, P b){ return real(conj(a)*b);}
double cross(P a,P b){return imag(conj(a)*b);}
struct L: public vector<P>{
    L(const P &a,const P &b){
    push_back(a); push_back(b);
    }// line
};
struct C{
    P c; double r;
    C(const P &c, double r) : c(c),r(r){}    // circle
};
/*complex ?????????*/
namespace std {
    bool operator < (const P& a, const P& b) {
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
        //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b);
    }
    bool operator == (const P& a, const P& b) {
        return a.real()==b.real()&&a.imag()==b.imag();
    }
}
/*????¨?????????????????¨???????????????????*/
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
}
double point_distance(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double pi = acos(-1.0);
int main(){
    double ax,ay,bx,by;
    cin>>ax>>ay>>bx>>by;
    P p1(ax,ay);P p2(bx,by);
    int n;cin>>n;
    rep(i,n){
        double tx,ty;cin>>tx>>ty;
        P t(tx,ty);
        P ans=dot((t-p1),(p2-p1))/norm(p2-p1)*(p2-p1);
        ans=ans+p1;
        printf("%.8f %.8f\n",ans.real(),ans.imag());
    }
}

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

using namespace std;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int k;
  cin>>k;
  
  string s;
  cin>>s;
  
  if(s.size()>k)
  {
    for(int i=0;i<k;i++)
      cout<<s[i];
    
    cout<<"...";
  }
  else
    cout<<s<<endl;
  
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#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(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main()
{
    INIT;
    int r;
    int d;
    int x2000;
    scanf("%d%d%d", &r, &d, &x2000);
    for(int i=0;i < 10; i++){
        printf("%d\n", r * x2000 - d);
        x2000 = r * x2000 - d;
    }

    return 0;
}

Measured memory_bytes: 256
youso = int(input())
words = input()
numbers = words.split()
for i in range(youso):
    numbers[i] = int(numbers[i])
    
answer = 0

for j in range(youso):
    if j % 2 == 0 and numbers[j] % 2 == 1:
        answer += 1

print(answer)

Measured memory_bytes: 9172
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[100010];
    rep(i, N) cin >> a[i];
    sort(a , a + N);
    cout << a[N - 1] - a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin>>A>>B;
  int count = 0;
 
  for (int i=A;i<=B;i++) {
    if(i/10000 == i%10) {
      if((i/1000)%10 == (i/10)%10) {
        count++;
      }
    }
  }
  cout << count << endl;
}

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

int cnt = 0;

void insertionSort(int a[], int n, int m) {
  for (int i = m; i < n; i++) {
    int key = a[i];
    int j = i - m;
    while (j >= 0 && a[j] > key) {
      a[j + m] = a[j];
      j -= m;
      ++cnt;
    }
    a[j + m] = key;
  }
}

int main() {
  int a[1000000];
  int n;
  int g[100] = {0};
  int glen = 0;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  g[0] = 1;
  for (int i = 1; i < 100; i++) {
    int v = g[i - 1] * 3 + 1;

    if (v >= n) {
      glen = i;
      break;
    }

    g[i] = v;
  }

  cout << glen << endl;

  for (int i = glen - 1; i >= 1; i--) {
    cout << g[i] << ' ';
  }
  cout << g[0] << endl;

  for (int i = glen - 1; i >= 0; i--) {
    insertionSort(a, n, g[i]);
  }
  cout << cnt << endl;

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

  return 0;
}

Measured memory_bytes: 5064
#include<stdio.h>
int main()
{
  int n,s;
  scanf("%d",&n);
  if(n>9)
  {
    s=n%10;
    if(s==2 || s==4 || s==5 || s==7 || s==9)
    {
      printf("hon");
    }
    if(s==0 || s==1 || s==6 || s==8)
    {
      printf("pon");
    }
    if(s==3)
    {
      printf("bon");
    }
  }
  else
  {
     if(n==2 || n==4 || n==5 || n==7 || n==9)
    {
      printf("hon");
    }
    if(n==0 || n==1 || n==6 || n==8)
    {
      printf("pon");
    }
    if(n==3)
    {
      printf("bon");
    }
  }
}

Measured memory_bytes: 2140
#include <stdio.h>

int main(){
    int N, X, count = 0;
    scanf("%d %d", &N, &X);

    int m[N];
    for(int i = 0; i < N; i++){
        scanf("%d", &m[i]);
    }

    for(int i = 0; i < N; i++){
        X -= m[i];
        count++;
    }

    int min = m[0];
    for(int i = 0; i < N; i++){
        if(min > m[i]){
            min = m[i];
        }
    }

    count += (X / min);
    printf("%d\n", count);
    
    return 0;
}

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

vector<int> cumsum(vector<int> vec)
{
    vector<int> res;
    res.push_back(vec[0]);
    for (int i=1; i<vec.size(); ++i)
    {
        res.push_back(res[i-1] + vec[i]);
    }
    return res;
}


int main()
{
    int N,tmp;
    vector<int> A,B;
    cin >> N;

    for(int i=0; i<N; ++i)
    {
        cin >> tmp;
        A.push_back(tmp);
    }
    for(int i=0; i<N; ++i)
    {
        cin >> tmp;
        B.push_back(tmp);
    }

    vector<int> cumA = cumsum(A);
    vector<int> cumB = cumsum(B);

    int sum = 0;
    int candidate = 0;

    for (int j=0; j<N; ++j)
    {
        if(N==1)
        {
            sum = cumA[0] + cumB[0];
            break;
        }
        candidate = 0;
        candidate = cumA[j] + cumB[N-1] - cumB[j-1];
        if(sum<candidate) sum = candidate;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

template<class T>
vector<lli> djk(const T& e, lli n, lli s) {
  vector<lli> d(n+1, 1e18);
  vector<bool> fix(n+1);
  d[s] = 0;
  while (true) {
    lli u = -1, c = 1e18;
    for (lli i = 1; i <= n; ++i) {
      if (!fix[i] && d[i] < c) {
        u = i; c = d[i];
      }
    }
    if (u == -1) break;
    fix[u] = true;
    for (lli v = 1; v <= n; ++v) {
      lli w = e[u][v];
      if (u != v && w >= 0 && d[u] + w < d[v]) {
        d[v] = d[u] + w;
      }
    }
  }
  return d;
}

lli n, m;
lli e[101][101];
bool ok[101][101];

int main() {
  cin >> n >> m;
  for (lli j=0; j<=n; ++j) {
    for (lli i=0; i<=n; ++i) {
      if (i != j) e[j][i] = -1;
    }
  }
  for (lli i=0; i<m; ++i) {
    lli a, b, c;
    cin >> a >> b >> c;
    e[a][b] = e[b][a] = c;
  }

  for (lli u=1; u<=n; ++u) {
    auto d = djk(e, n, u);
    for (lli v=1; v<=n; ++v) {
      if (v != u) {
        for (lli w=1; w<=n; ++w) {
          if (d[v] == d[w] + e[w][v]) ok[w][v] = ok[v][w] = true;
        }
      }
    }
  }

  lli ans = 0;
  for (lli j=1; j<=n; ++j) {
    for (lli i=j+1; i<=n; ++i) {
      if (e[j][i] > 0 && !ok[j][i]) ++ans; 
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 384
n,k = (int(i) for i in input().split())
a = [int(input())-k for i in range(n)]
b = [[0,0]]
for i in range(n): b.append([b[-1][0]+a[i],i+1])
b.sort()
num,c = 1,[[b[0][1],1]]
for i in range(1,n+1):
	if b[i][0]!=b[i-1][0]: num+=1
	c.append([b[i][1],num])
c,d,ans = sorted(c),[0]*(n+2),0
def add(i):
	while i<=n+1:
		d[i] += 1
		i += i & -i
def get(i):
	s = 0
	while i:
		s += d[i]
		i -= i & -i
	return s
for i,j in c:
	ans+=get(j)
	add(j)
print(ans)

Measured memory_bytes: 76104
package main

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

type TupleInt struct {
	first  int
	second int
}

func main() {
	sc := NewScanner()
	A,B,C := sc.NextInt(),sc.NextInt(),sc.NextInt()
	if A==B && B==C && C==A {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}



}
func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func Max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type SortInterFace []TupleInt

func (s SortInterFace) Len() int {
	return len(s)
}
func (s SortInterFace) Less(i, j int) bool {
	return s[i].first < s[j].first
}
func (s SortInterFace) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        char[] codefes = {'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
        char[] str = scan.next().toCharArray();

        int count = 0;
        for (int i = 0; i < codefes.length; i++){
            if (codefes[i] != str[i]) count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 10068
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val x = sc.nextInt() - 1
    val y = sc.nextInt() - 1
    var ans = Array(n - 1) { 0 }
    for (i in 0 until n) {
        val dist = Array(n) { 0 }
        val visited = Array(n) { false }
        visited[i] = true
        val que: Queue<Pair<Int, Int>> = LinkedList()
        que.add(i to 0)
        while (que.count() > 0) {
            val (v, step) = que.poll()
            dist[v] = step
            if (v > 0 && !visited[v - 1]) {
                visited[v - 1] = true
                que.add(v - 1 to step + 1)
            }
            if (v < n - 1 && !visited[v + 1]) {
                visited[v + 1] = true
                que.add(v + 1 to step + 1)
            }
            if (v == x && !visited[y]) {
                visited[y] = true
                que.add(y to step + 1)
            }
            if (v == y && !visited[x]) {
                visited[x] = true
                que.add(x to step + 1)
            }
        }
        for (j in 0 until n) {
            if (dist[j] != 0) {
                ans[dist[j] - 1]++
            }
        }
    }
    println(ans.map { it / 2 }.joinToString("\n"))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

int main() {
    int m, f, r;
    while(1){
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) {
            break;
        } else if (m == -1 || f == -1 || m + f < 30) {
            cout << "F" << endl;
        } else if (m + f >= 80) {
            cout << "A" << endl;
        } else if (m + f >= 65) {
            cout << "B" << endl;
        } else if (m + f >= 50 || (m + f >= 30 && r >= 50)) {
            cout << "C" << endl;
        } else {
            cout << "D" << endl;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3124
from itertools import chain
n,m = map(int,input().split())
ab_list = [list(map(int, input().split())) for _ in range(m)]
tmp_list = sorted(list(chain(*ab_list)))
tmp_dic = {}
for i in range(1,n+1):
    tmp_dic[i]=0
for val in tmp_list:
    tmp_dic[val] += 1
for k,v in tmp_dic.items():
    print(v)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

// const int N = ;
int n;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	int ans = 0, lg = 0, a[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(a[i] > a[i - 1]) lg = 0;
		else lg++;
		ans = max(ans, lg);
	}
	cout << ans << '\n';
}	


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

void NO()
{
    cout << "No" << endl;
    exit(0);
}

// 1-indexed BIT (i : [1, len])
template<typename T, int len>
struct BIT
{
    array<T, len + 1> val;
    void reset() { val.fill(0); }
    BIT() { reset(); }
    void add(int pos, T v)
    {
        while (pos > 0 && pos <= len)
        {
            val[pos] += v;
            pos += pos & -pos;
        }
    }
    T sum(int pos)
    {
        T res = 0;
        while (pos > 0)
        {
            res += val[pos];
            pos -= pos & -pos;
        }
        return res;
    }
};
BIT<int, 300001> bit;
lint count_inversion(const vector<int> &vec)
{
    bit.reset();
    lint ans = 0;
    for (auto v : vec)
    {
        ans += bit.sum(v);
        bit.add(v + 1, 1);
    }
    return (lint)vec.size() * (vec.size() - 1) / 2 - ans;
}

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

    vector<int> p, q[2];
    REP(i, N)
    {
        int tmp;
        cin >> tmp;
        if ((tmp + i + 1) & 1) NO();
        p.push_back(tmp);
        q[i % 2].push_back(tmp);
    }
    if ((count_inversion(q[0]) + count_inversion(q[1])) * 3 != count_inversion(p)) NO();
    cout << "Yes" << endl;
}


Measured memory_bytes: 5236
def find(S, T):
    return all(s==t for s, t in zip(S, T) if s!="?")
S, T = input(), input()
L = []
for i in range(len(S)-len(T)+1):
    if find(S[i:i+len(T)],T):
        L.append((S[:i]+T+S[i+len(T):]).replace("?", "a"))
print(min(L) if len(L) else "UNRESTORABLE")

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

const int MAXN = 1e5 + 5;
int N, U, V; 
vector<int> adj[MAXN];

void bfs(vector<int> &dist, int src) {
	queue<int> Q;
	dist[src] = 0;
	Q.push(src);
	while(!Q.empty()) {
		int here = Q.front(); Q.pop();
		for(auto &next : adj[here]) {
			if(dist[next] == INT_MAX) {
				dist[next] = dist[here] + 1;
				Q.push(next);
			}
		}
	}
}

int main() {
	cin >> N >> U >> V;
	--U; --V;
	for(int i = 0; i < N - 1; ++i) {
		int a, b; cin >> a >> b;
		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);
	}
	vector<int> UD(N, INT_MAX), VD(N, INT_MAX);
	bfs(UD, U);
	bfs(VD, V);
	int maxD = 0;
	for(int i = 0; i < N; ++i) {
		if(VD[i] > UD[i]) maxD = max(maxD, VD[i]);
	}
	cout << maxD - 1 << endl;
}

Measured memory_bytes: 6656
import numpy as np

N,M,C = map(int, input().split())
B = np.array(input().split(), int)
As = np.array([input().split() for _ in range(N)], int)

ans = 0
for A in As:
    if np.dot(B, A) + C > 0:
        ans += 1
print(ans)

Measured memory_bytes: 27084
#coding: euc-jp
class Main
  def self.main
    a = read
    if a[0] == a[1] then
      puts a[0] * 2
    else
      i = a[0] < a[1] ? 1 : 0
      puts a[i] * 2 - 1
    end
  end

  def self.read
    gets.chomp.split.map(&:to_i)
  end
end

Main.main


Measured memory_bytes: 1788
#include <stdio.h>
struct student{
    char id[20];
    int k;
    int m;
}p[1010];
int main()
{
    int n;
    int ret = 0;
    scanf("%d", &n);
    for(int i = 1; i <= 9; i++){
        if(n % i == 0){
            int t = n / i;
            if(t >= 1 && t <= 9){
                ret = 1;
            }
        }
    }
    if(ret)
        printf("Yes");
    else
        printf("No");
    return 0;
}


Measured memory_bytes: 128
N, K = map(int, input().split())
trans = list(map(int, input().split()))

townOrder = [-1 for _ in range(N+1)]
townOrder[1] = 1
nextTown = 1
cicleStart = 0
cicleEnd = 0

for order in range(1, N+1):
  nextTown = trans[nextTown-1]
  if townOrder[nextTown] == -1:
    townOrder[nextTown] = order +1
  else:
    cicleStart = townOrder[nextTown]
    cicleEnd = order + 1
    break

exc = cicleStart -1
cicle = cicleEnd - cicleStart

if K > exc:
  K -= exc
  rest = K % cicle
  for _ in range(rest):
    nextTown = trans[nextTown-1]
  print(nextTown)
else:
  nextTown = 1
  for _ in range(K):
    nextTown = trans[nextTown-1]
  print(nextTown)

Measured memory_bytes: 32328
#include<stdio.h>

int main(){
    int i,dice[6],tmp;
    char c[100];
    for(i=0;i<6;i++){
        scanf("%d ",&dice[i]);
    }
    
    scanf("%s",&c);
    
    for(i=0;c[i];i++){
        if(c[i]=='S'){
            tmp=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='N'){
            tmp=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='W'){
            tmp=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='E'){
            tmp=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=dice[0];
            dice[0]=tmp;
        }
    }
    printf("%d\n",dice[0]);
    return 0;
}

Measured memory_bytes: 596
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

mod = 10**9+7
s = readline().rstrip().decode('utf-8')

dp = [0]*13 #あまりが0~12の13通りとなる場合の数
dp[0] = 1
dig = 1 #今見てる桁数
for i in range(len(s)-1,-1,-1): #小さい方の桁から見ていく
    c = s[i]
    next_dp = [0]*13 #逐次更新してはいけないので、次の桁の数についてjを回して入れていく
    if c == "?": #?なら0~10の10通り全てについてあたる必要がある
        for d in range(10):
            for j in range(13):
                next_dp[(d*dig + j)%13] += dp[j]
                next_dp[(d*dig + j)%13] %= mod

    
    else:
        d = int(c)
        for j in range(13):
            next_dp[(d*dig + j)%13] += dp[j]
            next_dp[(d*dig + j)%13] %= mod


    dig *= 10
    dig %= 13
    dp = next_dp

print(dp[5]%mod)

Measured memory_bytes: 43372
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;

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

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

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

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

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

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(int a, int b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	vint ans;
	while (1) {
		int a = 0;
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0)break;
		for (int i = 1; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (i + j + j + 1 <= x && x <= i + j + n) {
					a++;
				}
			}
		}
		ans.push_back(a);
	}
	coutans;
	return 0;
}


Measured memory_bytes: 3128
s = list(str(input()))
N = len(s)

if N == 2:
    if s[0] == s[1]:
        print(1,2)
    else:
        print(-1,-1)
else:   
    det = 0
    for i in range(N-3):
        if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
            print(i+1,i+3)
            det = 1
            break

    if det == 0:
        print(-1,-1)

Measured memory_bytes: 4084
#include <stdio.h>

int main()
{
  int i;
  double a;
  while(scanf("%lf",&a)!=EOF){
    double s=a;
    double pre=a;
    for (i=0;i<10-1;i++){
      if (i%2==0){
        s+=pre*2;
        pre*=2;
      }else{
        s+=pre/3;
        pre/=3;
      }

    }
    printf("%f\n",s);
  }

  return 0;
}

Measured memory_bytes: 648
n = int(input())
a = list(map(int, input().split()))
b = []
kosu = 0
mini = 10**9

for i in range(n):
    if a[i] < 0:
        b.append(-a[i])
        kosu += 1
    else:
        b.append(a[i])
    mini = min(mini, b[i])

ans = sum(b)

if kosu % 2 == 0:
    print(ans)
else:
    print(ans - 2 * mini)


Measured memory_bytes: 14412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int T[2005]={0};
int main(){
  ll n,k;cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>T[i];
  }
  ll a=0;ll b=0;
  for(int i=1;i<=n-1;i++){
    for(int j=i+1;j<=n;j++){
      if(T[i]>T[j])a++;
      else if(T[i]<T[j])b++;
    }
  }
  ll ans=0;
  ans+=a*((((k+1)*k)/2)%MOD)%MOD;
  ans+=b*((((k-1)*k)/2)%MOD)%MOD;
  cout<<ans%MOD<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    for (int i=1;i<=9;i++){
        for (int j=i;j<=9;j++){
            if (i*j==N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,A,x;
  cin >> N >> A;
  x = A - N % 500;
  if (x >= 0) {
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import numpy as np

# A, B, C = [11, 12, 15]
A, B, C = list(map(int, input().split()))


vals = np.array([A, B, C])
vals = np.sort(vals)

sumval = vals.sum()



cn = vals[-1] + np.sum(vals[:2]) % 2

n = (3 * cn - sumval) // 2

print(n)



Measured memory_bytes: 27204