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

using namespace std;

inline long long read(){
   long long w=1,s=0;
   char ch=getchar();
   while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();} 
   while(ch>='0'&&ch<='9')  s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int main(){
    long long n=read(),ans=0;
    for(int j=2;j<=n;j++){
    int now=0;
    for(int i=1;i<j;i+=2) if (j%i==0) now++;
    if (now==7) ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll k; cin>>k;
	ll n; cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];

	vector<ll> l(n);
	REP(i,n-1){
		l[i]=a[i+1]-a[i];
	}
	l[n-1]=k-(a[n-1]-a[0]);

	//cout << "l: "; REP(i,(signed)l.size()) cout<<l[i]<<" "; cout << endl; //----------cout----------//


	sort(l.begin(),l.end());
	cout<<k-l[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 3328
#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;
inline void read(int &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;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}


int main() {
	int n,k;read(k);
	if(k==1){printf("1\n1\n");return 0;}
	n=(k+3)/4*2;printf("%d\n",n);
	rep(i,1,n){rep(j,1,n){int x=(i+j)%n+1+(i&1?n:0);printf("%d ",x<=k?x:x-n);}puts("");}
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s,t;cin>>s>>t;
  int a,b;cin>>a>>b;
  string u;cin>>u;
  if(s==u)a--;
  else if(t==u)b--;
  cout<<a<<" "<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

int x;

signed main() {
  init_ios();
  cin >> x;
  int res = 1000*(x/500);
  x %= 500;
  res += 5*(x/5);
  cout<<res<<"\n";
}

Measured memory_bytes: 256
/*　　　　　　　{:i:i:|i:i:/l/l--　 　 　--l/li:i:i|i:i:i:i}
　　　　　　 　 {:rx|:i:i ィi芥ミ 　 　 .ィi芥ミｉ:ｉ|ﾍ:i:i:}
.　　　 　 　 　 ｛ﾏ|ｉ:  {::’:} 　 　 　{:‘::} :ｉ:i:|〉｝:/
　　 　 　 　 　 乂|:i:| ｀¨¨¨¨´ 　 　　｀¨¨¨´  :i:ｉ:|ｼ/
　 　 　 　 　 　 ﾉ:|:i|　　　　　　′　　　 　   |:i:i:|ﾂ
　　　　　　　　/:/|:i:| ､　　　 　_ _ 　　　　  |:i:i:|
　 　 　　 　 /:/ .|:i:|/ ＼　　　 　 　     ｨ〔|:i:/
　　 　 　  　 〈;/ く刈＿ 个 　   -   　＜}　./|/_〉
　　     　　 r-っ'~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ~ﾞ|___
　　 　     /／ニつ　　　　　　 ､　　　　　　　ノﾆﾆ　＼
.　　　     |　　ニ⊃ 　./　/　 ──   /　/　　..⊆ﾆﾆ　　:|
.　　　     |　　丁´　 /|￣|￣  ─‐ /|￣|￣ 　 .￣|丁 　|
.　　　     |　　ﾉ.  　 |￣|￣  ─‐  |￣|￣ 　 　.|八 　|
.　　　     |　　||. 　 |￣|￣ |￣| |￣|￣ 　   .|　|
.　 　 　   |  　||   　￣￣￣　￣ 　￣￣￣　　  .|　|  |
.　 　 　  　    ||＿＿＿＿＿＿＿＿＿＿＿＿______|__　　 ',
　 　      ,′　 | ７ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ}  ,′
.　　     {　　　|/　}ﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆﾆ{/ 　 　
*///讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐讐。
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

using namespace std;

#define rep(a) _rep(0,int(a))
#define repj(a) for(int j=0;j<int(a);j++)
#define _rep(a,b) for(int i=int(a);i<int(b);i++)
#define ll long long
#define fst first
#define snd second
#define pf(b) printf("%.12f\n",(double)b)
#define _GLIBCXX_DEBUG
#define int long long


//factorial(練習)　階乗
int fact(int n) {
	int a = 1;
	for (int i = 1;i <= n;i++) a *= i;
	return a;
}
int sa(int n, int m) {      //差！
	if (n < m)return m - n;
	else return n - m;
}

int n;
signed main() {
	cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)cout << "hon" << endl;
	else if (n == 3)cout << "bon" << endl;

	else cout << "pon" << endl;
}

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

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for (int i = 0; i < m; i++){
        cin >> b[i];
    }

    int ans = 0;
    int a;

    for (int i = 0; i < n; i++){
        int sum = 0;
        for (int j = 0; j < m; j++){
            cin >> a;
            sum += a*b[j];
            }
        if ( sum + c > 0){
                ans++;
            }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = input()

data = []

for i in range(N):
    A,B = map(int,raw_input().split())
    C = A+B
    data.append([C,A,B])

data.sort()

ans = 0
flag = True

while N > 0:
    if flag:
        ans += data[N-1][1]
        flag = False
    else:
        ans -= data[N-1][2]
        flag = True
    N -= 1

print ans

Measured memory_bytes: 23940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

bool prime(int n){
	if(n<=1)return false;
	for(int i=2; i<=sqrt(n); i++)
		if(n%i == 0)return false;
	return true;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n;
	cin >> n;
	int suma = n;
	while(!prime(suma)){
		suma++;
	}
	cout << suma << endl;
	return 0;
} 




Measured memory_bytes: 3668
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a%b==0)printf("-1\n");else printf("%d\n",a);
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>

using namespace std;

int price(int a,int b,int c)
{
	int na=a/200,nb=b/300,nc=c/500;
	int pa=1520*(na/5)+380*(na%5);
	int pb=1870*(nb/4)+550*(nb%4);
	int pc=2244*(nc/3)+850*(nc%3);
	return pa+pb+pc;
}

int main()
{
	int g;
	while(scanf("%d",&g),g){
		int pmin=10000000;
		for(int c=0;c<=g/500*500;c+=500){
			for(int b=0;b+c<=g;b+=300){
				int a=g-(b+c);
				if(a%200==0){
					pmin=min(pmin,price(a,b,c));
				}
			}
		}
		printf("%d\n",pmin);
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int acgt(char x){
    if(x == 'A'||x == 'C'||x == 'G'||x == 'T'){
        return 1;
    }else{
        return 0;
    }
}

int main(void){
    char s[10];
    scanf("%s", &s);
    int max = 0;
    int count = 0;
    for(int i = 0;i < 10;i++){
        if(acgt(s[i])){
            count++;
        }else{
            if(count > max)max = count;
            count = 0;
        }
    }
    if(count > max)max = count;
    printf("%d\n", max);
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N, X;
  scanf("%d %d", &N, &X);
  int ans = N;
  vector<int> materials(N);
  int least = INF, sum = 0;
  for (int i = 0; i < N; ++i) {
    int m;
    scanf("%d", &m);
    materials[i] = m;
    sum += m;
    least = min(least, m);
  }

  X -= sum;
  ans += (X / least);
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
typedef long long ll;
const int MAXN = 100000;
struct node{
	node *ch[2];
}pl[MAXN + 5], *NIL=&pl[0], *ncnt=&pl[0], *root=&pl[0];
ll lowbit(ll x) {return x & (-x);}
void insert(char *S) {
	int len = strlen(S); node *nw = root;
	for(int i=0;i<len;i++) {
		if( nw->ch[S[i]-'0'] == NIL )
			nw->ch[S[i]-'0'] = (++ncnt), ncnt->ch[0] = ncnt->ch[1] = NIL;
		nw = nw->ch[S[i]-'0'];
	}
}
ll res; char s[MAXN + 5];
void dfs(node *rt, ll l) {
	if( rt->ch[0] == NIL && rt->ch[1] == NIL )
		return ;
	if( rt->ch[0] == NIL ) res ^= lowbit(l);
	else dfs(rt->ch[0], l-1);
	if( rt->ch[1] == NIL ) res ^= lowbit(l);
	else dfs(rt->ch[1], l-1);
}
int main() {
	root->ch[0] = root->ch[1] = NIL;
	int N; ll L; scanf("%d%lld", &N, &L);
	for(int i=1;i<=N;i++)
		scanf("%s", s), insert(s);
	dfs(root, L);
	if( res ) puts("Alice");
	else puts("Bob");
}

Measured memory_bytes: 4224
import java.util.*;

class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

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

    if (Math.abs(a - b) < k) {
      for (int i = a; i <= b; i++) {
        System.out.println(i);
      }
      return;
    }

    Set<Integer> s = new TreeSet();

    for (int i = 0; i < k; i++) {
      s.add(a + i);
    }
    for (int i = k; i >= 1; i--) {
      s.add(b - i + 1);
    }

    for (Integer i : s) {
      System.out.println(i);
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
        cout<<"0"<<endl;
    else
    {
        b=b*2;
        if(a>b)
            cout<<a-b<<endl;
        else
            cout<<"0"<<endl;
    }
}


Measured memory_bytes: 3568
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <tuple>
# include <functional>
# include <utility>
# define INF 1000000000
# define MOD 1000000000+7
using namespace std;

int main() {
	vector<int> v;
	int n;
	cin >> n;
	int a;
	if (n % 2 == 0) {
		for (int i = 1; i <= n; i++) {
			cin >> a;
			if (i % 2 == 0) {
				v.insert(v.begin(), a);
			}
			else {
				v.emplace_back(a);
			}
		}
	}
	else {
		for (int i = 1; i <= n; i++) {
			cin >> a;
			if (i % 2 == 1) {
				v.insert(v.begin(), a);
			}
			else {
				v.emplace_back(a);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << v[i] << " ";
	}
	cout << endl;
}



Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;
	int a[114514] = {};
	for (int i = 0; i < n; i++) { int k; cin >> k; a[k]++; }
	if (n % 2 == 1) {
		if (a[0] == 1) {
			for (int i = 2; i < (n - 1); i += 2) 
				if (a[i] != 2)goto heaven;
		}
		else goto heaven;
		long long ans = 1;
		for (int i = 0; i < (n - 1) / 2; i++) { ans *= 2; ans %= 1000000007; }
		cout << ans << endl;
	}
	else {
		for (int i = 1; i < n; i += 2) { if (a[i] != 2)goto heaven; }
		long long ans = 1;
		for (int i = 0; i < n / 2; i++) { ans *= 2; ans %= 1000000007; }
		cout << ans << endl;
	}
	return 0;
heaven:cout << "0\n"; return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int a[15], memo[15][10010];
int need[] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
int dp(int pos, int sisa)
{
	int ret;
	if(sisa==0)
		return 0;
	if (pos==0)
		return -1000000000;
	if (memo[pos][sisa] != -1)
		return memo[pos][sisa];
	ret = dp(pos - 1, sisa);
	if (sisa >= need[a[pos]])
		ret = max(ret, dp(pos,sisa-need[a[pos]])+1);
	memo[pos][sisa] = ret;
	return ret;
}
int main()
{
	int n, m, ans;
	cin>>n>>m;
	for (int i = 1; i <= m; i++)
		cin>>a[i];
	sort(a + 1, a + m + 1);
	memset(memo, -1, sizeof (memo));
	ans=dp(m,n);
	for(int i = 1; i <= ans; i++)
	{
		while (dp(m,n-need[a[m]])!=ans-i)
			m--;
		cout<<a[m];
		n-=need[a[m]];
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1024
a,b=map(int,input().split())
s=input()
count=0

for i in range(len(s)):
  if i==a:
    if s[a]=="-":
      count+=1
  else:
    if s[i]=="0" or s[i]=="1" or s[i]=="2" or s[i]=="3" or s[i]=="4" or s[i]=="5" or s[i]=="6" or s[i]=="7" or s[i]=="8" or s[i]=="9":
      count+=1
      
print("Yes"if count==len(s) else"No")

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

void swap(int& x, int& y){
   int tmp = x;
   x = y;
   y = tmp;
}

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if ( a > b ) swap(a, b);
  if ( b > c ) swap(b, c);
  if ( a > b ) swap(a, b);
  cout << a << " " << b << " " << c << endl;
  return 0;
}


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

public class Main {
    public static void main(String[] args) throws Exception {
        /*new Thread(null, new Runnable() {
            @Override
            public void run() {
                try {
                    new Solver().solve();
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }, "Solver", 1l << 30).start();*/

        new Solver().solve();
    }
}

class Solver {
    IO io = new IO(System.in, System.out);

    int N;
    String A, B, C;

    void solve() throws Exception {
        int i, j, k;

        N = io.nextInt(); A = io.next(); B = io.next(); C = io.next();

        int ans = 0;
        HashSet<Character> set = new HashSet<>();
        for (i = 0; i < N; ++i) {
            set.clear();
            set.add(A.charAt(i)); set.add(B.charAt(i)); set.add(C.charAt(i));
            ans += set.size() - 1;
        }

        io.println(ans);

        io.flush();
    }
}


class IO {
    static byte[] buf = new byte[2048];
    static int index, total;
    static InputStream in;
    static BufferedWriter bw;


    IO(InputStream is, OutputStream os) {
        try {
            in = is;
            bw = new BufferedWriter(new OutputStreamWriter(os));
        } catch (Exception e) {
        }
    }

    IO(String inputFile, String outputFile) {
        try {
            in = new FileInputStream(inputFile);
            bw = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(outputFile)));
        } catch (Exception e) {
        }
    }

    int scan() throws Exception {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0)
                return -1;
        }
        return buf[index++];
    }

    String next() throws Exception {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan())
            sb.append((char) c);
        return sb.toString();
    }

    int nextInt() throws Exception {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    long nextLong() throws Exception {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+')
            c = scan();
        for (; c >= '0' && c <= '9'; c = scan())
            val = (val << 3) + (val << 1) + (c & 15);
        return neg ? -val : val;
    }

    void print(Object a) throws Exception {
        bw.write(a.toString());
    }

    void println() throws Exception {
        bw.write("\n");
    }

    void println(Object a) throws Exception {
        print(a);
        println();
    }

    void flush() throws Exception {
        bw.flush();
        bw.close();
    }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
//#define ll long long int
#define p push_back
#define mp make_pair


int main()
{
    int t=1;
    t=1;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        map<int,int>m;
        long long int sum=0;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
            m[a[i]]++;
            sum+=a[i];
        }
       // cout<<"total  "<<sum<<endl;
        int q;
        cin>>q;
        while(q--)
        {
            int val,chg;
            cin>>val>>chg;

               sum= sum+ (chg-val)*m[val];
               // cout<<"changed "<<sum<<endl;
                m[chg]= m[chg]+m[val];
                 m[val]=0;


            cout<<sum<<endl;

        }

    }

}



Measured memory_bytes: 8464
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		execute16_1();
	}
	
	private static void execute16_1() {
		try (Scanner sc = new Scanner(System.in)) {
			
			int n = sc.nextInt();
			
			long[] dp = new long[n+1];
			
			dp[0]=1;
			
			long ans = 0;
			
			for(int i=2;i<=n;i++) {
				int x=i+i;
				while(n>=x) {
					dp[x]++;
					x+=i;
				}
			}

			ans+=1;
			for(int i=2;i<n+1;i++) {
				ans+=i*(dp[i]+2);
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 106808
using System;
using System.Linq;
public class Program {
  public static void Main() {
    int n = int.Parse(Console.ReadLine());
    int[] array = Console.ReadLine().Split(' ').Select(int.Parse).OrderByDescending(x => x).ToArray();
    Console.WriteLine(array[0] - array[n-1]);
  }
}


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

int main() {
	string str_in;
	int count=0;
	int ans[1000];
	int a=int('0');

	for(int i=0; i<1000; i++) ans[i] = 0;

	while(true) {
		getline(cin, str_in);
		
		if(str_in == "0") break;

		for(int i=0; i<str_in.size(); i++) {
			ans[count] += (int)str_in[i] - a;
		}

		count++;
	}

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

	return 0;
	
}


Measured memory_bytes: 3168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	int ans=700;
	if(s[0]=='o')ans+=100;
	if(s[1]=='o')ans+=100;
	if(s[2]=='o')ans+=100;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
D, N = map(int,input().split())
ls = [0]*2000000
for i in range(1,2*10**6):
    if i % 100 == 0:
        ls[i] = 1
    if i % 10000 == 0:
        ls[i] = 2
    if i % 1000000 == 0:
        ls[i] = 3
ii = 0
for i in range(1,2*10**6):
    if ls[i] == D:
        ii += 1
    if ii == N:
        ans = i
        break
print(ans)

Measured memory_bytes: 24712
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r1 = sc.nextDouble();
		double r2 = sc.nextDouble();
		System.out.println(1 / (1 / r1 + 1 / r2));
	}
}

Measured memory_bytes: 24660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    // j-i = A[i]+A[j]
    // j-A[j] = i+A[i]
    // それぞれをハッシュに登録する
    map<ll,ll> P,M;
    rep(i,N){
        P[i+1+A[i]]++;
        M[i+1-A[i]]++;
    }
    ll ans = 0;
    rep(i,N){
        // ペアを探す
        ll tmp = 0;
        tmp += P[i+1-A[i]];
        tmp += M[i+1+A[i]];
        ans+=tmp;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 50060
#include <iostream>
#include <cmath>
#include <bits/stdc++.h>
#include <algorithm>
#include <complex>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PI 3.14159265358979311600
#define loop(i, n) for(int i = 0; i < n; i++)
#define loop1(i, a, n) for(int i = a; i < n; i++)
using namespace  std;

using ll = long long;
const ll mod = 1e9 + 7;
typedef pair<ll, ll> pairs;
typedef complex<ll> G;
const int q=2e5+5;
#define x first
#define y second
const int INF = 1e9;

void done() {
    int n, k;
    cin >> n >> k;
    vector<int>a(n+1);
    for(int i =1;i <= n;i++) {
        cin >> a[i];
    }
    vector<int>pos;
    int ok = 0;
    for(int i =2;i < n;i++) {
        if(a[i] > a[i-1] && a[i] > a[i+1])pos.push_back(i);
    }
    int cnt = 0, d = 1, ans = 1;
    for(int i=0, j=0;i < pos.size();i++) {

        int q = pos[i];
        while((pos[j]-q)+2 <= k && j < pos.size()) {
            j++;
        }
        if(j-i > d) {
            ans = pos[i]-1;
            cnt = j-i+1;
            d = j-i;
            ok = 1;
        }
    }
    cout << cnt << " " << ans << '\n';

}
void solve() {
    int n;cin >> n;
    vector<string>s(n);
    for(int i=0;i < n;i++) {
        cin >> s[i];
    }
    int a = 0, b = 0, c = 0, d = 0;
    for(int i=0;i < n;i++) {
        if(s[i]=="AC")a++;
        if(s[i]=="WA")b++;
        if(s[i]=="TLE")c++;
        if(s[i]=="RE")d++;
    }
    cout << "AC x " << a << '\n';
    cout << "WA x " << b << '\n';
    cout << "TLE x " << c << '\n';
    cout << "RE x " << d << '\n';
}
void another() {



}
void test_case() {
    int t;
    cin >> t;
    while(t--)done();
}
int main() {

     fast;
    solve();

}



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int combination(int a, int b) {
    int u = 1, d = 1;

    rep(0, b) u *= (a - i);
    rep(1, b + 1) d *= i;

    return u / d;
}

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

    cout << (combination(n, 2) + combination(m, 2)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mx 1e18
void solve()
{
    ll n,m,j,y,i,k,x,d,c=0,z,p,q;
    string s;
    cin>>s;
    ll l=s.size();
    if(s[l-1]=='s')cout<<s<<"es";
    else cout<<s<<"s";

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


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  cout << fixed << setprecision(10) << 1.0 * n * n * n / 27 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define endl '\n'
#define ll long long
#define inf 1000000007
int main()
{
	fastio;
	#ifdef APNA_IO
		freopen("input.txt" , "rt" ,stdin);
		freopen("output.txt" , "wt" ,stdout);
	#endif
	ll n,k=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='R')
			k++;
	}
	if(k>n-k)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;


	return 0;
}




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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
ll K;

int main()
{
	scanf("%d%lld",&N,&K);
	vector< pair<ll,ll> > A(N);
	FOR(i,0,N){
		scanf("%lld%lld",&A [i].first,&A [i].second);
	}
	sort(A.begin(),A.end());

	ll curr = 1;
	FOR(i,0,N){
		if(curr + A [i].second > K){
			printf("%lld\n",A [i].first);
			return 0;
		}
		else{
			curr += A [i].second;
		}
	}

	return 0;
}


Measured memory_bytes: 1792
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        string[]S = new string[n];
        for (int i = 0; i < n; i++)
        {
            S[i] = sc.Next();
        }
        
        var arr = new int[255];
        for (char c = 'a'; c <= 'z'; c++)
        {
            arr[c] = int.MaxValue;
        }

        foreach (string s in S)
        {
            int[]tmp = new int[255];
            foreach (char c in s)
            {
                tmp[c]++;
            }
            for (char c = 'a'; c <= 'z'; c++)
            {
                arr[c] = Math.Min(arr[c],tmp[c]);
            }
            
        }

        string ans = "";
        
        for (char c = 'a'; c <= 'z'; c++)
        {
            ans += new string(c, arr[c]);
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 11092
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 ans = (int) Math.ceil( (double)(b - 1) / (a - 1));
        System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
typedef pair <int, int> P;

class UnionFind {
    vector<int> par;
    int n;

public:
    UnionFind(int n) : par(n, -1) {}

    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

vector <int> xc[100005], yc[100005];

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

    int n;
    cin >> n;

    UnionFind uf(n);
    vector <int> x(n), y(n);
    vector <P> X(n), Y(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        X[i] = P(x[i], i);
        Y[i] = P(y[i], i);
    }

    sort(X.begin(), X.end());
    for (int i = 0; i < n - 1; i++) {
        if (X[i].first == X[i+1].first) {
            uf.unite(X[i].second, X[i+1].second);
        }
    }

    sort(Y.begin(), Y.end());
    for (int i = 0; i < n - 1; i++) {
        if (Y[i].first == Y[i+1].first) {
            uf.unite(Y[i].second, Y[i+1].second);
        }
    }

    for (int i = 0; i < n; i++) {
        int par = uf.find(i);
        xc[par].push_back(x[i]);
        yc[par].push_back(y[i]);
    }

    ll ans = -n;
    for (int i = 0; i < n; i++) {
        if (uf.find(i) != i) continue;

        sort(xc[i].begin(), xc[i].end());
        xc[i].erase(unique(xc[i].begin(), xc[i].end()), xc[i].end());

        sort(yc[i].begin(), yc[i].end());
        yc[i].erase(unique(yc[i].begin(), yc[i].end()), yc[i].end());

        ans += xc[i].size() * yc[i].size();
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8832
s = str(input())
k = int(input())

#a = []
#for i in range(len(s)):
#    a.append([int(s[i]),int(s[i])**k])
#print(a)

a = 1
ocount = 0
for i in range(len(s)):
    t = int(s[i])
    if t != 1:
        a = t
        break
    else:
        ocount += 1

if k <= ocount:
    print(1)
else:
    print(a)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
using namespace std;
int main()
{
	int k[100]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int y;
	cin>>y;
	cout<<k[y-1];
	re 0;
}

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

using namespace std;

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

    int ans = B;

    if(A <= 12 && 6 <= A){
        ans *= 1/2.0; 
    }else if(A <= 5){
        ans = 0;
    }
    
    cout << ans << endl;
    return 0;
}

    

Measured memory_bytes: 256
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        x: usize, y: usize, z: usize,
    }

    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define testcase int t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
#define ub upper_bound // '>'
#define lb lower_bound // '>='
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast
    ll h,w;
cin>>h>>w;
ull res=h*w;
if(h==1||w==1)
    res=1;
else
{
    if(res%2==0)
    res/=2;
else
    res=res/2+1;
}
cout<<res<<endl;
return 0;
}







Measured memory_bytes: 256
N,M,X,Y = input().split()

x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

x_list.append(int(X))
y_list.append(int(Y))

if int(max(x_list)) < int(min(y_list)):
    print("No War")
else:
    print("War")

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

int main(){
    using namespace std;

    unsigned long N, K;
    char s[5000];
    scanf("%lu%lu %s", &N, &K, s);
    string S(s, s + strlen(s));

    string T(S.begin(), S.end());
    auto c = *min_element(S.begin(), S.end());
    (T += string(S.rbegin(), S.rend())) += '$';
    vector<unsigned long> L;
    for(unsigned long i = N * 2, p = 0; i--; ){
        if(T[i] != T[i + 1])p = T[i] < T[i + 1];
        if(p && i < N && T[i] == c)L.push_back(i);
    }
    for(unsigned long i : L)S = min(S, string(T.begin() + i, T.begin() + i + N));
    unsigned long k{static_cast<unsigned long>(find_if_not(S.begin(), S.end(), [&c](auto i){return i == c;}) - S.begin())};
    --K;
    unsigned long l = K > 13 ? N : min(N, (k << K) - k);
    string A(l, c);
    A += string(S.begin(), S.begin() + N - A.size());

    puts(A.data());

    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int c1,c0;
    c1 = 0;
    c0 = 0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='0'){
            c0++;
        }else{
            c1++;
        }
    }
    int cmin = min(c1,c0);
    cout << 2*cmin << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    Rep (i, N) cin >> a[i];

    vector<bool> dp(K+1, false);
    Rep (i, K+1) {
        for (auto e : a) {
            if (i - e < 0) continue;
            if (!dp[i-e]) {
                dp[i] = true;
                break;
            }
        }
    }

    // for (auto e : dp) cout << e << endl;

    if (dp[K]) cout << "First\n";
    else cout << "Second\n";


}

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

using namespace std;

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i)
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i)

#define DEBUG(...) fprintf(stderr , __VA_ARGS__)

template<typename T>inline int chkmin(T &x , const T &y){ return x > y ? x = y , 1 : 0; }
template<typename T>inline int chkmax(T &x , const T &y){ return x < y ? x = y , 1 : 0; }

template<typename T>inline T read(T &f)
{
	f = 0 ; int x = 1 ; char c = getchar();
	while(!isdigit(c)) x = c == '-' ? -1 : 1 , c = getchar();
	while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
	return f *= x;
}

using int64 = long long;
using uint64 = unsigned long long;

const int N = 400 + 5;

const double eps = 1e-7;

struct Node
{
	int64 x , y; double theta;
	int operator < (const Node &rhx) const
	{
		return theta < rhx.theta;
	}
} A[N];

int n ;

int64 sX[N] , sY[N];

int main()
{
	// freopen("in" , "r" , stdin);
	read(n);
	rep(i , 1 , n)
	{
		read(A[i].x);
		read(A[i].y);
		A[i].theta = atan2(A[i].y , A[i].x);
	}
	sort(A + 1 , A + 1 + n);
	rep(i , 1 , n) A[i + n] = A[i];
	int64 Ans = 0;
	rep(i , 1 , n * 2)
	{
		sX[i] = sX[i - 1] + A[i].x;
		sY[i] = sY[i - 1] + A[i].y;
	}
	rep(i , 1 , n)
	rep(j , i , i + n - 1)
	{
		int64 X = sX[j] - sX[i - 1];
		int64 Y = sY[j] - sY[i - 1];
		chkmax(Ans , X * X + Y * Y);
	}
	printf("%.15lf\n" , sqrt(Ans)); // ret); // sqrt(Ans));
	// printf("%.12f\n" , fabs(static_cast<long double>(Ans) - ret * ret));	
	return 0;
}

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

#define F first
#define S second
#define pb(x) push_back(x)
#define forr(i, a, b) for(int i = a;i <= b;i++)
#define sz(s) int(s.size())
#define ioi ios_base::sync_with_stdio(false)
#define all(x) x.begin(), x.end()
#define tie cin.tie(nullptr);cout.tie(nullptr);
#define int long long

using namespace std;

main(){ioi;tie;
	
	int a, b;
	cin >> a >> b;
	if(a == 1|| b == 1) return cout << 1, 0;
	cout << ((a * b) + 1 >> 1);
}

//Coded by LoliThief or ProRedWood or Lolivillian;



Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;


class Node {
   public:
   // long vertex;
   vector<pair<long, long>> to;
   vector<long> toind;
   // vector<long> length;
   // int grp;
   bool seen = false;
   bool finish = false;
   Node(){;};
};
vector<Node> vGr;

void dfs(int vertex, int col) {
   if (vGr[vertex].seen) return;
   vGr[vertex].seen = true;
   int col_this = 0;
   // for (auto& el : vGr[vertex].to) {
   for (auto itr =vGr[vertex].to.begin(); itr != vGr[vertex].to.end();itr++) {
      if (vGr[(*itr).first].seen) continue;
      if (col_this == col) col_this++;
      (*itr).second = col_this;
      dfs((*itr).first,col_this);
      col_this++;
   }
   vGr[vertex].finish = true;
   return;
};

int main(void) {
   int N;
   cin>>N;
   vGr.resize(N);
   rep(i,0,N-1) {
      ll a,b;
      cin>>a>>b;
      vGr[a-1].to.push_back(make_pair(b-1,-1));
      vGr[a-1].toind.push_back(i);
      vGr[b-1].to.push_back(make_pair(a-1,-1));
      vGr[b-1].toind.push_back(i);
   }
   dfs(0,-1);
   vector<ll> ans(N-1,-1);
   rep(i,0,N) {
      rep(j,0,vGr[i].to.size()) {
         if (vGr[i].to[j].second>=0) ans[vGr[i].toind[j]] = vGr[i].to[j].second;
      }
   }
   cout<<(*max_element(ans.begin(),ans.end()))+1<<endl;
   rep(i,0,N-1) cout<<ans[i]+1<<endl;


   return 0;
}

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

using namespace std;

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

    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        cout << s << "\n" << s << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
import Data.List
import Data.Ord

takePairs []  = []
takePairs [_] = []
takePairs (a:b:xs)
  | a == b = a : takePairs xs
  | otherwise = takePairs (b:xs)

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- map read . words <$> getLine :: IO [Int]
    let a' = takePairs . concat
           . filter ((2<=) . length) . group . sortOn Down $ a
    print $ if length a' < 2
               then 0 else product $ take 2 a'

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

int main() {
    int e_zero_cnt = 0, e_one_cnt = 0, o_zero_cnt = 0, o_one_cnt = 0;
    string s;

    cin >> s;

    for (int i = 0; i < s.length(); i += 2) {
        if (s[i] == '0') {
            e_zero_cnt++;
        } else {
            e_one_cnt++;
        }
    }

    for (int i = 1; i < s.length(); i += 2) {
        if (s[i] == '0') {
            o_zero_cnt++;
        } else {
            o_one_cnt++;
        }
    }

    int ans = min(e_zero_cnt + o_one_cnt, e_one_cnt + o_zero_cnt); 

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (a == -1)
        return b;
    else if (b == -1)
        return a;
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

template <class T>
class SegmentTree {
  private:
    int n = 1;
    vector<T> segtree;
    function<T(T, T)> operation;
    T ie;

    T _query(int a, int b, int k, int l, int r) {
        if (a >= r || b <= l)
            return ie;
        else if (a <= l && b >= r)
            return segtree[k];
        else {
            int vl = _query(a, b, 2 * k + 1, l, (l + r) / 2);
            int vr = _query(a, b, 2 * k + 2, (l + r) / 2, r);
            return operation(vl, vr);
        }
    }

  public:
    SegmentTree(vector<T> v, function<T(T, T)> _operation, T _ie)
        : operation(_operation), ie(_ie) {
        while (v.size() > n)
            n *= 2;
        segtree.resize(2 * n - 1, ie);
        for (int i = 0; i < v.size(); i++)
            segtree[i + n - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            segtree[i] = operation(segtree[2 * i + 1], segtree[2 * i + 2]);
    }

    T operator[](int i) {
        return segtree[i + n - 1];
    }

    void update(int i, T x) {
        i += n - 1;
        segtree[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            segtree[i] = operation(segtree[2 * i + 1], segtree[2 * i + 2]);
        }
    }

    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }
};

signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    auto f = [](int a, int b) -> int { return GCD(a, b); };
    SegmentTree<int> segtree(a, f, -1);
    int res = segtree.query(0, n);
    res = max(segtree.query(1,n),segtree.query(0,n-1));
    for (int i = 1; i < n; i++)
        chmax(res, GCD(segtree.query(0, i), segtree.query(i + 1, n)));
    cout << res << endl;
}

Measured memory_bytes: 5056
from collections import deque
import sys

c=sys.stdin

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

    for i in range(N):
        order=c.readline()
        if order[6]==" ":
            if order[0]=="i":
                q.appendleft(int(order[7:]))
            else:
                try :
                    q.remove(int(order[7:]))
                except:
                    pass
        else:
            if order[6]=="F":
                q.popleft()
            else:
                q.pop()
    print(*list(q))

if __name__ == "__main__":
    main()


Measured memory_bytes: 45956
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string s, t;
    cin >> s >> t;

    if ( s.size() == t.size() - 1 and s == t.substr(0, (int) s.size()) ) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
typedef long long ll;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define PI pair<int,int>

const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const ll mod = (ll)(1e9 + 7);
const int N = 100010;

int n, m;
int ans[N];
vector<vector<int> > G;

int main() {    
    while (cin >> n >> m) {
        memset(ans, -1, sizeof (ans));
        G.resize(n + 1);
        for (int i = 1; i <= n; ++i) G[i].clear();
        for (int i = 0; i < m; ++i) {
            int u, v; cin >> u >> v;
            G[u].push_back(v);
            G[v].push_back(u);
        }

        queue<int> Q;
        Q.push(1); ans[1] = 0;
        while (!Q.empty()) {
            int u = Q.front(); Q.pop();
            for (auto& v: G[u]) if (ans[v] == -1) {
                ans[v] = u; Q.push(v);
            }
        }
        int ok = 1;
        for (int i = 1; i <= n; ++i) if (ans[i] == -1) {
            ok = 0;
            break;
        }
        if (!ok) cout << "No" << endl;
        else {
            cout << "Yes" << endl;
            for (int i = 2; i <= n; ++i) cout << ans[i] << endl;
        }
    }
    return 0;
}
    


Measured memory_bytes: 10212
x, k, d = map(int, input().split())
dist = k * d
if x > 0:
    rang = x - dist
else:
    rang = x + dist
    
if x > 0 and rang > 0:
    print(rang)
    quit()
elif x <= 0 and rang <= 0:
    print(abs(rang))
    quit()
num1 = list(divmod(x, d))
num2 = [num1[0] + 1, x - d * (num1[0] + 1)]
if num1[0] % 2 == 0:
    num = [num1, num2]
else:
    num = [num2, num1]
    
print(abs(num[k % 2][1]))

Measured memory_bytes: 9236