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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll C[51][51];

void comb_table(int N){
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0 || j == i){
                C[i][j] = 1LL;
            }else{
                C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }
    }
}

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

    const int NMAX = 50;
    ll v[NMAX];

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

    comb_table(N);
    sort(v, v+N);
    reverse(v, v+N);

    double max_average = 0.0;
    for(int i = 0; i < A; i++){
        max_average += v[i];
    }
    max_average /= A;

    int a_th_val_num = 0, a_th_val_pos = 0;
    for(int i = 0; i < N; i++){
        if(v[i] == v[A-1]){
            a_th_val_num++;
            if(i < A){
                a_th_val_pos++;
            }
        }
    }

    ll cnt = 0LL;
    if(a_th_val_pos == A){
        for(a_th_val_pos = A; a_th_val_pos <= B; a_th_val_pos++){
            cnt += C[a_th_val_num][a_th_val_pos];
        }
    }else{
        cnt += C[a_th_val_num][a_th_val_pos];
    }

    cout.precision(20);
    cout << fixed << max_average << endl;
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0
for i in range(n):
    sum += b[a[i]-1]
    if i > 0:
        if a[i]-1 == a[i-1]:
            sum += c[a[i-1]-1]
print(sum)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int h, w;
	cin >> h >> w;
	vector<vector<char>> grid(h, vector<char> (w, 0));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> grid[i][j];
		}
	}
	vector<vector<int>> paths(h, vector<int> (w, 0));
	paths[0][0] = 1;
	for (int j = 0; j < w; j++) {
		if (grid[0][j] == '.') paths[0][j] = 1;
		if (grid[0][j] == '#') break;
	}
	for (int i = 0; i < h; i++) {
		if (grid[i][0] == '.') paths[i][0] = 1;
		if (grid[i][0] == '#') break;
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (grid[i][j] == '.') {
				if (grid[i - 1][j] != '#') {
					paths[i][j] += paths[i - 1][j];
					paths[i][j] %= MOD;
				}
				if (grid[i][j - 1] != '#') {
					paths[i][j] += paths[i][j - 1];
					paths[i][j] %= MOD;
				}
			}
		}
	}
	cout << paths[h - 1][w - 1] << endl;
	// for (int i = 0; i < h; i++) {
	// 	for (int j = 0; j < w; j++) {
	// 		cout << paths[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }

	return 0;
}

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

int main(){
    string target;
    int num;
    cin >> target;
    cin >> num;
    
    string com;
    for(int i =0; i<num; i++){
        cin >> com;
        if(com=="print"){
            int st,en;
            cin >> st >> en ;
            cout << target.substr(st,en-st+1) << endl;
        }
        else if (com=="replace"){
            int st,en;
            string str;
            cin >> st >> en >> str;
            target=target.replace(st,en-st+1,str);
        }else{
            int st,en;
            cin >> st >> en;
            string tmp =target.substr(st,en-st+1);
            int n =tmp.size();
            for (int i =0;i<n;i++) target[i+st]=tmp[n-i-1];
        }
    }
    return 0;
    
}


Measured memory_bytes: 3216
/*
    Circle in a Rectangle
*/

#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (x >= r && x <= W - r) {
        if (y >= r && y <= H - r) {
            puts("Yes");
            return (0);
        }
    }
    puts("No");
    return (0);
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  if (A == 5 && B == 5 && C == 7) {
    cout << "YES" << endl;
  } else if (A == 5 && B == 7 && C == 5) {
    cout << "YES" << endl;
  } else if (A == 7 && B == 5 && C == 5) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAXN = 3001;

int len[MAXN][MAXN], from[MAXN][MAXN];

int main() {
	string a, b;
	cin >> a >> b;
	
	int n = a.size(), m = b.size();

	for (int i = 0;i <= n;i++) 
		for (int j = 0;j <= m;j++) from[i][j] = -1;
	
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= m;j++) {
			if (a[i - 1] == b[j - 1]) {
				len[i][j] = len[i - 1][j - 1] + 1;
				from[i][j] = 0;
			}
			if (len[i - 1][j] > len[i][j]) {
				len[i][j] = len[i - 1][j];
				from[i][j] = 1;
			}
			if (len[i][j - 1] > len[i][j]) {
				len[i][j] = len[i][j - 1];
				from[i][j] = 2;
			}
		}
	}	

	/*cout << "len: " << endl;
	for (int i = 0;i <= n;i++) {
		for (int j = 0;j <= m;j++) cout << len[i][j] << " ";
		cout << endl;
	}

	cout << "from: " << endl;
	for (int i = 0;i <= n;i++) {
		for (int j = 0;j <= m;j++) cout << from[i][j] << " ";
		cout << endl;
	}*/
	
	int I = n, J = m;	

	string ans = "";

	while (from[I][J] != -1) {
		if (from[I][J] == 0) {
			I--; J--; ans += a[I];
		} else if (from[I][J] == 2) J--;
		else if (from[I][J] == 1) I--;
	}

	for (int i = ans.size() - 1;i >= 0;i--) cout << ans[i];
}

Measured memory_bytes: 70656
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

long long get_res(long long n) {
    long long tmp = 1;
    while ((tmp << 1) <= n) {
        tmp = (tmp << 1);
    }
    return n - tmp;
}

const int MAX_N = 200050;
int N;
long long A[MAX_N];

std::unordered_map<long long, int> mp;
std::vector<long long> vec;

int main(int argc, char **argv) {
    std::cin >> N;

    for (int i = 1; i <= N; i++) {
        std::cin >> A[i];
    }

    for (int i = 1; i <= N; i++) {
        vec.push_back(A[i]);
        if (mp.find(A[i]) == mp.end()) {
            mp[A[i]] = 1;
        } else {
            mp[A[i]] += 1;
        }
    }

    std::sort(vec.begin(), vec.end(), std::greater<long long>());

    int ret = 0;
    for (long long v : vec) {
        if (0 < mp[v]) {
            mp[v]--;
            long long res = get_res(v);
            long long cand = v - res * 2;
            if (mp.find(cand) != mp.end() && 0 < mp[cand]) {
                ret++;
                mp[cand]--;
            }
        }
    }

    std::cout << ret << std::endl;
    
    return 0;
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

vi bfs(int n, vvi& to, int st) {
  vi dist(n, INF);
  vi from(n, -1);
  queue<int> q;
  dist[st] = 0;
  q.push(st);
  int found = false;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : to[u]) {
      if (v == st) {
        int d = dist[u];
        vi res(d + 1);
        res[d] = u;
        while (u != st) {
          u = from[u];
          res[--d] = u;
        }
        return res;
      }
      if (dist[v] != INF) continue;
      dist[v] = dist[u] + 1;
      from[v] = u;
      q.push(v);
    }
  }
  vi res(1);
  return res;
}

void solve() {
  int n, m;
  cin >> n >> m;
  vvi to(n);
  rep(i, m) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    to[u].push_back(v);
  }
  dump(to);
  vvi loop(n);
  rep(u, n) loop[u] = bfs(n, to, u);
  // rep(u, n) dump(u, loop[u]);

  vector<int> used;
  function<void(int)> dfs = [&](int u) {
    dump(u, used[u]);
    if (used[u]) {
      if (used[u] == 1) used[u] = 3;
      return;
    }
    used[u] = 1;
    for (auto& v : to[u]) dfs(v);
    if (used[u] != 3) used[u] = 2;
  };

  // rep(u, n) {
  //   if (loop[u].size() > 1) {
  //     int pass = true;
  //     used.assign(n, 0);
  //     dfs(u);
  //     dump(u, used);
  //     used[u] = 2; // 開始点はOK
  //     for (int v : loop[u]) {
  //       if (used[v] == 3) {
  //         pass = false;
  //         break;
  //       }
  //     }
  //     if (pass) {
  //       cout << loop[u].size() << endl;
  //       for (int v : loop[u]) cout << v + 1 << endl;
  //       return;
  //     }
  //   }
  // }
  int minsz = INF;
  int minu = -1;
  rep(u, n) {
    if (loop[u].size() > 1) {
      if (minu == -1 || loop[u].size() < loop[minu].size()) {
        minu = u;
      }
    }
  }
  if (minu == -1) {
    cout << -1 << endl;
  } else {
    int u = minu;
    cout << loop[u].size() << endl;
    for (int v : loop[u]) cout << v + 1 << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 4224
import sys
input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

from math import gcd, floor, sqrt

INF = float('inf')


def is_prime(n):
    if n < 2:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False

    m = floor(sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True


N = int(input())
ans = 0

for i in range(1, N + 1):
    if i == 1:
        ans += N ** 2
        continue

    for j in range(1, N + 1):
        if j == 1:
            ans += N
            continue
        tmp = gcd(i, j)
        tmp_prime = is_prime(tmp)
        if tmp == 1:
            ans += N
            continue

        for k in range(1, N + 1):
            if k == 1:
                ans += 1
                continue
            if tmp_prime:
                if k % tmp == 0:
                    ans += tmp
                    continue
                else:
                    ans += 1
                    continue
            else:
                ans += gcd(tmp, k)

print(ans)




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }

    return 0;
}

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

int main(){
	/*input*/
	int n;	cin >> n;
	vector<int>d(n);
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	/*calculation*/
	sort(d.begin(), d.end());
	int ans = 0;
	for(int i = 0; i < n - 1; i++){
		if(d[i] == d[i + 1])continue;
		ans++;
	}
	/*output*/
	cout << ++ans << endl;
}


Measured memory_bytes: 256
def solve(ans, p, n):
    if len(p) == n:
        s = ""
        for v in p:
            s += chr(ord("a")+v)
        ans.append(s)
        return
    for v in range(max(p)+2):
        p.append(v)
        solve(ans, p, n)
        p.pop()
    return

def main():
    n = int(input())
    ans = []
    p = [0]
    solve(ans, p, n)
    ans.sort()
    for v in ans:
        print(v)

if __name__ == "__main__":
    main()

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

namespace _0030
{
    class Program
    {

        
        static void Main(string[] args)
        {

            string str = Console.ReadLine();
            var ch = str.ToCharArray();

            foreach(var s in ch)
            {
                if(s == 'A')
                {
                    Console.Write("X");
                }
                else if(s == 'B')
                {
                    Console.Write("Y");
                }
                else if(s == 'C')
                {
                    Console.Write("Z");
                }
                else
                {
                    Console.Write((char)(s - 3));
                }
                
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15868
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
   string s;

   cin >> s;

   cout << s[0];

   cout << s.size() - 2;

   cout << s[s.size()-1] << endl;

    return 0;
}

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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        int a; cin >> a;
        for (int dig = 1; dig <= 9; dig++) {
                if (a % dig == 0 && a / dig <= 9) {
                        cout << "Yes";
                        return;
                }
        }
        cout << "No";
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3628
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long m=sc.nextInt();
        long[] sum=new long[n+1];
        sum[0]=sc.nextInt()%m;
        for(int i=1;i<n;i++){
            sum[i]=(sc.nextInt()+sum[i-1])%m;
        }
        Arrays.sort(sum);
        long count=1;
        long ans=0;
        for(int i=1;i<n+1;i++){
            if(sum[i-1]==sum[i]){
                count++;
            }else{
                ans+=count*(count-1)/2;
                count=1;
            }
            if(i==n){
                ans+=count*(count-1)/2;
            }
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 62528
var
 i:longint;
 s,s1,s2:ansistring;
begin
 readln(s);
 readln(s1);
 for i:=1 to length(s1) do
  s2:=s2+s[i]+s1[i];
 if length(s)>length(s1) then s2:=s2+s[length(s)];
 writeln(s2);
end.

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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(){
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> a(n), b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<int> c(m), d(m);
    rep(i,m) cin >> c[i] >> d[i];
    rep(i,n) {
        int cp, min = INT32_MAX >>1;
        rep(j,m) {
            int dis = abs(a[i]-c[j]) + abs(b[i]-d[j]);
            if(min > dis || (min == dis && cp > j)) { 
                min = dis;
                cp = j;
            }
        }
        cout << cp+1 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    string s; cin >> s;
    s = " " + s;

    FOR(i, 1, s.length()) {
        bool b = i % 2 && s[i] == 'L' || i % 2 == 0 && s[i] == 'R';

        if (b) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s[3];
int main(){
  scanf("%s",&s);
  int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
 
  if (a-b-c-d==7) printf("%d-%d-%d-%d=7\n",a,b,c,d);
  else if (a-b-c+d==7) printf("%d-%d-%d+%d=7\n",a,b,c,d);
  else if (a-b+c-d==7) printf("%d-%d+%d-%d=7\n",a,b,c,d);
  else if (a-b+c+d==7) printf("%d-%d+%d+%d=7\n",a,b,c,d);
  else if (a+b-c-d==7) printf("%d+%d-%d-%d=7\n",a,b,c,d);
  else if (a+b-c+d==7) printf("%d+%d-%d+%d=7\n",a,b,c,d);
  else if (a+b+c-d==7) printf("%d+%d+%d-%d=7\n",a,b,c,d);
  else if (a+b+c+d==7) printf("%d+%d+%d+%d=7\n",a,b,c,d);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

shift = [(i*10)%13 for i in range(10)]

def main():
    S_tmp = input()
    N = len(S_tmp)-1
    S = [S_tmp[i] for i in range(N)]                          
    
    ans = [0]*13
    ans[0] = 1
    
    for i in range(N):
        ans_pre = [x for x in ans]
        ans = [0]*13
        
        if S[i] == "?":                   
            for j in range(13):                   
                for k in range(10):                           
                    ans[(j*10+k)%13] += ans_pre[j]
        else:       
            for j in range(13):
                ans[(j*10+int(S[i]))%13] += ans_pre[j]
                
        for j in range(13):
            ans[j] %= 10**9+7
            
    print(ans[5])
                
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 48880
import math


def solve():
    N = int(input())
    rN = math.ceil(N ** 0.5)

    for i in reversed(list(range(1, rN + 1))):
        if N % i == 0:
            print(int(i - 1 + (N / i) - 1))
            break


if __name__ == '__main__':
    solve()


Measured memory_bytes: 42996
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=b-a,e=c-b;
  if(d==e){
    cout<<"YES"<<endl;
  }
  else {
    cout <<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,Q;
int A[100010],B[100010],C[100010];
int num[100010];
vector<int> ans;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	cin>>Q;
	REP(i,Q){
		cin>>B[i]>>C[i];
	}
	int sum=0;
	REP(i,N){
		num[A[i]-1]++;
		sum+=A[i];
	}
	REP(i,Q){
		sum-=num[B[i]-1]*B[i];
		num[C[i]-1]+=num[B[i]-1];
		DEB(sum)END
		sum+=num[B[i]-1]*C[i];
		DEB(sum)END
		num[B[i]-1]=0;
		ans.push_back(sum);
	}
	REP(i,ans.size()){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 7408
use std::io;

fn main() {
    let (n, mut x) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut an = read::<usize>();
    an.sort();
    let mut ans = 0;

    for i in 0..n {
        if i == n - 1 {
            if an[i] == x { ans += 1; }
        } else if an[i] <= x { x -= an[i]; ans += 1; }
        else { break; }
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.Scanner;


public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) {
				count++;
			}
		}

		System.out.println(count);

		sc.close();
	}

}

Measured memory_bytes: 17328
N,M=map(int,input().split())
H=[list(map(int,input().split()))for _ in range(M)]
H.sort()
a=H[-1][0]
s=1
for i in range(M-2,-1,-1):
    if H[i][1]<=a:
        s+=1
        a=H[i][0]
print(s)


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

int main(){
  string n;
  cin>>n;
  int sum=0;
  for (int i=0;i<n.size();i++){
    sum+=n[i]-'0';
    sum%=9;
  }
  if(sum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 21, M = 1e9 + 7;

int a[N + 1][N], dp[N+1][1 << N];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j < (1 << n); j++) {
			if(__builtin_popcount(j) != i) continue;
			for(int k = 0; k < n; k++) {
				if((j >> k & 1) && a[i][k]) {
					dp[i][j] = (dp[i][j] + dp[i - 1][j ^ (1 << k)]) % M;
				}
			}
		}
	}
	cout << dp[n][(1 << n) - 1] << endl;

}



Measured memory_bytes: 93620
#include <iostream>
using namespace std;
int main(void){
    int n, m, a;
    long long d[100001], M = 1e9+7;
    bool b[100001];
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        b[i] = true;
        d[i] = 0;
    }
    for(int i=1;i<=n;i++){
        cin >> a;
        b[a] = false;
    }
    d[0] = 1;
    if(b[1])d[1] = 1;
    for(int i=2;i<=n;i++){
        if(b[i])d[i] = (d[i-1] + d[i-2]) % M;
    }
    cout << d[n] << endl;
}


Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


import numpy as np
from numba import njit

N, W_max = ints()
W, V = read_col(N)
W = np.array(W, dtype=np.int64)
V = np.array(V, dtype=np.int64)

'''
dp[i,j] ... 重さの最小 (:iまで考慮したとき、価値がちょうどjのとき)
答えはW以下の数字が入ってるマスの一番左側

更新則
chmin(dp[i+1,j+V[i]] , dp[i, j]+W[i]) #ナップサックに入れた場合
chmin(dp[i+1,j] , dp[i, j]) # ナップサックに入れなかった場合
'''


@njit('(i8, i8, i8[:], i8[:])', cache=True)
def solve(N, W_max, W, V):
    V_max = np.sum(V) + 1
    dp = np.full((N + 1, 2 * V_max), 10**12, dtype=np.int64)
    # 初期化
    dp[0][0] = 0  # 一個も選ばず価値が0なら必ず重さも0

    # 更新
    for i in range(N):
        # numba使うならベクトル化しないほうが早い!!!
        for j in range(V_max):
            jv = j + V[i]
            dp[i + 1, jv] = min(dp[i + 1, jv], dp[i, j] + W[i])
            dp[i + 1, j] = min(dp[i + 1, j], dp[i, j])

    # 左から見てく
    for j in range(V_max - 1, -1, -1):
        if np.any(dp[:, j] <= W_max):
            print(j)
            return


solve(N, W_max, W, V)


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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll n;
  cin>>n;
  vll v(n);
  FOR(i,0,n){
    cin>>v[i];
  }
  vll ve(n);
  ve[0]=v[0];
  FOR(i,1,n){
    ve[i]=ve[i-1]+v[i];
  }
  ll a=100,b=0;
  FOR(i,0,n-1){
   b=max(ve[n-1]-ve[i]*2,ve[i]*2-ve[n-1]);
    if(b<a){
      a=b;
    }
  }
  co(a);
}


Measured memory_bytes: 256
#include <iostream>                                          
using namespace std;                                         
                                                             
int main(void) {                                             
  int H, W;                                                  
  while (true) {                                             
    cin >> H >> W;                                           
    if (H==0 && W==0) {                                      
      break;                                                 
    }                                                        
    for (int i=0; i<H; i++) {                                
      for (int j=0; j<W; j++) {                              
        cout << "#" << flush;                                
      }                                                      
      cout << endl;                                          
    }                                                        
    cout << endl;                                            
  }                                                          
  return 0;                                                  
}                               

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

using namespace std;

const int MAX_N = 1000, INDEX = 1;

int n, a[MAX_N + INDEX];

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

    cin >> n;

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

    cout << *max_element(a + INDEX, a + INDEX + n, less<int>()) - *min_element(a + INDEX, a + INDEX + n, less<int>()) << endl;

    return 0;
}


Measured memory_bytes: 256
import bisect
X, N = map(int, input().split())
P = list(map(int, input().split()))
R = []
for i in range(105):
    R.append(i)
for p in P:
    R.remove(p)
a = bisect.bisect_right(R, X)
if X - R[a - 1] > R[a] - X:
    print(R[a])
else:
    print(R[a-1])

Measured memory_bytes: 9192
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n,t,*a = map(int,read().split())


ans = 0

s = a[0]
for i in a:
    s = max(i,s)
    ans += i+t-s
    s = i+t

print(ans)

Measured memory_bytes: 31096
//
// Created by bytedance on 2020/4/10.
//


#include <bits/stdc++.h>
//#include <fstream>

using namespace std;
const int maxn = 1e5 + 5;
int sum[maxn];

int main() {
    memset(sum, -1, sizeof(sum));
    long long n;
    int x, m;
    scanf("%lld%d%d", &n, &x, &m);
    int cnt = 1;
    long long ans = 0;
    while (cnt <= n) {
        if (sum[x] != -1) {
            long long tans = x;
            int tmp = 1LL * x * x % m;
            while (tmp != x) {
                tans += tmp;
                tmp = 1LL * tmp * tmp % m;
//                printf("%d %d\n", tmp, x);
            }
            ans += tans * ((n - cnt) / (cnt - sum[x]));
            n = (n - cnt) % (cnt - sum[x]) + 1;
            while (n) {
                ans += x;
                n--;
                x = 1LL * x * x % m;
            }
            break;
        }
        sum[x] = cnt++;
        ans += x;
        x = 1LL * x * x % m;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4204
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using li = unsigned long long int;
using namespace std;

int main() {
    fastIO;
    int n, m;
    cin >> n >> m;

    vector<int> roads(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        roads.at(a - 1)++;
        roads.at(b - 1)++;
    }
    for (auto road : roads) cout << road << endl;
}

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

int main() {
  int N;
  cin>>N;
  int a=0,b=0;
  for(int i=1;i<=N;i++){
    if(i%2==1) b++;
    a++;
  }
  double ans = double(b)/double(a);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), s = next();
  var a = nexts(n);
  var dp = xArray(0,s);
  var ans = 0;
  for(var i = 0; i < n; i++){
    var t = a[i], l = i+1, r = n-i;
    if(t === s)ans += mul(l,r);
    if(t >= s)continue;
    ans += mul(dp[s-t],r);
    for(var j = s-t; --j;){
      dp[j+t] += dp[j];
      dp[j+t] %= mod;
    }
    dp[t] += l;
    dp[t] %= mod;
  }
  return ans % mod;
}

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

int main(){
  string s;
  cin>>s;
  bool ans = true;
  if(s.length() % 2 != 0)
  { ans = false;}
else{  
  for(int i =0;i < s.length(); i++){
    if(i % 2 == 0)
      if(s[i] != 'h')
      {ans = false; break;}
    
    if(i % 2 == 1)
      if(s[i] != 'i')
      {ans = false; break;}
  }
}
  if(ans)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-


Fact = [False for _ in range(10**5+1)]

def get_fact(m):
  global Fact
  ans = 1
  for i in range(2,int(m**0.5)+1):
    if m%i==0:
      ans *= i
      if i != m//i:
        ans *= m//i
      if ans >= m*2 or Fact[m//i]:
        return True
  return False

Fact_n = [0 for _ in range(10**5+1)]
for i in range(2,10**5+1):
  Fact[i] = get_fact(i)
  if Fact[i]:
    Fact_n[i] = Fact_n[i-1]+1
  else:
    Fact_n[i] = Fact_n[i-1]

Q = int(input())
ret = [0 for _ in range(Q)]
for q in range(Q):
  ret[q] = Fact_n[int(input())]

for q in ret:
  print(q)


Measured memory_bytes: 10540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    
    if(S.at(A) != '-'){
        cout << "No" << endl;
        return 0;
    }

    for(int i=0;i<S.size();i++){
        if(i != A && S.at(i) == '-'){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define M 1000000007
#define line cout<<endl;
#define rep(i,k,n) for(ll i=(k);i<=(n);i++)
#define per(i,k,n) for(ll i=(k);i>=(n);i--)
#define pii pair<ll,ll> 
#define inar cin>>n; rep(i,0,n-1)cin>>a[i];
#define mp(a,b) make_pair(a,b)
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
using namespace std;
const int MAX=1000004;
long long p,q,x,l,r,y,z,i,j,k,n,m,t,d,c=0,sum=0;
ll mn=0x3f3f3f3f,len,cnt=1,mx=-1000;
vector<pii> v,prime;vector<pii> con;
bool sec(const pii &a,const pii &b){
	return a.second<b.second;
}
int main()
{
	string s;
	cin>>s;
	s[0]='2',s[1]='0',s[2]='1',s[3]='8';
	cout<<s;
return 0; 
}

Measured memory_bytes: 256
use std::io::Read;
use std::io::{stdout, BufWriter, Write};

fn main() {
    let mut buf = String::new();

    // stdinから全てbufに読み込む
    std::io::stdin().read_to_string(&mut buf).unwrap();

    // 読み込んだ文字列をスペースで分解する
    let mut iter = buf.split_whitespace();

    // about n
    let n: usize = iter.next().unwrap().parse().unwrap();
    // about k
    let k: usize = iter.next().unwrap().parse().unwrap();

    // ans
    let ans: usize = n - k + 1;

    // 出力
    let out = stdout();
    let mut out = BufWriter::new(out.lock());
    writeln!(out, "{}", ans).unwrap();
}

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

int main(){
  int n; string s;
  cin >> n >> s;
  string t;
  for(auto i=0;i<n/2;i++)
    t.push_back(s.at(i));
  string tt = t+t;
  if(tt == s)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(){
  char ch;

  while(1){
    scanf("%c", &ch);
    if(ch == '\n') break;
    if(!isalpha(ch)){
	printf("%c", ch);
      }else if(isupper(ch)){
	printf("%c", tolower(ch));
      }else{
	printf("%c", toupper(ch));
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

#define PI 3.141592653589793

int main(){
    double a,b,x;cin >> a >> b >> x;
    if(2*x > a*a*b){
        b = 2*b - (2*x)/(a*a);
        double th = atan(b/a);
        double ans = th*(180.0/PI);
    cout << fixed <<  std::setprecision(10) <<  ans << endl;
        
    }
    else{
    double tmp = (2*x) / (a*b*b);
   // cout << tmp << " ";
    double ra = atan(tmp);
   // cout << ra << " ";
    double th = PI/2 - ra;
   // cout << th << " ";
    double ans = th*(180.0/PI);
    cout << fixed <<  std::setprecision(10) <<  ans << endl;
    }
}


    



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int A,B;
	cin>>A>>B;
	cout<<(A+B)%24;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

int main()
{
    int h, w;
    cin >> h >> w;
    int result[1401][1401] = {};
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int c;
            cin >> c;
            if(c == 1) continue;
            if(i == 0 || j == 0){
                result[i][j] = 1;
            } else {
                result[i][j] = min(result[i - 1][j], min(result[i][j - 1], result[i - 1][j - 1])) + 1;
            }
            ans = max(ans, result[i][j]);
        }
    }
    // for(int i = 0; i < h; i++){
    //     for(int j = 0; j < w; j++){
    //         cout << result[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    cout << ans * ans << endl;
    return 0;
}

Measured memory_bytes: 10768
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

constexpr long long int MOD = 1000000007;
//const int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;

constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

struct Edge {
	int to, cost;
	Edge(const int t, const int c) {
		to = t, cost = c;
		return;
	}
};

struct Node {
	int dis, node, flag, turn;
	Node(const int d, const int n, const int f, const int t) {
		dis = d, node = n, flag = f, turn = t;
		return;
	}
	bool operator<(const Node&n)const {
		return dis > n.dis;
	}
};

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

	cin >> N >> M >> K;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	vector<vector<Edge>>edge(N);
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> H;
		L--, R--;
		edge[L].push_back(Edge(R, H));
		edge[R].push_back(Edge(L, H));
	}
	vector<vector<vector<long long int>>>dis(N, vector<vector<long long int>>(3, vector<long long int>(K + 1, MOD*MOD)));
	dis[0][2][K] = 0;
	priority_queue<Node>PQ;
	PQ.push(Node(0, 0, 2, K));
	while (!PQ.empty()) {
		auto box = PQ.top();
		PQ.pop();
		for (auto i : edge[box.node]) {
			if (v[i.to] == box.flag&&box.turn > i.cost)continue;
			if (v[i.to] == 0) {
				if (dis[i.to][2][K] > box.dis + i.cost) {
					dis[i.to][2][K] = box.dis + i.cost;
					PQ.push(Node(dis[i.to][2][K], i.to, 2, K));
				}
			}
			else if (v[i.to] == 2) {
				if (dis[i.to][0][K] > box.dis + i.cost) {
					dis[i.to][0][K] = box.dis + i.cost;
					PQ.push(Node(dis[i.to][0][K], i.to, 0, K));
				}
			}
			else {
				if (box.turn <= i.cost) {
					if (dis[i.to][1][0] > box.dis + i.cost) {
						dis[i.to][1][0] = box.dis + i.cost;
						PQ.push(Node(dis[i.to][1][0], i.to, 1, 0));
					}
				}
				else {
					if (dis[i.to][box.flag][box.turn - i.cost] > box.dis + i.cost) {
						dis[i.to][box.flag][box.turn - i.cost] = box.dis + i.cost;
						PQ.push(Node(dis[i.to][box.flag][box.turn - i.cost], i.to, box.flag, box.turn - i.cost));
					}
				}
			}
		}
	}
	//for (int i = 0; i < N; i++)for (int j = 0; j < 3; j++)for (int k = 0; k <= K; k++)if(dis[i][j][k]!=MOD*MOD)cout << i << " " << j << " " << k << " " << dis[i][j][k] << endl;
	long long int ans = MOD * MOD;
	for (auto i : dis.back())for (auto j : i)ans = min(ans, j);
	if (ans == MOD * MOD)ans = -1;
	cout << ans << endl;
}


Measured memory_bytes: 52092
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	string s;
	cin>>s;
	if(s.size()==2)cout<<s<<endl;
	else {
		for(int i=s.size()-1;i>=0;i--)cout<<s[i];
		cout<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class edge_t {
public:
  edge_t(int tt, int aa, int bb) : t(tt), a(aa), b(bb) {};

public:
  int t;
  int a;
  int b;
};

class node_t {
public:
  node_t(int ii, long long dd) : i(ii), d(dd) {};

public:
  bool operator<(const node_t& x) const {
    if (d != x.d)
      return d > x.d;

    return i > x.i;
  };

public:
  int i;
  long long d;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int n, m, s, t, u, v, a, b;

  std::cin >> n >> m >> s >> t;

  s --;
  t --;

  std::vector<std::vector<edge_t>> G(n);

  for (int i = 0; i < m; i ++) {
    std::cin >> u >> v >> a >> b;

    u --;
    v --;

    G[u].emplace_back(v, a, b);
    G[v].emplace_back(u, a, b);
  }

  long long dist[2][111111], d;

  memset(dist, 0x3f, sizeof(dist));

  std::priority_queue<node_t> pq;

  pq.emplace(s, dist[0][s] = 0);
  
  while (! pq.empty()) {
    node_t node = pq.top(); pq.pop();

    if (node.d > dist[0][node.i])
      continue;

    for (const auto& e : G[node.i])
      if ((d = node.d + e.a) < dist[0][e.t]) {
        dist[0][e.t] = d;
        
        pq.emplace(e.t, d);
      }
  }

  pq = std::priority_queue<node_t>();

  pq.emplace(t, dist[1][t] = 0);
  
  while (! pq.empty()) {
    node_t node = pq.top(); pq.pop();

    if (node.d > dist[1][node.i])
      continue;

    for (const auto& e : G[node.i])
      if ((d = node.d + e.b) < dist[1][e.t]) {
        dist[1][e.t] = d;
        
        pq.emplace(e.t, d);
      }
  }
  
  long long r[111111];

  r[n - 1] = dist[0][n - 1] + dist[1][n - 1];
  
  for (int i = n - 2; i >= 0; i --)
    r[i] = std::min(dist[0][i] + dist[1][i], r[i + 1]);

  for (int i = 0; i < n; i ++)
    std::cout << 1000000000000000LL - r[i] << std::endl;

  return 0;
}


Measured memory_bytes: 12344
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> A){
    if (A[0] != 0) {
        std::cout << -1 << std::endl;
        return;
    }
    long long c = A[0];
    long long ret = 0;
    for (int i = 1; i < N; i++) {
        if(A[i] - A[i-1] > 1) {
            std::cout << -1 << std::endl;
            return;
        } else if(A[i] - A[i-1] == 1){
            continue;
        } else {
            ret += A[i-1];
        }
    }
    ret += A.back();
    std::cout << ret << std::endl;
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> A(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&A[i]);
    }
    solve(N, A);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 3328
"""
Nが1になるようなKは、
・K^x = NになるようなKか
・K^x(K*y+1) = N になるようなKである。
後者は前者を包括するので、後者についてのみカウントすればよい。
Kの数を求めるために、後者をさらに2種類に分ける
・x > 0の場合
・x == 0の場合
前者の場合、KはNの約数なので、Nの約数全部に関して条件を満たすか調べればよい。Nの約数はそんなに多くならないので、時間はかからない。
後者の場合だと、KはN-1の約数の数だけ存在するのでN-1の約数の数を求めればよい。
"""
from collections import Counter

def gcd(a,b):
    return a if b==0 else gcd(b,a%b)

N = int(input())
ans = 0
#x>0の場合を調べる
#Nを素因数分解する
devisers = []
d = 2
while d*d < N:
    if N % d == 0:
        devisers.append(d)
        devisers.append(N//d)
    d += 1
if d*d == N:
    devisers.append(d)

for d in devisers:
    dummyN = N
    while dummyN % d == 0:
        dummyN //= d
    if dummyN%d == 1:
        ans += 1


#x == 0 になるようなKの数を調べる。
#N-1を素因数分解する。
tmp = []
dummyN = N-1
ceil = int(dummyN**0.5)
for d in range(2,ceil+1):
    while dummyN % d == 0:
        tmp.append(d)
        dummyN //= d
if dummyN != 1:
    tmp.append(dummyN)
    dummyN //= dummyN

divideN = Counter(tmp)
commonDCnt = 1
for v in divideN.values():
    commonDCnt *= (v+1)
ans += commonDCnt

print(ans)


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

using namespace std;

#define int long long

void solve() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int l = 0, r = 1e9;
    while (l < r - 1) {
        int m = (l + r) / 2;
        int cnt = 0;
        for (int i = 0; i < n; ++i) cnt += (a[i] + m - 1) / m - 1;
        if (k >= cnt) r = m;
        else l = m;
    }
    cout << r;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 5144
from itertools import islice


def maximum_profit(rate):
    ret = -float("inf")
    mi = rate[0]
    for r in islice(rate, 1, len(rate)):
        ret = max(ret, r - mi)
        mi = min(mi, r)
    return ret

if __name__ == "__main__":
    R = [int(input()) for _ in range(int(input()))]
    print(maximum_profit(R))

Measured memory_bytes: 15656
# 傾きの正負の変化を調べるのに、
# AとB(傾き)をかけてその符号を見るという方法があると気づいた
N = int(input())
A = list(map(int, input().split(" ")))

c = 1
e = 0
for i in range(N-1):
    d = A[i+1]-A[i]
    # print(d, e, e*d < 0)
    # 一方が負の数、もう一方が正の数なら
    if e*d < 0:
        c += 1
        e = 0
    elif d != 0: # この条件忘れた
        e = d

print(c)


Measured memory_bytes: 14252