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

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

    int min = t.length();
    for (int i = 0; i <= s.length() - t.length(); i++) {
      String ss = s.substring(i, i + t.length());

      int count = 0;
      for (int j = 0; j < t.length(); j++) {
        if (ss.charAt(j) != t.charAt(j)) {
          count++;
        }
      }
      min = Math.min(count, min);
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 27856
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int S=1e5;
LL X[S];
int W[S];
vector<int> ps[2];
vector<int> xs[2];
LL N,L;
int f(LL T, LL s)
{
	//cerr << T << ", " << s << endl;
	if(ps[0].size()==0||ps[1].size()==0){
		return 0;
	}
	int f=0;
	int a;
	int b;
	if(W[s]==1){
		a=lower_bound(ps[0].begin(),ps[0].end(),s)-ps[0].begin();
		b=(lower_bound(xs[1].begin(),xs[1].end(),X[s])-xs[1].begin())%xs[1].size();
	}
	else
	{
		f=1;
		a=lower_bound(ps[1].begin(),ps[1].end(),s)-ps[1].begin();
		b=(lower_bound(xs[0].begin(),xs[0].end(),X[s])-xs[0].begin()+xs[0].size()-1)%ps[0].size();
	}
	//cerr << "aaa " << a << ", " << b << endl;
	LL c=0;
	int sg[2]={1,-1};
	while(c<T){
		//cerr << f << ", " << a << ", " << b << ": " << ps[f].size() << ", " << ps[f^1].size() << endl;
		LL p=sg[f]*c+X[ps[f][a]];
		LL q=sg[f^1]*c+X[ps[f^1][b]];
		p%=L;
		if(p<0){
			p+=L;
		}
		q%=L;
		if(q<0){
			q+=L;
		}
		if(f==0&&q<=p){
			q+=L;
		}
		else if(f==1&&p<=q){
			p+=L;
		}
		if(abs(p-q)/2+c<T){
			c+=abs(p-q)/2;
			int t=(ps[f].size()+sg[f^1]+a)%ps[f].size();
			a=b;
			b=t;
			f^=1;
		}
		else{
			break;
		}
	}
	return ps[f][a];
}
P od[S];
int main() {
	LL T;
	cin >> N >> L >> T;
	L*=2;
	T*=2;
	for(int i=0;i<N;i++){
		cin >> X[i] >> W[i];
		X[i]*=2;
		if(W[i]==1){
			ps[0].push_back(i);
			xs[0].push_back(X[i]);
		}
		else{
			ps[1].push_back(i);
			xs[1].push_back(X[i]);
		}
	}
	LL o=f(T%L,(T/L*f(L,0))%N)%N;
	for(int i=0;i<N;i++){
		LL v=X[i];
		if(W[i]==1){
			v+=T;
		}
		else{
			v-=T;
		}
		v%=L;
		if(v<0){
			v+=L;
		}
		od[i]=P(v/2,W[i]);
	}
	P key=od[o];
	sort(od,od+N);
	int s=lower_bound(od,od+N,key)-od;
	for(int i=0;i<N;i++){
		cout << od[(s+i)%N].first << endl;
	}

	return 0;
}



Measured memory_bytes: 4216
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  long long A,B;
  cin >> A >>B;

  if((A==1 || B==1) &&( A==2 || B==2)){
  cout << "3" << endl ;
  }
  if((A==1 || B==1) &&( A==3 || B==3)){
  cout << "2" << endl ;
  }
  if((A==2 || B==2) &&( A==3 || B==3)){
  cout << "1" << endl ;
  }
  
}


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

int main()
{
    bool dp[100010]={0};
    string div[] = { "dream", "dreamer", "erase", "eraser" };
	string S; cin >> S;
	dp[0] = 1;
	for (int i = 0; i < S.size(); ++i) {
		if (!dp[i]) continue;
		for (string s : div) {
			if (s == S.substr(i, s.size())) {
				dp[i + s.size()] = 1;
			}
		}
	}
	cout << (dp[S.size()] ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3856
using System;
class Program
 {
   	static void Main(string[] args)
        {
    　　int N = int.Parse(Console.ReadLine()); //標準入力
		string a = Console.ReadLine(); //標準入力
		
      string[] aa = a.Split(' ');
		Decimal result=0;
      	
		Decimal[] bb = new Decimal[N];
		for(int i = 0; i< N; i++){
      			bb[i]= Decimal.Parse(aa[i]);
      		}
      Decimal sum= 0;
      Decimal sums = 0;
	for(int i = 0; i< N; i++){
      sum = (sum + bb[i])%(Decimal)(2*(Math.Pow(10,9)+7));
		sums = (sums + bb[i]*bb[i]) %(Decimal)(2*(Math.Pow(10,9)+7));
      		}
			result = (Decimal)((sum*sum-sums)/2) % (Decimal)(Math.Pow(10,9)+7);
     		Console.WriteLine("{0}", (int)result);
        }
 
 }

Measured memory_bytes: 49120
#include <stdio.h>

int main(void){
	
	int a,b;

	scanf("%d %d",&a,&b);

	if(a<b)printf("a < b\n");
	else if(a>b)printf("a > b\n");
	else if(a==b)printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall


def solve():
    N, M, L = map(int, input().split())
    dist = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(M):
        a, b, c = map(int, input().split())
        dist[a-1][b-1] = c
        dist[b-1][a-1] = c
    fw = floyd_warshall(csr_matrix(dist))

    ok = [[0 for _ in range(N)] for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if fw[i][j] <= L:
                ok[i][j] = 1
    ans = floyd_warshall(csr_matrix(ok))

    Q = int(input())
    for i in range(Q):
        s, t = map(lambda x: int(x)-1, input().split())
        if ans[s][t] < N:
            print(int(ans[s][t])-1)
        else:
            print(-1)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 21224
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



ll dp[3010][3010];
int main() {
	int n;
	cin >> n;
	n++;
	int count = 0;
	rep(i, n) {
		if (i % 2 == 1) {
			vector<ll> temp;
			divisor(i, temp);
			if (temp.size() == 8)count++;
		}
	}
	cout << count;
}

Measured memory_bytes: 256
let () =
  let k,s = Scanf.scanf "%d %d " (fun a b -> a,b) in

  let res = ref 0 in

  for i1 = 0 to k do
    for i2 = 0 to k do
      let i3 = s-i1-i2 in
      if i3>=0 && i3<=k then res := !res+1
    done;
  done;

  Printf.printf "%d\n" !res 


Measured memory_bytes: 384
import java.util.*;

class Main{

    class P{
        String name;
        double value;
        P(String name, double value){
            this.name = name;
            this.value = value;
        }
    }

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            PriorityQueue<P> q = new PriorityQueue<P>(10, new Comparator<P>(){
                    public int compare(P a, P b){
                        if(a.value<b.value) return 1;
                        if(a.value>b.value) return -1;
                        else{
                            int min = Math.min(a.name.length(), b.name.length());
                            for(int i=0; i<min; i++){
                                if(a.name.charAt(i)==b.name.charAt(i)) continue;
                                if(a.name.charAt(i)<b.name.charAt(i)) return -1;
                                else if(a.name.charAt(i)>b.name.charAt(i)) return 1;
                            }
                            if(a.name.length()<b.name.length()) return -1;
                            else if(a.name.length()>b.name.length()) return 1;
                        }
                        return 0;
                    }
                });

            for(int i=0; i<n; i++){
                String l = sc.next();
                int p = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
                int d = sc.nextInt(), e = sc.nextInt(), f = sc.nextInt(), s = sc.nextInt();
                int m = sc.nextInt();

                int time = (a + b + c) + (d + e) * m;
                int mo = -p + (f * s) * m;
                q.add(new P(l, (double)mo/time));
            }

            while(q.size()>0){
                P pp = q.poll();
                System.out.println(pp.name);
            }
            System.out.println("#");
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 38736
#include<bits/stdc++.h>
using namespace std;
const int N(111111);
long long dp[N][3];
char st[N], s[N];
int a[N];
int main() {
	int n;
	scanf("%d", &n);
	for(int i(0); i < n; i++) {
		if(i) {
			scanf("%s", st);
			s[i] = st[0];
		}else {
			s[i] = '+';
		}
		scanf("%d", &a[i]);
		if(s[i] == '-')
			a[i] = -a[i];
	}
	for(int i(0); i < n; i++) {
		for(int j(0); j <= 2; j++) {
			dp[i][j] = -1e18;
		}
	}
	dp[0][0] = a[0];
	for(int i(1); i < n; i++) {
		for(int j(0); j <= 2; j++) {
			for(int k(0); k <= j + 1; k++) {
				if(s[i] == '+' && k > j) 
					continue;
				dp[i][k] = max(dp[i][k], dp[i - 1][j] + a[i] * (j % 2 == 0 ? 1 : -1));
			}
		}
	}
	cout << dp[n - 1][0] << endl;
}


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

int main() {
  int N;
  scanf("%d", &N);
  int A, B;
  if (N > 1) {
    scanf("%d%d", &A, &B);
  }

  if (N == 1) {
    printf("Hello World");
  } else {
    printf("%d", A + B);
  }
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
int dp[3000][51];
//dp[i][j] ways to take j cards and calculate sum
int32_t main()
{
	int n,a;
	cin>>n>>a;
	dp[0][0]=1;
	int x=0;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		for(int sum=2500;sum>=0;sum--)
			for(int cards=i;cards>=0;cards--)
			dp[sum+x][cards+1]+=dp[sum][cards];
	}

	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=dp[i*a][i];
	}
	cout<<ans<<"\n";
}



Measured memory_bytes: 4600
#include <assert.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <string>
#include <vector>

 
using namespace std;
 
typedef string str;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<long long> vl;

#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define trav(a, x) for (auto &a : x)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define PRINT_ARRAY(a, N)        \
  F0R(z, N) cout << a[z] << " "; \
  cout << "\n"
 
const int MOD = 1000000007;  // 998244353
const ll INF = 1e18;
const ld PI = 4 * atan((ld)1);

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

		int made = 0;
		ll N, X, T;
		cin >> N >> X >> T;
		int t = 0;
		while (made < N) {
				made += X;
				t += T;
		}
		cout << t << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
}


Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine};
object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt;
        val t = new Tree(size);
        (0 until size).foreach { i =>
            readLine.split(" ").map(_.toInt) match {
                case Array(v, l, r) => t.add(v, l, r);
            }
        }
        println("Preorder");
        println(" " + t.walkPreorder().mkString(" "));
        println("Inorder");
        println(" " + t.walkInorder().mkString(" "));
        println("Postorder");
        println(" " + t.walkPostorder().mkString(" "));
    }
}
class Tree(val size: Int) {
    lazy private val root = setRoot();
    private val tree = new Array[(Int, Int, Int)](size);
    
    def add(value: Int, left: Int, right: Int): Unit = {
        tree(value) = (value, left, right);
    }
    def setRoot(): Int = {
        def _go(index: Int, tmpRoot: Int): Int = if (index >= size) {
            tmpRoot;
        } else {
            tree(index) match {
                case (v, l, r) => if (tmpRoot == l || tmpRoot == r) _go(0, v) else _go(index + 1, tmpRoot);
                case _ => _go(index + 1, tmpRoot)
            }
        }
        _go(0, tree(0)._1)
    }
    
    def walkPreorder(): List[Int] = {
        def _go(index: Int, ret: List[Int]): List[Int] = {
            if (index == -1) {
                ret;
            } else {
                val (v, l, r) = tree(index);
                val retSelf = v :: ret;
                val retLeft = _go(l, retSelf);
                val retRight = _go(r, retLeft);
                retRight;
            }
        }
        _go(root, Nil).reverse;
    }
    def walkInorder(): List[Int] = {
        def _go(index: Int, ret: List[Int]): List[Int] = {
            if (index == -1) {
                ret;
            } else {
                val (v, l, r) = tree(index);
                val retLeft = _go(l, ret);
                val retSelf = v :: retLeft;
                val retRight = _go(r, retSelf);
                retRight
            }
        }
        _go(root, Nil).reverse;
    }
    def walkPostorder(): List[Int] = {
        def _go(index: Int, ret: List[Int]): List[Int] = {
            if (index == -1) {
                ret;
            } else {
                val (v, l, r) = tree(index);
                val retLeft = _go(l, ret);
                val retRight = _go(r, retLeft);
                val retSelf = v :: retRight;
                retSelf
            }
        }
        _go(root, Nil).reverse;
    }
}


Measured memory_bytes: 44112
#include <iostream>
#include <set>
using namespace std;
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  string s;
  multiset<int> a;
  while(cin>>s){
    if(s=="end")return 0;
    if(s=="insert"){
      long long n;cin>>n;
      a.insert(n);
    }else{
      set<int>::iterator i = a.end();
      cout << *--i << endl;
      a.erase(i);
    }
  }
}



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

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b << '\n';  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n, counter, ans=0;
  cin >> n;
  for(int i=0;2*i+1<=n;i++){
    counter=0;
    for(int j=1; j<=2*i+1;j++)
      if((2*i+1)%j==0) counter++;
    if(counter==8)
      ans++;}
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    lst = [int(s) for s in input().split()]
    if lst.count(1) < 1:
        print(-1)
        return
    current = 1
    for i in lst:
        if i == current:
            current += 1

    answer = N - current + 1
    print(answer)

if __name__ == "__main__":
    main()



Measured memory_bytes: 26140
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
using ll = long long;
const int mod = 10000007;

ll n,w, cost[100000], weight[100000],memo[100001][101],sumc[100001],ans=-1;

ll dp(ll c,ll num);
int main() {
	fill(memo[0], memo[100001], -1);
	cin >> n>>w;
	sumc[0] = 0;
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> cost[i];
		sumc[i+1] = sumc[i] + cost[i];
	}
	for (int i = 0; i < 101; i++) {
		memo[0][i] = 0;
	}
	for (int i = 0; i < 100001; i++) {
		memo[i][0] = 0;
	}
	for (int i = 0; i <= 100000; i++) dp(i, n);
	cout << ans << endl;
}
ll dp(ll c,ll num) {
	if (c < 0||sumc[num]<c)return 100000000000;
	if (memo[c][num] == -1) {
		memo[c][num] = min(dp(c,num - 1), dp(c - cost[num - 1],num - 1) + weight[num - 1]);
		if (memo[c][num] > w)memo[c][num] = 100000000000;
		else ans = max(ans, c);
	}
	return memo[c][num];
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> cards(N);
  for (int i = 0; i < N; i++) {
    cin >> cards.at(i);
  }
  
  sort(cards.begin(), cards.end(), greater<int>());
  
  int diff = 0;
  for (int i = 0; i < N; i+=2) {
    diff += cards.at(i);
    if (i == N - 1) break;
    diff -= cards.at(i + 1);
  }
  
  cout << diff << endl;
}


Measured memory_bytes: 256
n,m,l = map(int,input().split())
if (n != m) and (n != l ) and (m != l):
  print('No')
elif n == m:
  if n == l:
    print('No')
  else:
    print('Yes')
elif n == l:
  print('Yes')
elif m == l:
  print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int>v;
	int n,m,ans=0;
	cin>>n>>m;
	for(int i=1;i<=sqrt(m);i++)
		if(m%i==0)
		{
			v.push_back(i);
			if(i!=sqrt(m))v.push_back(m/i);
		}
	sort(v.begin(),v.end());
	int i;
	for(i=0;i<v.size();i++)
		if(v[i]>=n)
		{
			cout<<m/v[i];
			return 0;
		}
}

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

using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N + 1);
  vector<int> AS(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    A[i] %= M;
    AS[i] = AS[i - 1] + A[i];
    AS[i] %= M;
  }
  map<int, int> m;
  m[0] = 1;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += m[AS[i]];
    m[AS[i]]++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3968
# -*- coding: utf-8 -*-
s = input()
t = ''
keywords = ['dream', 'erase', 'dreamer', 'eraser']

wk = ''
wk2 = ''
while (s != t):
  for keyword in keywords:
    wk = keyword + t
    if s == wk:
      t = wk
      break
    elif s.endswith(wk):
      t = wk
      break
  if wk2 == t:
    t = ''
    break
  wk2 = t

print('YES') if t != '' else print('NO')


Measured memory_bytes: 3624
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n,k = get_nums_l()
A = [-1] + get_nums_l()

# log(A)

now = A[1]
count = 1
history = {1}

while now not in history:
    # log(now, count)
    count += 1
    history.add(now)
    now = A[now]

loop_start = now
init_len = 0
now = 1
while now != loop_start:
    now = A[now]
    init_len += 1

# log("init_len", init_len)
# log("count", count)

if k <= 2*n:
    now = 1
    for i in range(k):
        now = A[now]
else:
    l = (k - init_len) % (count-init_len)

    now = loop_start
    for i in range(l):
        now = A[now]

print(now)

Measured memory_bytes: 113104
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll k,t,ans=0;
  cin >> k >> t;
  ll a[t];
  for(int i=0;i<t;i++){
    cin >> a[i];
    ans = max(a[i]-1-(k-a[i]),ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <unistd.h>
#include <utility>
#include <vector>
#define int ll
#define dbc(x) //cerr << x << '\n'
#define dbn(x) //cerr << #x << " == " << x << '\n'
#define pb push_back
#define endl '\n'

using namespace std;

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

//
const int MOD = 1e9 + 7;
map<int, int> him;
map<int, int> glob;

bool sieve[10000];

void sie(int n) {
	memset(sieve, 1, sizeof sieve);
	sieve[0] = sieve[1] = 0;
	for (int i=2; i*i <= n; i++) {
		if (sieve[i]) {
			for (int j=i*i; j<n; j+=i) {
				sieve[j] = false;
			}
		}
	}
}

void fac(int m) {
	him.clear();

	for (int i=2; i <= m; i++) {
		while (m % i == 0) {
			him[i]++;
			m /= i;
		}
	}

	for (auto i : him) {
		dbn(i.first);
		dbn(i.second);
		glob[i.first] += i.second;
	}
	dbc("====");
}

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

	int n; cin >> n;
	sie(n);

	for (int i=2; i<=n; i++) {
		fac(i);
	}

	int resp = 1;
	for (auto i : glob) {
		resp = (resp * (i.second + 1)) % MOD;
	}

	cout << resp << endl;
}

Measured memory_bytes: 256
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];
	int mx = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j)
				continue;
			mx = max(mx, abs(v[i] - v[j]));
		}
	}
	cout << mx << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

bool check(int *L, int i, int j, int k);
int main(){
    int N;
    int L[100];
    int i,j,k;
    int count = 0;

    cin >> N;
    for(i=0;i<N;i++){
        cin >> L[i];
    }

    for(i=0;i<N;i++){
        for(j=i+1;j<N;j++){
            for(k=j+1; k<N;k++){
                if(check(L,i,j,k) == true){
                    count++;
                }
            }
        }
    }

    cout << count << endl;
    return 0;
}

bool check(int *L, int i, int j, int k){
    int data[3] = {L[i],L[j],L[k]};
    int counter;
    sort(data,data + 3,std::greater<int>());

    for(counter=1;counter<3;counter++){
        if(data[counter] == data[counter-1]){
            return false;
        }
    }

    if( data[0] < data[1] + data[2]){
        return true;
    }else{
        return false;
    }
}

Measured memory_bytes: 3588
s = input()
l = 1 <= int(s[:2]) <= 12
r = 1 <= int(s[2:]) <= 12
if l:
    if r:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if r:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8, i8, i8), cache=True)
def main(N, X, M):
    A = np.empty(M + 10, np.int64)
    A[0] = X
    first = np.full(M, -1, np.int64)
    n = 0
    while True:
        n += 1
        A[n] = A[n - 1] * A[n - 1] % M
        if first[A[n]] >= 0:
            period = n - first[A[n]]
            offset = first[A[n]] + 1
            break
        first[A[n]] = n
    if N <= offset:
        return A[:N].sum()
    x = A[:offset].sum()
    N -= offset
    q, r = divmod(N, period)
    x += q * A[offset:offset + period].sum()
    x += A[offset:offset + r].sum()
    return x

N, X, M = map(int, readline().split())

print(main(N, X, M))

Measured memory_bytes: 107408
import sys

from collections import deque
# q = deque(); q.append(x); q.appendleft(x); q.pop() -> x; q.popleft() -> x
from collections import defaultdict
# d = defaultdict(lambda: []); d[key] -> []
import heapq
# hq = []; heapq.heappush(hq, x); heapq.heappop(hq) -> x; heapq.heappushpop(hq, x) -> x
import bisect
# i = bisect.bisect_left([1,2,3,4], 1.5); i = bisect.bisect_right([4,3,2,1], 1.5)

#import numpy as np
#from scipy.misc import comb

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    X = i2nn()
    X.sort()
    n = sum(X[:2])
    print(n)

main()


Measured memory_bytes: 38384
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		int res = 0;
		while(true) {
			boolean flg = false;
			for (int i=0; i<N; i++) {
				if ( A[i]%2 == 0 ) {
					A[i] = A[i]/2;
				}else {
					flg = true;
					break;
				}
			}
			if (flg) break;
			res++;
		}
		System.out.println(res);
	}
}


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

using namespace std;
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(9);
  cout << fixed;
  int n; cin >> n;
  vector<pair<int, int>> ar(n);
  for(auto &x: ar) cin >> x.first >> x.second;
  sort(ar.begin(), ar.end());
  double sum = 0, oc = 0;
  do {
    for(int i = 1; i < n; ++i) {
      sum += hypot(ar[i].first - ar[i - 1].first, ar[i].second - ar[i - 1].second);
    }
    oc++;
  } while(next_permutation(ar.begin(), ar.end()));
  cout << sum / oc << '\n';
  return 0;
}


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

std::vector<int> A(9);
int n;
string Message = "No";

int main() {
  for (size_t i = 0; i < 9; i++) {
    cin >> A.at(i);
  }
  cin >> n;
  std::vector<int> B(n);
  for (size_t i = 0; i < n; i++) {
    cin >> B.at(i);
  }
  for (size_t i = 0; i < 9; i++) {
    for (size_t j = 0; j < n; j++) {
      if (A.at(i) == B.at(j)) {
        A.at(i) = 0;
      }
    }
  }
  for (size_t i = 0; i < 9; i++) {
    if (A.at(i) != 0) {
      A.at(i) = 1;
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (A.at(i * 3) + A.at(i * 3 + 1) + A.at(i * 3 + 2) == 0) {
      Message = "Yes";
    }
  }
  for (size_t i = 0; i < 3; i++) {
    if (A.at(i) + A.at(i + 3) + A.at(i + 6) == 0) {
      Message = "Yes";
    }
  }
  if (A.at(0) + A.at(4) + A.at(8) == 0) {
    Message = "Yes";
  }
  if (A.at(2) + A.at(4) + A.at(6) == 0) {
      Message = "Yes";
  }
  cout << Message << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	string str = next<string>();
	rep(i, 0, str.length()) if (str[i] == '7') { puts("Yes"); return 0; }
	puts("No");
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


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

using namespace std;

bool np[100005];
int cnt[100005], q, ta, tb;

int main() {
	np[0] = 1, np[1] = 1;
	for (int i = 2; i < 100005; i++)
		if (!np[i])
			for (long long j = (long long)i * i; j < 100005; j += i)
				np[j] = 1;
	scanf("%d", &q);
	for (int i = 0; i < 100004; i++) {
		cnt[i + 1] = cnt[i];
		if (i % 2 && !np[i] && !np[(i + 1) / 2])
			cnt[i + 1]++;
	}
	while (q--) {
		scanf("%d%d", &ta, &tb);
		printf("%d\n", cnt[tb + 1] - cnt[ta]);
	}
	return 0;
}

Measured memory_bytes: 1152
fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    if n % 2 != 0 {
        yn(false);
        return;
    }
    for i in 0..n / 2 {
        if s[i] != s[i + n / 2] {
            yn(false);
            return;
        }
    }
    yn(true);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <cstdio>

#define NR 410

bool un[NR][NR], del[NR];
int n, m;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i) {
		int x, y;
		scanf("%d%d", &x, &y);
		
		if (del[x] || del[y] || un[x][y] || un[y][x]) {
			if (!del[x] || !del[y]) {
				del[x] = del[y] = true;
				for (int k = 1; k <= n; ++k) un[k][x] = un[k][y] = true;
			}
		} else {
			for (int k = 1; k <= n; ++k) if (k != x && k != y) {
				if (un[k][x]) un[k][y] = true;
				if (un[x][k]) un[y][k] = true;
				if (un[k][y]) un[k][x] = true;
				if (un[y][k]) un[x][k] = true;
			}
			
			un[x][y] = true;
			un[y][x] = true;
		}
	}
	
	int cnt = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j < i; ++j)
			if (!un[i][j] && !un[j][i])
				++cnt;
				
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 384
# -*- coding:utf-8 -*-
import sys
 
 
def search(x, y):
    x_length = len(x)
    y_length = len(y)
    memo = [[0] * (y_length + 1) for i in range(x_length + 1)]
    for i, ch_x in enumerate(x, 1):
        row = memo[i]
        pre_row = memo[i-1]
        for j, ch_y in enumerate(y, 1):
            if ch_x == ch_y:
                row[j] = pre_row[j-1] + 1
            elif pre_row[j] < row[j-1]:
                row[j] = row[j-1]
            else:
                row[j] = pre_row[j]
    return memo[-1][-1]
 
 
if __name__ == "__main__":
    n = int(input())
    strs = [list(val) for val in sys.stdin.read().splitlines()]
    result = [search(strs[i*2], strs[i*2+1]) for i in range(n)]
    print(*result, sep="\n")


Measured memory_bytes: 31040
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (ll i = a; i < b; i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<ll, ll>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

int main() {
	fast_io;
	string s; cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes";
		else
		cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666;
int n,m,a[N],f[N];char s[N];bool mrk[N];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
Vi dot[N];
void merge(int x, int y){
	x=find(x);y=find(y);f[x]=y;
}
int main() {
	scanf("%s",s+1);n=strlen(s+1);read(m);
	rep(i,1,n)a[i]=(int(s[i])-int(s[i-1])+26)%26;
	rep(i,1,n+1)f[i]=i;
	while(m--){
		int l,r;read(l);read(r);merge(l,r+1);mrk[l]=mrk[r+1]=1;
	}
	if(n%2){for(int i=2;i<n+2-i;i++)merge(i,n+2-i),mrk[i]=mrk[n+2-i]=1;}
	else{mrk[n/2+1]=1;for(int i=2;i<n+2-i;i++)merge(i,n+2-i),mrk[i]=mrk[n+2-i]=1;}
	mrk[n+1]=0;mrk[1]=0;
	rep(i,1,n+1)dot[find(i)].pb(i);
//	rep(i,1,n+1)printf("%d:%d %d\n",i,f[i],a[i]);
	rep(i,1,n+1)if(SZ(dot[i])){
		int s=0,s1=0;rep(j,0,SZ(dot[i])-1)s+=a[dot[i][j]],s1+=!mrk[dot[i][j]];
		if(!s1&&s%26){puts("NO");return 0;}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 9984
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] s = new String[h];
		for(int i = 0; i < h; i++) {
			s[i] = sc.next();
		}
		int[] dx = {0,0,1,1,1,-1,-1,-1};
		int[] dy = {-1,1,-1,0,1,-1,0,1};
		for(int i = 0; i < h; i++) {
			for(int j = 0; j< w; j++) {
				if(s[i].charAt(j)=='.') {
					int count = 0;
					for(int k = 0; k < 8; k++) {
						int x = i+dx[k];
						int y = j+dy[k];
						if((x>=0 && x < h) && (y>=0 && y < w)) {
							if(s[x].charAt(y)=='#') {
								count++;
							}
						}
					}
					System.out.print(count);
				}
				else {
					System.out.print('#');
				}
			}
			System.out.println();
		}
	}
}

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> a(H);
  rep(i, H) {
    vector<char> row(W);
    rep(j, W) { cin >> row.at(j); }
    a.at(i) = row;
  }

  rep_s(i, -1, H + 1) {
    rep_s(j, -1, W + 1) {
      if (i == -1 || j == -1 || i > H - 1 || j > W - 1) {
        cout << "#";
      } else {
        cout << a.at(i).at(j);
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

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

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}

void solve()
{
    int n;
    cin>>n;
    int val=0;
    for(int i=1;i<=n;i++){
        for(int p=i;p<=n;p+=i){
            val+=p;
        }
    }
    cout<<val<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    //cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((long double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include<string>
using namespace std;
int main()
{
	int n,arr[100],x=0;
	cin >> n;
	for (int i = 1; i <=n; i++) {
		cin >> arr[i];
	}
	for(int i = 1; i <= n; i++) {
		if (i % 2 == 1 & arr[i] % 2 == 1)x++;
	}
	cout << x;
	return 0;
}


Measured memory_bytes: 3600
//https://atcoder.jp/contests/abc146/tasks/abc146_a
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 <<endl;
    else if(s == "TUE") cout << 5 << endl;
    else if (s== "WED") cout << 4 << endl;
    else if( s== "THU") cout << 3 << endl;
    else if( s== "FRI") cout << 2 << endl;
    else if( s== "SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, T: int):
    p = N // X
    q = N % X
    if q > 0:
        p += 1
    t = p * T
    print(t)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61748
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int d[6] = {1500,1200,1000,500,300,200};
int m[6] = {2244,1870,1520,850,550,380};
int main(void){
  int n;
  int dp[5001]={0};
  FOR(i,1,5001) dp[i] = 1e8;
  REP(i,6){
    FOR(j,0,5001-d[i]){
      dp[j+d[i]] = min(dp[j] + m[i], dp[j+d[i]]);
    }
  }
  while(cin>>n){
    if(!n) break;
    cout<<dp[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i+=2) {
    int cnt = 0;
    for (int j = 1; j*j <= i; ++j) {
      if (i%j == 0) {
        cnt += 2;
        if (j*j == n) cnt--;
      }
    }
    //show2(i,cnt);
    if (cnt == 8) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <algorithm>
# include <cstring>
# include <cmath>
# include <climits>
# include <iostream>
# include <string>
# include <queue>
# include <vector>
# include <set>
# include <map>
# include <cstdlib>
# include <stack>
# include <ctime>
using namespace std;

# 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 mct(a,b) memset(a,b,sizeof(a))
# define gc getchar()
typedef long long ll;
const int N=1e6+5;
const int inf=0x7fffffff;
const double eps=1e-7;
template <typename T> void read(T &x){
	x=0;int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
	x*=f;
}
int n,k;
char s[N];
int a[N];
int ans;

int main()
{
	read(n);
	read(k);
	scanf("%s",s+1);
	Rep(i,1,n-1)if(s[i]==s[i+1])ans++;
	printf("%d\n",min(n-1,ans+2*k));
	return 0;
}

Measured memory_bytes: 2304
n=int(input())
li = ["357","375","537","573","753","735"]
if n<1000:
  li=[s for s in li if int(s)<=n]
  print(len(li))
  exit()
t=["7","5","3"]
ans = 6
for i in range(4,10):
  li_new = []
  for s in li:
    for j in range(i):
      for k in t:
        u=int(s[:j]+k+s[j:])
        if u<=n:
          li_new.append(str(u))
  li=list(set(li_new))
  ans += len(li)
print(ans)

Measured memory_bytes: 21120
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;
///if(///////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}


///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());




int n; cin>>n;
char c; 
vv<int> ct(26,0);
ll ans=1;
for(int i=0;i<n;++i){
	cin>>c; c-='a';
	ct[c]++;
}
for(int i=0;i<26;++i){
	ans=(ans*(ct[i]+1))%MOD;
}
cout<<(ans-1+MOD)%MOD<<el;



return 0;
}


Measured memory_bytes: 256