akhauriyash/Code-Regression huggingface dataset:
#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 RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b;
    cin >> a >> b;

    if ( a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
def kumitate(a,b):
    a,b =max(a,b),min(a,b)
    while b != 0:
        a,b = b,a%b
    return a

N =int(input())
l =[int(i)for i in input().split()]
l =sorted(l)
mini =l[0]
for i in l:
    mini = kumitate(mini,i)
print(mini)

Measured memory_bytes: 14252
import numpy
N = input()
S = raw_input()
acc_sum_w2e = numpy.cumsum([1 if c == 'W' else 0 for c in S])
acc_sum_e2w = numpy.cumsum([1 if c == 'E' else 0 for c in S[::-1]])[::-1]
counts = [acc_sum_w2e[i] + acc_sum_e2w[i] - 1 for i in range(N)]
print min(counts)


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

using namespace std;

int a[2 * 100000];
int lis[2 * 100000];

void dfs(const vector<vector<int>>& edges, int node, vector<int>* state) {
  vector<int>::iterator it = lower_bound(state->begin(), state->end(), a[node]);
  bool extend = it == state->end();
  int original;
  if (extend) {
    state->push_back(a[node]);
  } else {
    original = *it;
    *it = a[node];
  }
  lis[node] = state->size();
  for (int i = 0; i < edges[node].size(); ++i) {
    int n = edges[node][i];
    if (lis[n] == -1) {
      dfs(edges, n, state);
    }
  }
  if (extend) {
    state->pop_back();
  } else {
    *it = original;
  }
}

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

  vector<vector<int>> edges;
  edges.resize(N);
  for (int i = 0; i < N - 1; ++i) {
    int u, v;
    cin >> u >> v;
    edges[u - 1].push_back(v - 1);
    edges[v - 1].push_back(u - 1);
  }

  for (int i = 0; i < N; ++i) {
    lis[i] = -1;
  }
  vector<int> state;
  state.reserve(N);
  dfs(edges, 0, &state);
  for (int i = 0; i < N; ++i) {
    cout << lis[i] << endl;
  }
}

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

const int MAX_H = 1e4 * 3;
const int INF = 1e9;

void chmin(int &a, int b) {
    if (a > b) a = b;
}

int main() {
    int h, n; cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vector<int> min_cost(MAX_H, INF);
    min_cost[0] = 0;
    for (int i = 0; i < h; i++) {
        if (min_cost[i] == INF) continue;
        for (int j = 0; j < n; j++) {
            int damage = a[j];
            int cost = b[j];
            chmin(min_cost[i + damage], min_cost[i] + cost);
        }
    }
    int ans = 1e9;
    for (int i = h; i < MAX_H; i++) {
        chmin(ans, min_cost[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[5];
    for(int i=0;i<5;i++)
        cin>>a[i];
    int ans=0;
    for(int i=0;i<5;i++)
        ans+=a[i]+(10-a[i]%10)%10;
    int mx=0;
    for(int i=0;i<5;i++)
        mx=max(mx,(10-a[i]%10)%10);
    ans-=mx;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C ,D;
    cin >> A >> B >> C >> D;

    if (A + B < C + D){
        cout << "Right" << endl;
    }
    else if (A + B > C + D){
        cout << "Left" << endl;
    }
    else {
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
import sys


def main():
    n = int(input())
    buttons = [int(input()) for _ in range(n)]

    def push(x):
        return buttons[x - 1]

    seq = [push(1)]

    for _ in range(n):
        if seq[-1] == 2:
            print(len(seq))
            return 0
        seq += [push(seq[-1])]

    print(-1)

    return 0


if __name__ == '__main__':
    sys.exit(main())


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

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

	int n;
	cin>>n;
	int ans = 0;
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=n; ++j){
			for(int k=1; k<=n; ++k){
				ans += __gcd(i, __gcd(j,k));
			}
		}
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
  string s;
  cin>>s;
  rep(i,3) cout<<s[i];
return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;



int main(){
    int a, b; cin >> a >> b;
    vector<string> ans;
    int white = 0;
    int black = 0;
    rep(i,50){
        string s = "";
        if(i%2==0){
            rep(j,100){
                if(j%2==0){
                    if(a-1>white){
                        s += '.';
                        white++;
                    }else s += '#';
                }else s += '#';
            }
            ans.push_back(s);
        }else{
            rep(j,100) s += "#";
            ans.push_back(s);
        }
    }
    rep(i,50){
        string s = "";
        if(i%2==1){
            rep(j,100){
                if(j%2==0){
                    if(b-1>black){
                        s += '#';
                        black++;
                    }else s += '.';
                }else s += '.';
            }
            ans.push_back(s);
        }else{
            rep(j,100) s += ".";
            ans.push_back(s);
        }
    }
    cout << 100 << " " << 100 << endl;
    for(auto s : ans) cout << s << endl;
    //cout << ans.size() << endl;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, k = LI()
    s = S()
    s[k-1] = s[k-1].lower()
    print("".join(s))

    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);


  char x, y; cin >> x >> y;
  if(x==y){
    cout<<'=';
  }
  else if(x<y){
    cout<<'<';
  }
  else cout<<'>';
  cout<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		// ?????????????????\????????????
		Scanner sc = new Scanner(System.in);

		while (true) {

			int num = sc.nextInt();
			int sum = sc.nextInt();

			if (num == 0 && sum == 0)
				break;

			// ?????¶????????????????????????????????°??????????????????????????°
			int cnt = 0;

			// ?????¶??????????????????????????????????????????
			for (int pnt1 = 1; pnt1 <= num; pnt1++) {

				for (int pnt2 = pnt1 + 1; pnt2 <= num; pnt2++) {

					for (int pnt3 = pnt2 + 1; pnt3 <= num; pnt3++) {

						if (pnt1 + pnt2 + pnt3 == sum) {

							if (pnt2 == pnt3) {

								cnt += 0;

							} else {

								cnt++;

							}
						}
					}
				}
			}
			System.out.println(cnt);
		}
		sc.close();
	}

}

Measured memory_bytes: 26652
import math as m
from array import *
import sys
import datetime
import calendar

n= int(input())

s = input()
l1= s.split(" ")
s1=l1[0]
s2=l1[1]
for i in range(0,n):
    print(s1[i],end="")
    print(s2[i],end="")
    


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

int main()
{
	int N;
	string s;
	cin >> N;
	cin >> s;
	int i = 1;
	while (i < s.size())
	{

		if (s[i] == s[i - 1]) {

			if (i >= 2) {

				s.erase(i, 1);
			}
			else {
				s = s.substr(i, s.size());

			}
			i = 1;
		}else
		{
			i++;
		}
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 636
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;

int main() {
  int a;
  int b;
  int ans;
  cin >> a >> b;
  ans=a*b;

  if(a>9 | b>9) ans=-1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
# Problem https://atcoder.jp/contests/abc085/tasks/abc085_b
# Python  1st Try
import sys
# from collections import defaultdict
# import heapq,copy
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def solver(cakeTotal, riseSet):
    RISE_MAXSIZE = 100
    result = 0
    # print("riseset={}".format(riseSet))
    bucketList = [0] * RISE_MAXSIZE
    for p in range(0,cakeTotal, +1): # p = position
        weigh = riseSet[p]
        bucketList[weigh-1] = bucketList[weigh-1] + 1
    for p in range(RISE_MAXSIZE):
        if 0 < bucketList[p]:
            result = result + 1
    return result
if __name__ == "__main__":
    N = II()
    DI = list()
    for _ in range(0, N):
        DI.append(II())
    print("{}".format(solver(N, DI)))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <list>
#include <set>
#include <utility> // pair
#include <map>
#include <iostream>
#include <sstream>
#include <algorithm> // sort
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <bitset>
#define PI acos(-1)
typedef long long ll;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 5; 
using namespace std;

int main()
{
	ll x, sum = 100;
	int k = 0;
	scanf("%lld", &x);
	while (sum < x)
	{
		sum = sum * 1.01;
		k++;
	}
	printf("%d\n", k);
	return 0;
}

Measured memory_bytes: 3228
#include<stdio.h>
int main(){
    int A,B,C,K,max,SUM,i;
    
    SUM=0;
    
    scanf("%d%d%d",&A,&B,&C);
    scanf("%d",&K);
    
    
    max = A;
    
    if (max<B) {
        max= B;
    }
    
    if (max<C) {
        max = C;
    }
    
    if (max==A) {
        for (i=0;i<K;i=i+1) {
            A=A*2;
        }
        SUM=A+B+C;
    }else if (max==B) {
        for (i=0;i<K;i=i+1) {
            B=B*2;
        }
        SUM=A+B+C;
    }else if (max==C) {
        for (i=0;i<K;i=i+1) {
            C=C*2;
        }
        SUM=A+B+C;
    }
    
    printf("%d\n",SUM);
    
    
    return 0;
    
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if(a == b) {
    cout << c << endl;
  } else if (b == c) {
    cout << a << endl;
  } else {
    cout << b << endl;
  }
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main()
{
   int n, k;
   cin >> n >> k;
   vector<long long int> pos, neg;
   for (int i = 0; i < n; i++)
   {
      int a;
      cin >> a;
      if (a > 0)
         pos.push_back(a);
      else
         neg.push_back(-a);
   }
   sort(pos.begin(), pos.end());
   sort(neg.begin(), neg.end());
   long long int ans = 1;
   if (k == n)
   {
      for (int i = 0; i < pos.size(); i++)
      {
         ans = (ans * pos[i]) % MOD;
      }

      for (int i = 0; i < neg.size(); i++)
      {
         ans = (ans * -neg[i]) % MOD;
      }
   }
   else if (pos.empty())
   {
      if (k % 2 == 0)
      {
         for (int i = 0; i < k; i++)
         {
            ans = (ans * -neg[neg.size() - 1 - i]) % MOD;
         }
      }
      else
      {
         for (int i = 0; i < k; i++)
         {
            ans = (ans * -neg[i]) % MOD;
         }
      }
   }
   else
   {
      int posIdx = pos.size() - 1;
      int negIdx = neg.size() - 1;
      if (k % 2 == 1)
      {
         ans = pos[posIdx];
         posIdx--;
      }
      for (int i = 0; i < k / 2; i++)
      {
         long long int tmp1 = 0, tmp2 = 0;
         if (posIdx - 1 >= 0)
         {
            tmp1 = pos[posIdx] * pos[posIdx - 1];
         }
         if (negIdx - 1 >= 0)
         {
            tmp2 = neg[negIdx] * neg[negIdx - 1];
         }
         if (tmp1 > tmp2)
         {
            ans = (ans * (tmp1 % MOD)) % MOD;
            posIdx -= 2;
         }
         else
         {
            ans = (ans * (tmp2 % MOD)) % MOD;
            negIdx -= 2;
         }
      }
   }
   cout << (ans + MOD) % MOD << endl;
}

Measured memory_bytes: 5660
N, K = map(int, input().split())
W = [int(input()) for w in range(N)]

def check(p):
    i = 0
    for _ in range(K):
        s = 0
        while s + W[i] <= p:
            s += W[i]
            i += 1
            if i == N:
                return N
    return i

left = 0
right = 100000 * 10000
mid = 0
while 1 < right - left:
    mid = (left + right) / 2
    v = check(mid)
    if v >= N:
        right = mid
    else:
        left = mid

print(int(right))


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

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<size_t> p(N);
  for (size_t i=0; i<N; ++i) {
    scanf("%zu", &p[i]);
    --p[i];
  }

  int res=0;
  for (size_t i=0; i+1<N; ++i) {
    if (i == p[i]) {
      std::swap(p[i], p[i+1]);
      ++res;
    }
  }

  if (p[N-1] == N-1)
    ++res;

  printf("%d\n", res);
}


Measured memory_bytes: 1024
s = input()
t = input()

resolved = False
for i in (range(len(s) - len(t) + 1)):
    sliced = s[len(s)-len(t)-i:len(s)-i]
    matched = True
    for j in range(len(sliced)):
        if sliced[j] != t[j] and sliced[j] != '?':
            matched = False
            break
    if matched:
        resolved = True
        s = s[:len(s)-len(t)-i] + t + s[len(s)-i:]
        break

if resolved:
    print(s.replace('?', 'a'))
else:
    print('UNRESTORABLE')



Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e6 * 2 + 10, INF = 1e9 * 1e9 + 10, MOD = 998244353;

vector<pair<ll, ll>> vec;
vector<ll> pref;
ll dp[SIZE];

ll get_sum(int l, int r) {
	if (l < 0) l = 0;
	if (r < 0) r = -1;

	return pref[r + 1] - pref[l];
}

int main()
{
	fastInp;

	ll n;
	cin >> n;

	ll cnt = 0, ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n % i == 0) ans--;
		ans += (n / i);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3188
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1, dy = y2 - y1;

    cout << x2 - dy << " " << y2 + dx << " " << x1 - dy << " " << y1 + dx << endl;
    
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

bool issosu(int e)
{
    for(int k = 2; k * k <= e; k++ )
    {
        if( e % k == 0 ) return false;
    }
    return true;
}

int getans()
{
    int n; cin >> n;
    vector<int> a(n);
    int maxa = 0;
    rep(i, n) 
    {
        cin >> a[i];
        maxa = max(maxa, a[i]);
    }

    bool setwise = false;

    for( int e = 2; e * e <= maxa; e++ )
    {
        // eが素数か判定
        if( issosu(e) )
        {
            int nextmax = 0;
            int count = 0;
            rep(i, n)
            {
                if( a[i] % e == 0 )
                {
                    count++;
                    while(a[i] % e == 0) a[i] /= e;
                }
                nextmax = max(nextmax, a[i]);
            }
            if( count == n ) return 2;
            if( count > 1 ) setwise = true;
            maxa = nextmax;
        }
    }

    int maxcount = 0;
    map<int, int> m;
    rep(i, n)
    {
        if( a[i] == 1 ) continue;
        m[a[i]]++;
        maxcount = max(maxcount, m[a[i]]);
    }
    if( maxcount == n ) return 2;
    if( setwise || maxcount > 1 ) return 1;
    return 0;
}

int main()
{
    int ret = getans();
    if( ret == 2 )
    {
        cout << "not coprime";
    }
    else if( ret == 1 )
    {
        cout << "setwise coprime";
    }
    else
    {
        cout << "pairwise coprime";        
    }
    return 0;    
}

Measured memory_bytes: 10760
import math

def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shellSort(A,n):
    global cnt
    cnt = 0
    m = int(math.log(n))
    if m < 1:
        m = 1
    G = []
    for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
    G.sort(reverse=True)
    
    for i in range(0,m):
        insertionSort(A,n,G[i])
    print(m)
    for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
    print(cnt)
    for i in range(n):
        print(A[i])

n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)

Measured memory_bytes: 47608
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <math.h>

const long long MOD = 1000000007;

using namespace std;



int main(void) {

    long long i, j;
    long long n, k;
    long long sum = 0;
    long long temp;
    long long min, max;
    long long a, b, c, d;
    string s;
    vector<long long> res;

    cin >> n >> k;

    res.resize(n);

    for (i = 0; i < k; i++) {
        cin >> d;
        for(j = 0; j < d; j++) {
            cin >> temp;
            res[temp - 1]++;
        }
    }


    for (i = 0; i < n; i++) {
        if(res[i] == 0) {
            sum++;
        }
    }

    cout << sum << endl;


    return 0;
}

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

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  int n,m; cin >> n;
  map<string,int> mp;
  rep(i,n){
    string s; cin >> s;
    mp[s]++;
  }
  cin >> m;
  rep(i,m){
    string s; cin >> s;
    mp[s]--;
  }
  string s;
  int maxv = -1000;
  for(auto x: mp){
    if(x.snd > maxv){
      maxv = x.snd;
    }
  }
  if(maxv > 0) cout << maxv;
  else cout << 0;
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef pair<ll,ll> pll;
const ll inf = 99999999999;
const int nax = 2e6 + 7;
int n , m;
ll graph[200][200];
ll dis[200][200];
int main(){
	dhoom;
	int n , m;
	cin >> n >> m;
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			graph[i][j] = inf;
		}
	}
	for(int i = 0 ; i < n ; i++)
		graph[i][i] = 0;
	for(int i = 0 ; i < m ; i++){
		int u , v , w;
		cin >> u >> v >> w;
		graph[u][v] = w;
	}
	for(int k = 0 ; k < n ; k++){
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < n ; j++){
				if(graph[i][k] == inf || graph[k][j] == inf)continue;
				   graph[i][j] = min(graph[i][j] , graph[i][k] + graph[k][j]);
			}
			
		}
	}
	for(int i = 0 ; i < n ; i++){
		if(graph[i][i] < 0)
			return cout << "NEGATIVE CYCLE\n",0;
	}
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ;j++){
			if(j != 0)
				cout << " ";
			if(graph[i][j] >= inf)
				cout << "INF";
			else 
				cout << graph[i][j];
		}
		cout << endl;
	}
    return 0;
}




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

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

int main(){
  int n;
  string s, t;
  cin >> n >> s >> t;

  int count = 2*n;
  string ans;
  rep(i, n){
    ans += s.at(i);
    ans += t.at(i);
  }

  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
 
const int INF = 1 << 28;
 
struct SegmentTree
{
  
  vector< int > small, add;
  int sz;
  
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    small.assign(2 * sz - 1, INF);
    add.assign(2 * sz - 1, 0);
  }
  inline void Merge(int k)
  {
    small[k] = min(small[2 * k + 1] + add[2 * k + 1], small[2 * k + 2] + add[2 * k + 2]);
  }
  inline int RangeMinimumQuery(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return(INF);
    if(a <= l && r <= b) return(small[k] + add[k]);
    int L = RangeMinimumQuery(a, b, 2 * k + 1, l, (l + r) >> 1);
    int R = RangeMinimumQuery(a, b, 2 * k + 2, (l + r) >> 1, r);
    return(min(L, R) + add[k]);
  }
  int RangeMinimumQuery(int a, int b)
  {
    return(RangeMinimumQuery(a, b, 0, 0, sz));
  }
  inline void RangeAdd(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) return;
    if(a <= l && r <= b) {
      add[k] += x;
      return;
    }
    RangeAdd(a, b, x, 2 * k + 1, l, (l + r) >> 1);
    RangeAdd(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    Merge(k);
  }
  void RangeAdd(int a, int b, int x)
  {
    return(RangeAdd(a, b, x, 0, 0, sz));
  }
  inline int BinarySearch(int k, int l, int r, int upd)
  {
    if(k >= sz - 1) return(r);
    const int right = small[2 * k + 2] + add[2 * k + 2] + add[k] + upd;
    if(right >= 2) return(BinarySearch(2 * k + 1, l, (l + r) >> 1, upd + add[k]));
    return(BinarySearch(2 * k + 2, (l + r) >> 1, r, upd + add[k]));
  }
  int BinarySearch()
  {
    return(BinarySearch(0, 0, sz, 0));
  }
};
 
int main()
{
  int N, Q;
 
  scanf("%d %d", &N, &Q);
  char S[300001];
  bool poped[300001] = {};

  scanf(" %s", S);
  SegmentTree tree(N);
  set< int > open;
  priority_queue< int, vector< int >, greater< int > > close;
  for(int i = 0; i < N; i++) {
    tree.RangeAdd(i, i + 1, -INF);
  }
  for(int i = 0; i < N; i++) {
    tree.RangeAdd(i, N, S[i] == '(' ? +1 : -1);
    if(S[i] == ')') close.push(i);
    else open.insert(i);
  }
  while(Q--) {
    int q;
    scanf("%d", &q);
    --q;
    tree.RangeAdd(q, N, S[q] == ')' ? +2 : -2);
    if(S[q] == '(') {
      open.erase(q);
      if(!poped[q]++) close.push(q);
      S[q] = ')';
      int p = close.top(); close.pop();
      poped[p] = false;
      while(S[p] == '(') {
        p = close.top();
        poped[p] = false;
        close.pop();
      }
      printf("%d\n", p + 1);
      tree.RangeAdd(p, N, +2);
      S[p] = '(';
      open.insert(p);
    } else {
      open.insert(q);
      S[q] = '(';
      int pos = *open.lower_bound(tree.BinarySearch());
      printf("%d\n", pos + 1);
      tree.RangeAdd(pos, N, -2);
      S[pos] = ')';
      open.erase(pos);
      if(!poped[pos]++) close.push(pos);
    }
  }
}

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

int main() {
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	int L[n], R[n];
	fill(L, L+n, 0);
	fill(R, R+n, 0);
	for (int i = 0, x = 1; x <= k; i++) {
		if (s[i] == 'x') continue;
		L[i] = x;
		x++;
		i += c;
	}
	for (int i = n-1, x = k; x >= 1; i--) {
		if (s[i] == 'x') continue;
		R[i] = x;
		x--;
		i -= c;
	}
	for (int i = 0; i < n; i++) {
		if (L[i] != 0 && L[i] == R[i]) cout << i+1 << endl;
	}
	return 0;
}

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

typedef long long int ll; 
#define int long long
const int mod = 1e9 + 7;
const int mex = 1e6 + 0;
int fact[mex+5], inv[mex+5];

int toPower(int a, int p){
    int res = 1;
    while (p){
        if (p & 1) res = ll(res) * a % mod;
        p >>= 1; a = ll(a) * a % mod;
    }
    return res;
}

int Inv(int x){ 
    return toPower(x, mod - 2); 
}

void initialize(){
    inv[0] = Inv(fact[0]);fact[0] = inv[0] = 1;
    
    for(int i = 1; i < mex; i++){
        fact[i] = (ll(i) * fact[i - 1]) % mod;
        inv[i] = Inv(fact[i]);
    }
}

int C(int n, int k){
    if (n < 0 || k < 0 || k > n) return 0;
    return ll(fact[n]) * inv[k] % mod * inv[n - k] % mod;                 
}

signed main(){
    initialize();
    int n, m; cin >> n >> m;
    
    if((n+m)%3){
        cout << "0\n"; return 0;
    }
    
    int r = n - (n+m)/3;
    int ans = C((n+m)/3,r);
    cout << ans << '\n';
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000003;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


int main(){
    int n;cin >> n;
    string s;cin >> s;
    vector<vector<int>> dp(n+1,vector<int> (10,0));
    vector<vector<int>> dq(n+1,vector<int> (10,0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            dp[i+1][j] = dp[i][j] | (s[i] - '0' == j);
        }
    }
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 10; j++) {
            dq[i][j] = dq[i+1][j] | (s[i] - '0' == j);
        }
    }
    set<int> st;
    for (int i = 1; i < n - 1; i++) {
        int t = s[i] - '0';
        for (int j = 0; j < 10; j++) {
            for (int k = 0; k < 10; k++) {
                if(!dp[i][j]||!dq[i+1][k]) continue;
                int p = j * dp[i][j] * 100 + t * 10 + dq[i+1][k] * k;
                st.insert(p);
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 4480
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Long, Long> map = new HashMap<>();
        long sum = 0;
        for (int i = 0; i < n; i++) {
            Long key = sc.nextLong();
            Long count = map.getOrDefault(key, 0L);
            map.put(key, ++count);
            sum += key;
        }
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            Long b = sc.nextLong();
            Long c = sc.nextLong();

            Long bCount = map.getOrDefault(b, 0L);
            long tmp = sum - (b * bCount) + (c * bCount);
            System.out.println(tmp);
            map.put(b, 0L);
            long cCount = map.getOrDefault(c, 0L);
            map.put(c, bCount + cCount);
            sum = tmp;
        }
    }
}

Measured memory_bytes: 65860
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];

	vector<pair<int, int>> l, r;
	for (int i = 0; i < N; i++) {
		int sum = 0, m = 0;;
		for (const auto &c : S[i]) {
			sum += (c == '(') - (c == ')');
			chmin(m, sum);
		}
		if (sum > 0) l.emplace_back(m, sum);
		else {
			int sum = 0, m = 0;;
			reverse(S[i].begin(), S[i].end());
			for (const auto &c : S[i]) {
				sum += (c == ')') - (c == '(');
				chmin(m, sum);
			}
			r.emplace_back(m, sum);
		}
	}

	sort(l.begin(), l.end(), greater<>());
	sort(r.begin(), r.end(), greater<>());
	int suml = 0;
	for (int i = 0; i < l.size(); i++) {
		if (suml + l[i].first < 0) {
			cout << "No" << "\n";
			return 0;
		}
		suml += l[i].second;
	}
	int sumr = 0;
	for (int i = 0; i < r.size(); i++) {
		if (sumr + r[i].first < 0) {
			cout << "No" << "\n";
			return 0;
		}
		sumr += r[i].second;
	}

	if (suml != sumr) {
		cout << "No" << "\n";
		return 0;
	}

	cout << "Yes" << "\n";

	return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 1e18
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    vector<ll> A(N); rep(i,N)cin>>A.at(i);
    sort(begin(A),end(A));
    if(A.at(0)==0){
        cout<<0<<endl;
        return 0;
    }
    ll res = 1;
    rep(i,N){
        if(res>(ll)pow(10,18)/A.at(i)){
            cout<<-1<<endl;
            return 0;
        }
        res *= A.at(i);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 4000
from sys import stdin
from statistics import mean, median,variance,stdev
import numpy as np

def main():
    N = int(input())
    A = list(map(int, stdin.readline().rstrip().split()))
    m = mean(A)

    A = np.array(A)
    A = np.abs(A -m)

    print(np.argmin(A))

input = lambda: stdin.readline()
main()


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 092 D / Link: http://abc092.contest.atcoder.jp/tasks/abc092_d  ----- */


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

	LL A, B; cin >> A >> B;
	LL H, W; H = W = 100;
	VS a(H, string(W, '!'));
	FOR(i, 0, H) {
		FOR(j, 0, W) {
			if (i < H / 2) {
				a[i][j] = '.';
			}
			else {
				a[i][j] = '#';
			}
		}
	}
	A--, B--;
	for (int i = 1; i < H / 2; i += 2) {
		for (int j = 1; j < W-1; j += 2) {
			if (B) {
				a[i][j] = '#';
				B--;
			}
		}
	}
	for (int i = H / 2 + 1; i < H; i += 2) {
		for (int j = 1; j < W-1; j += 2) {
			if (A) {
				a[i][j] = '.';
				A--;
			}
		}
	}


	cout << H << " " << W << endl;
	FOR(i, 0, H) {
		cout << a[i] << endl;
	}

	return 0;
}


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

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

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;

int main(){
  int n,Alice_point=0,Bob_point=0;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  rep(i,n){
    if(i%2==0) Alice_point += a[i];
    if(i%2==1) Bob_point += a[i];
  }
  cout << Alice_point-Bob_point << endl;
}
  
  

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

using namespace std;

int main()
{
    int n;

    cin >> n;

    int ara[n];

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

    vector <int> lis;

    for(int i = 0; i < n; i++)
    {
        auto it = lower_bound(lis.begin(), lis.end(), ara[i]);

        if(it == lis.end())
            lis.push_back(ara[i]);

        else
            lis[it - lis.begin()] = ara[i];
    }

    cout << lis.size() << '\n';

    return 0;
}



Measured memory_bytes: 3916
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
T = [I() for _ in range(n)]
def lcm(a,b):
    g = gcd(a,b)
    return a // g * b
ans = 1
for i in range(n):
    ans = lcm(ans,T[i])
print(ans)


Measured memory_bytes: 10512
def floyd_warshall(dp, V):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

    # Check Negative Cycle
    for k in range(V):
        for i in range(V):
            for j in range(V):
                if dp[i][k] + dp[k][j] < dp[i][j]:
                    return -1
    return dp

INF = float('inf')
V, E = [int(x) for x in input().split()]
dp = [[INF for _ in range(V)] for _ in range(V)]
for i in range(V):
    dp[i][i] = 0

for j in range(E):
    s, t, d = [int(x) for x in input().split()]
    dp[s][t] = d

dp = floyd_warshall(dp, V)
if dp == -1:
    print("NEGATIVE CYCLE")
else:
    for i in range(V):
        for j in range(V):
            if dp[i][j] == INF:
                dp[i][j] = "INF"
        print(*dp[i])


Measured memory_bytes: 6292
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int k = sc.NextInt();
        int s = sc.NextInt();

        long answer = 0;
        for (int x = 0; x <= k; x++)
        {
            for (int y = 0; y <= k; y++)
            {
                int z = s - x - y;
                if (z < 0 || z > k)
                {
                    continue;
                }
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

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

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

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main(){
    string s;
    cin >> s;
    set<char> set_s;
    for (int i = 0; i < s.size(); i++){
        set_s.insert(s.at(i));
    }
    if (s.size() == set_s.size()){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
}

Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let a = scan.readn::<usize>(n);
    let mut ret = 0;
    for i in 0..n {
        if a[a[i]-1] == i+1 {
            ret += 1;
        }
    }
    println!("{}", ret/2);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 100001

bool is_prime[MAX];
bool is_like[MAX];
int like_sum[MAX];

void eratos() {
  fill(is_prime, is_prime + MAX, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i < MAX; i++) {
    if (!is_prime[i]) continue;
    for (int j = i + i; j < MAX; j += i) {
      is_prime[j] = false;
    }
  }
}

void calc_like() {
  fill(is_like, is_like + MAX, false);
  for (int i = 3; i < MAX; i++) {
    if (is_prime[i] && is_prime[(i + 1) / 2]) {
      is_like[i] = true;
    }
  }
}

void calc_like_sum() {
  like_sum[0] = 0;
  for (int i = 1; i < MAX; i++) {
    like_sum[i] = like_sum[i - 1];
    if (is_like[i]) like_sum[i]++;
  }
}

int main() {
  eratos();
  calc_like();
  calc_like_sum();
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << like_sum[r] - like_sum[l - 1] << endl;
  }
}


Measured memory_bytes: 1280
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
 
 
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
 
using namespace std;
 
const int MAX_V = 100001;
const long long INF = 1e12;
 
int n,m,r;
 
struct edge{
    int to, dist;
    edge(int t_to,int t_dist){
        to=t_to;dist=t_dist;
    }
};
 
typedef pair<int,int> P;//cost???¨v
 
vector< vector<edge> > G(MAX_V);
long long d[MAX_V];
 
void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P> > que;
    fill_n((long long *)d, sizeof(d)/sizeof(long long),INF);
    d[s] = 0;
    que.push(P(0,s));
 
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;
        rep(i,G[v].size()){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.dist){//???????????????´???
                d[e.to] = d[v] + e.dist;
                que.push(P(d[e.to],e.to));
            }
        }
    }
}
 
 
int main(){
 
    cin >> n >> m >> r;
 
//  G.clear();
//  G.resize(n);
 
    rep(i,m){
        int a,b,d;
        cin >> a >> b >> d;
        edge tmp1(b,d);
        G[a].push_back(tmp1);
    }
 
    dijkstra(r);
    rep(i,n){
        //if(i==r) continue;
        if(d[i]==INF) cout << "INF" <<endl;
        else cout << d[i] << endl;
    }
 
}

Measured memory_bytes: 11676
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        v: [(usize, usize); n]
    }
    let mut t = 0;
    for &(a, b) in v.iter().rev() {
        t += (a + t + b - 1) / b * b - (a + t);
    }
    println!("{}", t);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
const int Max= 1e5+10;
long long dp[Max][4];
long long a[Max][4];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++)
			scanf("%lld",&a[i][j]);
	for(int i=1;i<=3;i++)
		dp[1][i]=a[1][i];
	for(int i=2;i<=n;i++)
	{
		for(int j=1;j<=3;j++)
		{
			if(j==1)
				dp[i][j]=max(dp[i-1][2],dp[i-1][3])+a[i][j];
			else if(j==2)
				dp[i][j]=max(dp[i-1][1],dp[i-1][3])+a[i][j];
			else
				dp[i][j]=max(dp[i-1][1],dp[i-1][2])+a[i][j];
		}
	}
	printf("%lld\n",max(dp[n][1],max(dp[n][2],dp[n][3])));
	return 0;
} 

Measured memory_bytes: 6528