akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)

typedef long long int ll;

std::vector<ll> enum_div(ll n);
long long comb(int n, int r);
bool IsPrime(int num);
bool dp[110][10010];
class UnionFind;
using Graph = vector<vector<int>>;

//自作関数一覧---------------------------
ll gcd(ll a, ll b); //最小公倍数の導出
ll lcm(ll x, ll y); //最大公約数の導出
ll bur(ll N, ll X); //??
//---------------------------------------

//UF木
class UnionFind {
public:
	//親
	vector<int> Parent;

	//初期状態
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//サイズ確認
	int size(int A) {
		return -Parent[root(A)];
	}

	int connect(int A, int B) {
		//root同氏をくっつける
		A = root(A);
		B = root(B);

		//結合済み
		if (A == B) {
			return false;
		}
		//大きいほうに小さいほうをくっつける
		if (size(A) < size(B)) swap(A, B);

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

		return true;
	}

};

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	

	string S, T;
	char fi[50], fv[50];
	char board[4][4];
	bool start = false;
	ll left = 0, right = 0;
	
	
	cin >> N >> D >> A;
	std::vector<ll> cho(N);

	rep(i, 0, N)
		cin >> cho[i];

	rep(i, 0, N) {
		B = 1;

		while (true) {
			if (B <= D) {
				B += cho[i];
				C++;
			}
			else {
				
				break;
			}
		}

	}

	cout << C + A<< endl;

	return 0;
}


std::vector<ll> enum_div(ll n)//nの約数を列挙
{
	vector<ll> res;
	for (int i = 1; i*i <= n; ++i) {
		if (n % i != 0) continue;
		res.push_back(i);
		if (n / i == i) continue; // 上の行で追加済み。
		res.push_back(n / i);
	}
	return res;
}








bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}



//combination
long long comb(int n, int r) {
	std::vector<std::vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v[n][r];
}


ll gcd(ll a, ll b) {

	/* 自然数 a > b を確認・入替 */
	if (a<b) {
		ll tmp = a;
		a = b;
		b = tmp;
	}
	ll x = b;
	ll y = a;
	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}


	return y / b*x;
}

// 最大公約数を求める関数
ll lcm(ll x, ll y)
{
	if (x == 0 || y == 0)  // 引数チェック
	{
		//fprintf(stderr, "引数エラーです。\n");
		return 0;
	}

	return (x * y / gcd(x, y));
}

ll bur(ll N, ll X) {
	ll pan = 1;
	ll pat = 1;
	ll burg = 0;



	if (X > burg) {
		if (N == 0)
			return pat;


		burg += pan;
		burg += bur(N - 1, X);
		burg += pat;
		burg += bur(N - 1, X);
		burg += pan;


	}

	return burg;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, m;
	cin >> n >> m;
	ll a[n], ans = 0, acc = 0;
	map<ll, int> mop;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		acc = (acc + a[i]) % m;
		mop[acc]++;
	}
	acc = 0;
	for (int i = 0; i < n; i++)
	{
		ans += mop[acc];
		acc = (acc + a[i]) % m;
		mop[acc]--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define MOD
#define MAXN
#define MAXM
#define LL long long
#define ll long long
#define mem(a) memset(a,0,sizeof(a))
#define memmax(a) memset(a,0x3f,sizeof(a))
//#define int long long
using namespace std;
inline int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0'||ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0'&&ch<='9'){
		x=(x*10)+(ch-'0');
		ch=getchar();
	}
	return x*f;
}
const string S="RYGB";
//#undef int
int main(){
//#define int long long
	int h=read(),w=read(),d=read();
	for (register int i=1;i<=h;++i){
		for (register int j=1;j<=w;++j){
			int x=i+j+w,y=i-j+w;
			int p=((int)(x/d)+2)%2,q=((int)(y/d)+2)%2;
			putchar(S[(p<<1)+q]);
		}
		putchar('\n');
	}
}


Measured memory_bytes: 512
n, m = gets().split(' ').map(&:to_i)
x = gets().split(' ').map(&:to_i)

if n >= m
	puts 0
else
	xs = x.sort
	dx = []
	for i in 0 ... (xs.length - 1)
		dx[i] = xs[i + 1] - xs[i]
	end

	dx.sort!
	puts dx[0 ... (m - n)].inject(&:+)
end


Measured memory_bytes: 10608
#include <stdio.h>
 
int main(){
   int a, b, c, tmp;
 
   scanf("%d %d %d", &a, &b, &c);
 
   if (a>b){
      tmp = a;
      a = b;
      b = tmp;
   }
 
   if (b>c){
      tmp = b;
      b = c;
      c = tmp;
   }
       
   if (a>b){
      tmp = a;
      a = b;
      b = tmp;
   }
 
   printf("%d %d %d\n", a, b, c);
 
   return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		rep(i, 4) { char c; cin >> c; cout << c; }
		cout << " ";
		rep(i, 8) { char c; cin >> c; cout << c; }
		cout << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll arr[5];
  for(int i=0;i<5;i++)
    cin>>arr[i];
  for(int i=0;i<5;i++)
  {
    if(arr[i]==0)
    {
      cout<<(i+1)<<endl;
      break;
      
    }
    
  }
}


Measured memory_bytes: 3576
# AOJ ITP1_8_C

import sys

def numinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def main():
    counts = []
    for i in range(26): counts.append(0)

    lines = sys.stdin.readlines()

    for i in range(len(lines)):
        string = lines[i]
        # if not len(string): break   # 長さが0のstringが来たら終了
        for k in range(len(string)):
            c = string[k]
            if 97 <= ord(c) <= 122:
                counts[ord(c) - 97] += 1
            elif 65 <= ord(c) <= 90:
                counts[ord(c) - 65] += 1

    # 結果を出力。
    for i in range(26):
        print(chr(97 + i) + " : " + str(counts[i]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 5568
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define pi 3.14159265358979323846
#define int long long
#define inf 1000000007 
#define sort(vec) sort(vec.begin(),vec.end());
#define rever(vec) reverse(vec.begin(),vec.end());
#define unsort(vec) sort(vec); rever(vec);
#define rep(i,n) for(int i=0;i<n;i++)
int a[114514],dp[114514];
signed main(){
    int n,k;
    cin>>n>>k;
     for(int i=1;i<=n;i++){
		 cin>>a[i];
		 dp[i]=inf;
		 }
    dp[1]=0;
    for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		}
	}
	cout<<dp[n]<<endl;
}



Measured memory_bytes: 1792
n=int(input())
if 100<=n<=111: print(111)
elif 112<=n<=222:print(222)
elif 223<=n<=333:print(333)
elif 334<=n<=444:print(444)
elif 445<=n<=555:print(555)
elif 556<=n<=666:print(666)
elif 667<=n<=777:print(777)
elif 778<=n<=888:print(888)
else:print(999)

Measured memory_bytes: 3060
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toLong)
    val aList = readLine()!!.split(' ').map(String::toLong)
    val bList = readLine()!!.split(' ').map(String::toLong)
    val aSet = aList.toSortedSet()
    val bSet = bList.toSortedSet()
    if (n.toInt() != aSet.size || m.toInt() != bSet.size) {
        println(0)
        return
    }
    var answer = 1L
    for (i in n * m downTo 1) {
        val aContains = aSet.contains(i)
        val bContains = bSet.contains(i)
        if (aContains && bContains) {
            //do nothing
        } else if (aContains) {
            val first = bSet.indexOfFirst { it >= i }
            answer *= if (first == -1) 0 else (m - first)
        } else if (bContains) {
            val first = aSet.indexOfFirst { it >= i }
            answer *= if (first == -1) 0 else (n - first)
        } else {
            val aFirst = aSet.indexOfFirst { it >= i }
            val bFirst = bSet.indexOfFirst { it >= i }
            answer *=
                    if (aFirst == -1 || bFirst == -1) 0
                    else (n - aFirst) * (m - bSet.indexOfFirst { it >= i }) - (n * m - i)
        }
        answer %= 1000000007
    }
    println(answer)
}


Measured memory_bytes: 75916
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N;

  cin >> N;
  cout << N * N * N << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  string s;

  cin >> s;

  int sum = 0;

  for(auto& c : s) sum = (sum + c - '0') % 9;

  cout << (sum == 0 ? "Yes\n" : "No\n");

  return 0;
}
/*

*/


Measured memory_bytes: 3768
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

   private static final String INPUT_FILE_PATH = "";

   static void solve(InputReader in, PrintWriter out) {
      long a = in.nextLong(), b = in.nextLong(), c = in.nextLong(), d = in.nextLong();
      out.println(Math.max(Math.max(a * c, a * d), Math.max(b * c, b * d)));
   }

   private static class InputReader {
      private BufferedReader br;
      private StringTokenizer st;

      public InputReader(InputStream inputStream) {
         this.br = new BufferedReader(new InputStreamReader(inputStream), 32768);
         this.st = null;
      }

      public String nextToken() {
         while (st == null || !st.hasMoreTokens()) {
            try {
               st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
               throw new RuntimeException(e);
            }
         }
         return st.nextToken();
      }

      public int nextInt() {
         return Integer.parseInt(nextToken());
      }

      public long nextLong() {
         return Long.parseLong(nextToken());
      }

      public double nextDouble() {
         return Double.parseDouble(nextToken());
      }
   }

   public static void main(String[] args) throws Exception {
      InputStream inputStream = INPUT_FILE_PATH.isEmpty()
         ? System.in
         : new FileInputStream(new File(INPUT_FILE_PATH));
      OutputStream outputStream = System.out;

      InputReader inputReader = new InputReader(inputStream);
      PrintWriter printWriter = new PrintWriter(outputStream);

      solve(inputReader, printWriter);

      printWriter.close();
   }

}


Measured memory_bytes: 33064
import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;

public class Main {	
	Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new AOJ1124();
	}
	class AOJ1124{
		public AOJ1124() {
			while(true){
				int n = in.nextInt();
				int q = in.nextInt();
				if(n+q==0)break;
				int[] memo = new int[200];
				for(int i=0;i<n;i++){
					int m = in.nextInt();
					for(int s=0;s<m;s++)memo[in.nextInt()]++;
				}
				int max = 0;
				int index = 0;
				for(int i=199;i>=0;i--){
					if(memo[i]>=max){
						max=memo[i];
						index=i;
					}
				}
				if(max>=q)System.out.println(index);
				else System.out.println("0");
				
			}
		}
	}
	
}

Measured memory_bytes: 63192
N, W = map(int, input().split())
v = [0] * N
w = [0] * N

for i in range(N):
    v[i], w[i] = list(map(int, input().split()))

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if j-w[i] >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            dp[i+1][j] = dp[i][j]
        pass

print(dp[N][W])



Measured memory_bytes: 25940
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
    // clang-format on

#include <utility>
using K = pair<int, int>;

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int s, d, m;
    while (cin >> s >> d >> m) {
        vector<vector<K>> Kanmi(s);
        REP(i, 0, s) {
            int k;
            cin >> k;
            REP(j, 0, k) {
                int a, b;
                cin >> a >> b;
                Kanmi[i].emplace_back(a, b);
            }
        }
        vector<K> Lst;
        {
            REP(i, 0, d) {
                int f;
                cin >> f;
                for (auto L : Kanmi[f]) {
                    Lst.push_back(L);
                }
            }
        }
        auto dp = make_v(Lst.size() + 1, m + 1, 0LL);
        REP(i, 0, Lst.size()) {
            REP(j, 0, m + 1) {
                chmax(dp[i + 1][j], dp[i][j]);
                if (j + Lst[i].second <= m) {
                    chmax(dp[i + 1][j + Lst[i].second], dp[i][j] + Lst[i].first);
                }
            }
        }
        ll ans = -1;
        int prm = -1;
        REP(i, 0, m + 1) {
            if (ans < dp[Lst.size()][i]) {
                ans = dp[Lst.size()][i];
                prm = i;
            }
        }
        cout << ans << " " << prm << endl;
    }
    return 0;
}



Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    if (n == 0 || k == 0) return 1; // あとでけす
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(void){
  int h,w,a,b; cin >> h >> w >> a >> b;
  combination c(h+w+5);
  mint ans = 0;
  FOR(i,b,w-1){
    ans += c(h-a-1+i,i) * c(a-1+w-i-1,w-i-1);
  }
  cout << ans.x << endl;


}

Measured memory_bytes: 3328
#include <stdio.h>
#define N 45

int main(){
  int i;
  int fib[N];

  fib[0] = fib[1] = 1;

  for(i = 2; i < N; i++) fib[i]=fib[i-1]+fib[i-2];
  scanf("%d",&i);
  printf("%d\n",fib[i]);
  return 0;
}



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

public class Main
{
   public static void main(String[] args)
   {
      int a, b, keta;
      try {
         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
         String s;
         while((s=br.readLine())!=null){
            StringTokenizer st=new StringTokenizer(s, " ");
            a=Integer.parseInt(st.nextToken());
            b=Integer.parseInt(st.nextToken());
            a+=b;
            keta=1;
            while((a/=10)!=0) keta++;
            System.out.println(keta);
         }
      }
      catch(Exception e){}
   }
}

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

 
/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/


int main(){
    string S;
    cin>>S;
    int n;
    n=S.length();
    string s1,s2;
    s1 = S.substr(0,(n-1)/2);
    s2 = s1;
    reverse(s2.begin(),s2.end());
    string s3,s4;
    s3 = S.substr((n+1)/2,(n-1)/2);
    s4 = s3;
    reverse(s4.begin(),s4.end());
    int tmp = 0;
    if(s1==s2 && s2==s3 && s3 == s4){
        tmp=1;
    }
    if(tmp==1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int func(long long n, std::vector<long long> a) {
    // cout << fixed << setprecision(8);

    while (n > 1) {
        sort(all(a));
        for (int i = n - 1; i > 0; i--) {
            a[i] %= a[0];
            if (a[i] == 0) {
                a.erase(a.begin() + i);
                n--;
            }
        }

        // rep(j, n) { cout << a[j] << " "; }
        // cout << endl;
    }
    // cout << "END: ";
    // rep(j, n) { cout << a[j] << " "; }
    // cout << endl;
    cout << a[0] << endl;

    return 0;
}

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

    func(N, std::move(A));

    return 0;
}


Measured memory_bytes: 1024
a,b=map(int,input().split())
if a==1 and b==1:
    print("Draw")
elif a==1:
    print("Alice")
elif b==1:
    print("Bob")
else:
    if a>b:
        print("Alice")
    elif a==b:
        print("Draw")
    else:
        print("Bob")


Measured memory_bytes: 2940
s = input()
n = 4

for i in range(2**n):
    tmp = ['','','','']
    for j in range(n):
        if ((i>>j)&1):
            tmp[j]='A'
    t = '{0[0]}KIH{0[1]}B{0[2]}R{0[3]}'.format(tmp) 
    if t==s:
        print('YES');exit()
print('NO')

Measured memory_bytes: 3064
N,A,B=map(int,input().split())

a=0
b=0
for s in input():
    if s=='a' and a+b<A+B:
        print('Yes')
        a+=1
    elif s=='b' and a+b<A+B and b<B:
        print('Yes')
        b+=1
    else:
        print('No')


Measured memory_bytes: 4016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		
		int alphabets[] = new int[26];
		
		for(int i = 0; i < input.length() ; i++){
			alphabets[input.charAt(i) - 'a']++;
		}
		
		PriorityQueue<Node> pq = new PriorityQueue<Node>();
		for(int i = 0; i < alphabets.length; i++){
			if(alphabets[i] != 0){
				pq.add(new Node(alphabets[i], (char)(i + 'a')));
			}
		}
		
		if(pq.size() == 1){
			System.out.println(input.length());
			
			return;
		}
		while(pq.size() > 1){
			Node n1 = pq.remove();
			Node n2 = pq.remove();
			
			Node z = new Node(n1.freq + n2.freq, n1, n2);
			
			pq.add(z);
		}
		
		Node root = pq.peek();
		
		//System.out.println(root.toString());
		int[] len = new int[26];
		DFS(root, len, 0);
		
		int result = 0;
		for(int i = 0; i < alphabets.length ; i++){
			result += alphabets[i]*len[i];
		}
		System.out.println(result);
	}
	
	static void DFS(Node current, int len[], int depth){
		if(current.isLeaf){
			len[current.c - 'a'] = depth;
			//System.out.println("length of "+current.c+" is "+len[current.c - 'a']);
		}
		else {
			DFS(current.left, len, depth + 1);
			DFS(current.right, len, depth + 1);
		}
	}

}

class Node implements Comparable<Node>{
	int freq;
	boolean isLeaf;
	char c;
	Node left;
	Node right;
	
	Node(int freq, Node l, Node r){
		this.freq = freq;
		isLeaf = false;
		c = 'X';
		this.left = l;
		this.right = r;
		
	}
	
	Node(int freq, char c){
		this.freq = freq;
		this.c = c;
		isLeaf = true;
		this.left = null;
		this.right = null;
				
	}

	@Override
	public int compareTo(Node n0) {
		// TODO Auto-generated method stub
		return this.freq - n0.freq;
	}
	
	public String toString(){
		return c+" "+freq+" "+isLeaf;
	}
}



Measured memory_bytes: 27128
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		if(x==1)System.out.println(1+" "+0);
		else {
			long a = 0;
			long b = 0;
			long sub = 0;
			boolean found = false;
			while(found==false) {
				a++;
				b=0;
				while(a>=b) {
					long powa = (long)Math.pow(a,5);
					long powb = (long)Math.pow(b,5);
					sub = powa-powb-x;
					if(sub == 0) {
						found = true;
						break;
					}
					sub = powa+powb-x;
					if(sub == 0) {
						found = true;
						b=b*(-1);
						break;
					}
					b++;
				}
			}
			System.out.println(a+" "+b);
		}
    }
}

Measured memory_bytes: 38644
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int D,N; cin>>D>>N;
	int c=0,p=pow(100,D);
	for(int i=1;i<=1000000+10000000;i++){
		if(i%p==0 and i%(100*p)!=0)c++;
		if(c==N){
			cout<<i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}


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

    string s1,s2,s = "";
    char a;
    REP(i,n){
        s.push_back('1' + i);
        cin >> a;
        s1.push_back(a);
    }
    REP(i,n){
        cin >> a;
        s2.push_back(a);
    }
    int i=0,aa,b;
    do{
        i++;
        if(s == s1) aa = i;
        if(s == s2) b = i;
    }while(next_permutation(s.begin(),s.end()));
    cout << abs(aa - b) <<endl;
}





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

int main(){

    int a,b,c,d,e,k;

    cin>>a>>b>>c>>d>>e>>k;

    if( (e-a)  > k) cout<<":("<<endl;

    else if( (e-a) <= k) cout<<"Yay!"<<endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

vector<ll> a;
vector<ll> paty;

ll r(ll n1,ll x1){

    if(n1 == 0){
        if(x1 <= 0){
            return 0;
        }
        else{
            return 1;
        }
    }
    else if(x1 <= a[n1 - 1] + 1){
        return r(n1 - 1,x1 - 1);
    }
    else{
        return paty[n1-1] + 1 + r(n1 - 1,x1 - 2 - a[n1 - 1]);
    }
}

int main(){

    ll n, x;
    cin >> n >> x;

    a.resize(n);
    paty.resize(n);

    paty[0] = 1;
    a[0] = 1;
    for(int i = 1;i < n;i++){
        a[i] = 2 * a[i-1] + 3;
        paty[i] = 2 * paty[i-1] + 1;
    } 

    /*rep(i,n){
        cout << a[i] <<" " << paty[i] << endl;
    }*/

    cout << r(n,x) << endl;;
    
    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    ans = 0
    for i in range(1, N + 1):
        if len(str(i)) % 2 == 1:
            ans += 1
    
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;

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

bool dp[400][10][7][7][7][7];
bool wed[400][17];

int dx[4] = {0, 0, 1, 1}, dy[4] = {0, 1, 0, 1};

int dxx[9] = {-2, -1, 0, 1, 2, 0, 0, 0, 0}, dyy[9] = {0, 0, 0, 0, 0, -2, -1, 1, 2};
int pos[9] = {0, 1, 2, 4, 5, 6, 8, 9, 10};
bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    REP(i, N + 1) {
        REP(j, 10) REP(a, 7) REP(b, 7) REP(c, 7) REP(d, 7) { dp[i][j][a][b][c][d] = false; }
    }
    REP(i, N) {
        REP(j, 16) { cin >> wed[i][j]; }
    }
    // REP(i, N) {
    //     REP(j, 16) { cout << wed[i][j] << " "; }
    //     cout << endl;
    // }
    dp[0][4][1][1][1][1] = true;
    REP(k, 4) {
        if (wed[0][pos[4] + dx[k] * 4 + dy[k]]) dp[0][4][1][1][1][1] = false;
    }
    REP(i, N - 1) {
        REP(j, 9) {
            REP(a, 7) REP(b, 7) REP(c, 7) REP(d, 7) {
                if (!dp[i][j][a][b][c][d]) continue;
                int x = j / 3, y = j % 3;
                REP(k, 9) {
                    int nx = x + dxx[k], ny = y + dyy[k];
                    int nj = nx * 3 + ny;
                    if (nx < 0 || nx >= 3 || ny < 0 || ny >= 3) continue;
                    int np = pos[nj];
                    assert(np + 5 < 16);
                    if (wed[i + 1][np] || wed[i + 1][np + 1] || wed[i + 1][np + 4] || wed[i + 1][np + 4 + 1]) continue;
                    int na = a + 1, nb = b + 1, nc = c + 1, nd = d + 1;

                    if (np == 0) na = 0;
                    if (np == 2) nb = 0;
                    if (np == 8) nc = 0;
                    if (np == 10) nd = 0;

                    if (na >= 7 || nb >= 7 || nc >= 7 || nd >= 7) continue;

                    dp[i + 1][nj][na][nb][nc][nd] = true;
                }
            }
        }
    }
    bool ok = false;
    REP(j, 9) REP(a, 7) REP(b, 7) REP(c, 7) REP(d, 7) {
        if (dp[N - 1][j][a][b][c][d]) ok = true;
    }
    if (ok)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return true;
}
signed main() {
    while (solve())
        ;
    // solve();
}


Measured memory_bytes: 11584
X = int(input())
List = list()

for x in range(2,33):
    List.append(x)

answer = 0

for x in range(X,0,-1):
    for y in List:
        number = x
        n = 0
        if number % y == 0:
            while number % y == 0:
                number //= y
                n += 1
            if number == 1 and n >= 2:
                answer = x
                break
    if not answer == 0:
        break

if answer == 0:
    answer = 1

print(answer)

Measured memory_bytes: 3188
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
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; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N;
    cin >> N;
    vector<P> pos;
    vector<P> neg;

    for (int i = 0; i < N; i++) {
        string str;
        cin >> str;
        int score = 0;
        for (char c : str) {
            if (c == ')') score--;
            else score++;
        }

        bool is_pos = score >= 0;
        if (!is_pos) {
            reverse(str.begin(), str.end());
            for (int i = 0; i < str.size(); i++) {
                if (str[i] == ')') str[i] = '(';
                else str[i] = ')';
            }
        }

        int lower = 0;
        int tmp = 0;
        for (char c : str) {
            if (c == ')') {
                tmp--;
                lower = min(tmp, lower);
            } else {
                tmp++;
            }
        }

        if (is_pos) pos.emplace_back(lower, score);
        else neg.emplace_back(lower, -score);
    }

    sort(pos.begin(),pos.end(), greater<>());
    sort(neg.begin(), neg.end(), greater<>());

    int total1 = 0;
    for (auto &p : pos) {
        if (total1 + p.first < 0) {
            cout << "No" << endl;
            return 0;
        }
        total1 += p.second;
    }

    int total2 = 0;
    for (auto &p : neg) {
        if (total2 + p.first < 0) {
            cout << "No"<< endl;
            return 0;
        }
        total2 += p.second;
    }

    if (total1 == total2) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 19064
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		while (N>0) {
			if (N%10==7) {
				System.out.println("Yes");
				return ;
			}
			N=N/10;
		}
		System.out.println("No");
  	}
}


Measured memory_bytes: 35708
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main() {

	int n, a, b;
	cin >> n >> a >> b;

	if (a < b) {
		cout << a << endl;
	}
	else {
		cout << b << endl;
	}
	
	if (abs(n - (a + b)) != n - (a + b)) {
		cout << (a + b) - n << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int n;
  cin >> n;
  vi v(n), c(n);
  rep (i, n) {
    cin >> v[i];
  }
  rep (i, n) {
    cin >> c[i];
  }

  int ans = 0;
  rep (i, n) {
    ans += max(v[i] - c[i], 0);
  }
  cout << ans << endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

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

  ll cnt = 0;
  while (a[0] % 2 == 0) {
    a[0] /= 2;
    ++cnt;
  }

  FOR(i, 1, n) {
    ll tmp = 0;
    while (a[i] % 2 == 0) {
      a[i] /= 2;
      ++tmp;
    }
    if (cnt != tmp) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll mn = 1;
  REP(i, n) { mn = a[i] / __gcd(mn, a[i]) * mn; }

  mn *= mod_pow(2, cnt - 1, INF);

  if (mn > m) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = (m / mn + 1) / 2;

  cout << ans << endl;

  return 0;
}

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

int n, t;
int A[101][101];
int d[101], f[101];

void depthFirstSearch(int r) {
	d[r] = ++t;
	for (int i = 1; i <= n; i++) {
		if (A[r][i] == 1 && d[i] == 0) depthFirstSearch(i);
	}
	f[r] = ++t;
	return;
}

int main() {
	int u, v, l;
	t = 0;
	cin >> n;

	for (int i = 1; i <= n; i++) {
		d[i] = f[i] = 0;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			A[i][j] = 0;
		}
	}

	for (int i = 1; i <= n; i++) {
		cin >> u >> l;
		for (int j = 0; j < l; j++) {
			cin >> v;
			A[u][v] = 1;
		}
	}

	for (int i = 1; i <= n; i++) {
		if (d[i] == 0) depthFirstSearch(i);
	}

	for (int i = 1; i <= n; i++) {
		cout << i << " " << d[i] << " " << f[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    int R[MAX], n;
    
    cin >> n;
    for( int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = -2000000000;
    int minv = R[0];
    for (int i = 1;i <n ;i++){
        maxv = max(maxv, R[i] - minv);
        minv = min(minv,R[i]);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <stdio.h>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)


int main() {
    int n;
    cin >> n;
    string S;
    cin >> S;
    int ans = 0;
    rep(i, n){
        int cnt = 0;
        for(char c = 'a'; c <= 'z'; c++){
            bool left = false, right = false;
            rep(j, i){
                if (S[j] == c)left = true;
            }
            FOR(j, i, n){
                if (S[j] ==c) right = true;
            }
            if (left && right) cnt ++;
        }
        if (ans < cnt) ans = cnt;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <deque>
#include <vector>
#include <map>
#include <math.h>
#include <limits.h>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (int)ceil((double)a / b) << endl;
	return 0;
}

Measured memory_bytes: 256
//02
#include<iostream>
#include<string>

using namespace std;

int main(){
  string s;
  cin>>s;
  int d=0;
  for(int i=0;i<s.size();i++){
    char t[128];
    t['i']='i';
    t['w']='w';
    t['(']=')';
    t[')']='(';
    d+=s[i]!=t[s[s.size()-1-i]];
  }
  cout<<(d+1)/2<<endl;
  return 0;
}

Measured memory_bytes: 1184
#include<cstdio>
#include<cstring>
#include<vector>
#include<iostream>
using namespace std;
bool f[9];
int n,m,ans=0;
vector<int> mp[9];
void dfs(int step,int p)
{
	if(step==n)
	{
		ans++;
		return;
	}
	int k=mp[p].size();
	for(int i=0;i<k;++i)
	if(f[mp[p][i]])
	{
		f[mp[p][i]]=false;
		dfs(step+1,mp[p][i]);
		f[mp[p][i]]=true;
	}
}
int main()
{
	memset(f,true,sizeof(f));
	scanf("%d%d",&n,&m);
	for(int a,b,i=1;i<=m;++i)
	{
		scanf("%d%d",&a,&b);
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	f[1]=false; dfs(1,1);
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

constexpr int INF = 1e9+7;
constexpr ll INFL = 9*1e18;

constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };

// constexpr int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// constexpr int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

int inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T>inline void print(T&& x){cout<<setprecision(32)<<x<<endl;}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  int ans = a[0];
  rep(i,n){
    ans = gcd(ans,a[i]);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N; 
int ans = 0;
vector<set<int>> vec(10);
void dfs(int n, int depth){
  if(depth == 3){
    ans++;
    return;
  }
  REP(i, 10){
    int it = *vec[i].upper_bound(n);
    if(it == INF) continue;
    dfs(it, depth+1);
  }
}


signed main() {
  cin >> N;

  string s;
  cin >> s;

  REP(i, N){
    vec[s[i]-'0'].insert(i);
  }
  REP(i, 10) vec[i].insert(INF);


  dfs(-1, 0);
  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <limits.h>
#include <map>
#include <set>

using namespace std;
const int ninf = -(1000000000 + 1);


int solve(void);
int getTreasureNum( vector<vector<int>> &clist, vector<vector<int>> &mp, vector<map<int,int>>&trans);
int getSmallerID(vector<int> &list,  int target);

int main(void) {

	//FILE *fpin = freopen("data.txt", "r", stdin);
	while (solve());
	return 0;

}

int solve(void) {

	int n, m;
	cin >> n >> m;

	/*
		?´?????????¨??§?¨???§???
	*/

	vector<vector<int>> clist(2);
	vector<pair<int, int>> plist(n);
	vector<vector<int>> mp;
	vector<map<int, int>> trans(2);
	/*
		input
	*/
	for (int i = 0; i < n; i++) {
		cin >> plist[i].first >> plist[i].second;
		clist[1].push_back(plist[i].first);
		clist[0].push_back(plist[i].second);
	}

	for (int i = 0; i < 2; i++) {
		clist[i].push_back(ninf);
		sort(clist[i].begin(), clist[i].end());
		clist[i].erase(unique(clist[i].begin(), clist[i].end()), clist[i].end());
		for (int j = 0; j < clist[i].size(); j++) {
			trans[i][clist[i][j]] = j;
		}
	}
	mp = vector<vector<int>>(clist[0].size(), vector<int>(clist[1].size(), 0));

	for (int i = 0; i < n; i++)
		mp[trans[0][plist[i].second]][trans[1][plist[i].first]] ++;

	for (int x = 0; x < mp[0].size(); x++) {
		for (int y = 0; y + 1 < mp.size(); y++) {
			mp[y + 1][x] = mp[y + 1][x] + mp[y][x];
		}
	}

	for (int y = 0; y < mp.size(); y++) {
		for (int x = 0; x + 1 < mp[0].size();x++) {
			mp[y][x + 1] = mp[y][x + 1] + mp[y][x];
		}
	}

	for (int i = 0; i < m; i++)
		cout << getTreasureNum(clist, mp, trans) << endl;

	return 0;
}

int getTreasureNum(vector<vector<int>>& clist, vector<vector<int>>& mp, vector<map<int, int>>& trans)
{
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	if (x2 < clist[1][0] || x1 > clist[1][clist[1].size() - 1] || y2 < clist[0][0] || y1 > clist[0][clist[0].size() - 1]) { return 0; }
	
	if( trans[1].find(x1) == trans[1].end() )
		x1 = min(getSmallerID(clist[1], x1) + 1, (int)clist[1].size()-1);
	else
		x1 = getSmallerID(clist[1], x1);

	x2 = getSmallerID(clist[1], x2);

	if (trans[0].find(y1) == trans[0].end())
		y1 = min(getSmallerID(clist[0], y1) + 1, (int)clist[0].size() - 1);
	else
		y1 = getSmallerID(clist[0], y1);

	y2 = getSmallerID(clist[0], y2);
	
	x1--;
	y1--;
	return mp[y2][x2] - mp[y1][x2] - mp[y2][x1] + mp[y1][x1];
	
}


int getSmallerID(vector<int>& list, int target)
{
	int low = 0;
	int high = list.size();
	int mid = 0;

	while (abs(low - high) > 1) {
		mid = (low + high) / 2;
		if (list[mid] <= target) {
			low = mid;
		}
		else {
			high = mid;
		}
	}
	mid = (high + low) / 2;
	return mid;
}

Measured memory_bytes: 101376
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	ans := 1
	for i := 0; i < n; i++ {
		if ans*2 < ans+k {
			ans *= 2
			continue
		}
		ans += k
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512