akhauriyash/Code-Regression huggingface dataset:
/** MIT License Copyright (c) 2018-2019 Vasilev Daniil **/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//#pragma GCC optimize("Ofast")
template<typename T> using v = vector<T>;
typedef long long ll;
//#define int ll
typedef long double ld;
typedef string str;
typedef vector<int> vint;
#define rep(a, l, r) for(int a = (l); a < (r); a++)
#define pb push_back
#define fs first
#define sc second
#define sz(a) ((int) a.size())
const long long inf = 4611686018427387903; //2^62 - 1
const long double EPS = 1e-12;
#if 0  //FileIO
const string fileName = "";
ifstream fin ((fileName == "" ? "input.txt"  : fileName + ".in" ));
ofstream fout((fileName == "" ? "output.txt" : fileName + ".out"));
#define get fin >>
#define put fout <<
#else
#define get cin >>
#define put cout <<
#endif
#define eol put endl
void read() {} template<typename Arg,typename... Args> void read (Arg& arg,Args&... args){get (arg)     ;read(args...) ;}
void print(){} template<typename Arg,typename... Args> void print(Arg  arg,Args...  args){put (arg)<<" ";print(args...);}
int getInt(){int a; get a; return a;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//code starts here

void run() {
	char a;
	get a;
	map<char, char> d; d['A'] = 'T'; d['C'] = 'G'; d['G'] = 'C'; d['T'] = 'A';
	put d[a];
}

signed main() {ios::sync_with_stdio(0); cin.tie(0); put fixed << setprecision(12); run();}



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

int main() {
  int N,K;
  string S;
  cin >> N >> K >> S;
  char x;
  x=S.at(K-1);
  if(x=='A')
    x='a';
  else if(x=='B')
    x='b';
  else
    x='c';
  S.at(K-1)=x;
  cout << S;
}

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


int main () {
  int i,j,n;
  int dp[1001][1001];
  int ma;
  char c;

  cin >> n;
  while(n != 0) {
    ma = 0; 

    for(i=0; i<n; i++){ dp[0][i] = 0; }
    for(i=0; i<n; i++){ dp[i][0] = 0; }
  
    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++) {
	cin >> c;
	if(c == '*') {
	  dp[j][i] = 0;
	  continue;
	}
      
	dp[j][i] = min(dp[j-1][i], min(dp[j-1][i-1], dp[j][i-1]))+1;
	ma = (dp[j][i] > ma) ? dp[j][i] : ma;
      }
    }
    cout << ma << endl;

    cin >> n;
  }

  return 0;
}

Measured memory_bytes: 5072
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3f
//#define inf 0x3f3f3f3f
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define inv(x) Power(x, mod - 2)
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define N 305

using namespace std;
typedef pair<int,int> Pair;
typedef long long ll;

const long double Pi = 3.14159265358979323846l;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return (x += y) - (x >= mod ? mod : 0); }
inline void inc(int &x, int y) { (x += y) -= (x >= mod ? mod : 0); }
inline int mul(int x, int y) { return 1ll * x * y % mod; }
inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = mul(res, x);
		x = mul(x, x), y >>= 1;
	} return res;
}

template <class T> inline T	input() {
	T x; char ch; while (!isdigit(ch = getchar()));
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return x;
}

template <class T> inline void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> inline void chkmax(T &x, T y) { x = x > y ? x : y; }

struct {
	inline operator int () { return input<int>(); }
	inline operator long long () { return input<long long>(); }
	template <class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

int n, m;
int f[N][N][N];
int l[N], r[N], num[N];
vector<int> lim[N];

bool check(int i, int a, int b) {
	for (int x : lim[i])
		if (1 + (a >= l[x]) + (b >= l[x]) != num[x]) return false;
	return true;
}

signed main() {
	read(n, m);
	for (int i = 1; i <= m; ++i) {
		read(l[i], r[i], num[i]);
		lim[r[i]].push_back(i);
	}

	f[1][0][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = 0; j < i; ++j)
			for (int k = 0; k <= j; ++k) {
				if (!check(i, j, k)) continue;
				inc(f[i + 1][j][k], f[i][j][k]);
				inc(f[i + 1][i][k], f[i][j][k]);
				inc(f[i + 1][i][j], f[i][j][k]);
			}

	int ans = 0;
	for (int j = 0; j < n; ++j)
		for (int k = 0; k <= j; ++k)
			if (check(n, j, k)) inc(ans, f[n][j][k]);
	printf("%d\n", mul(ans, 3));
	return 0;
}


Measured memory_bytes: 108800
main = do
  x <- readLn :: IO Int
  print $ genPrime x

genPrime :: Int -> Int
genPrime x
  | isPrime x 2 = x
  | otherwise = genPrime (x+1)

isPrime :: Int -> Int -> Bool
isPrime x i 
  | i*i > x = True
  | x `mod` i == 0 = False
  | otherwise = isPrime x (i+1)

Measured memory_bytes: 508
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void)
{
	ll i,ans,n,k,count,num;
	while(scanf("%lld%lld",&n,&k)!=EOF)
	{
		ans=0;
		count=1;
		if(k==0)
		{
			ans=n*n;
			printf("%lld\n",ans);
			continue;
		}
		for(i=k+1;i<=n;i++)
		{
			num=n%i;
			if((num-k+1)>0)
			ans+=(num-k+1);
			ans+=(count++)*((n-num)/i);
		}
		printf("%lld\n",ans);
	}
 } 

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

using namespace std;

int n,m,i,j;
vector <int> edge[200005];
bool color[200005];

int main(){
	scanf("%d%d", &n, &m);
	
	for(i = 0; i < m; i++){
		int x,y;
		scanf("%d%d", &x, &y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	for(int k = 0; k < edge[1].size(); k++)
	color[edge[1][k]] = 1;
	
	for(int k = 0; k < edge[n].size(); k++){
		if(color[edge[n][k]])
		return 0 * printf("POSSIBLE\n");
	}
	
	printf("IMPOSSIBLE\n");
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;
int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	N=S.size();
	FOR(i,N-1) {
		if(S[i]==S[i+1]) return _P("%d %d\n",i+1,i+2);
	}
	FOR(i,N-2) {
		if(S[i]==S[i+2]) return _P("%d %d\n",i+1,i+3);
	}
	_P("-1 -1\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int N; cin >> N;

	int res = 0;
	for (int i = (int)(sqrt(N) + 0.5); i > 0; --i){
		if (N >= i*i){
			res = i*i;
			break;
		} // end if
	} // end for

	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
#define MAX 1000100
//#define NIL -1

vector<pair<LL, LL>> factorize_gen(LL n){
    vector<pair<LL, LL>> out;
    for(LL i=2; i*i<=n; i++){
        if(n%i!=0){
            continue;
        }
        LL num=0;
        while(n%i==0){
            num++;
            n/=i;
        }
        out.push_back(make_pair(i, num));
    }
    if(n!=1){
        out.push_back(make_pair(n, 1));
    }

    return out;
}

LL modinv(LL a, LL m) {
    LL b = m, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
int main() {
    int n;
    vector<LL> a;
    LL tmp_a;
    cin >> n;
    vector<LL> lcd(MAX, 0);
    LL ans=0;
    LL lcd_mod=1;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }
    vector<pair<LL, LL>> tmp;
    for(int i=0; i<n; i++){
        tmp=factorize_gen(a[i]);
        for(int j=0; j<tmp.size(); j++){
            lcd[tmp[j].first]=max(lcd[tmp[j].first], tmp[j].second);
        }
    }

    for(int i=2; i<MAX; i++){
        while(lcd[i]>0){
            lcd_mod*=i;
            lcd_mod%=MOD;
            lcd[i]--;
        }
    }

    for(int i=0; i<n; i++){
        ans+=lcd_mod*modinv(a[i], MOD);
        ans%=MOD;
    }

    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 8320
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Collections;

static class Extensions
{
    public static int ToInt(this string s) => int.Parse(s);
    public static long ToLong(this string s) => long.Parse(s);
    public static char ToChar(this string s) => char.Parse(s);
    public static double ToDouble(this string s) => double.Parse(s);
    public static int[] ToIntArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToInt()).ToArray();
    public static long[] ToLongArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToLong()).ToArray();
    public static double[] ToDoubleArray(this string s) => s.Replace(',', ' ').Split(' ').Select(x => x.ToDouble()).ToArray();
    public static Queue<T> ToQueue<T>(this IEnumerable<T> seq) => new Queue<T>(seq);
    public static Stack<T> ToStack<T>(this IEnumerable<T> seq) => new Stack<T>(seq);
    public static HashSet<T> ToHashSet<T>(this IEnumerable<T> seq) => new HashSet<T>(seq);
}
static class MyMath
{
    static public long GCD(long a, long b) => (a < b) ? GCD(b, a) : ((b == 0) ? a : GCD(b, a % b));
    static public long LCM(long a, long b) => (a > b) ? (a / GCD(a, b) * b) : (b / GCD(a, b) * a);
    static private readonly long _m = 1000000000 + 7;
    static public long Mod(long val) => (val % _m + _m) % _m;
    static private long extGCD(long a, long b, ref long x, ref long y) => (b == 0) ? (a + (x = 1) * 0 + (y = 0) * 0) : (extGCD(b, a % b, ref y, ref x) + (y -= a / b * x) * 0);
    static public long ModInverse(long a, long dummy1 = 0, long dummy2 = 0) => extGCD(a, _m, ref dummy1, ref dummy2) * 0 + Mod(dummy1);    
}

class Program
{
    static string[] ReadLines(int n) => Enumerable.Range(0, n).Select(s => Console.ReadLine()).ToArray();

    static void Main()
    {
        int N = Console.ReadLine().ToInt();

        var cityList = Console.ReadLine().ToIntArray();
        var yuushaList = Console.ReadLine().ToIntArray();

        //1番目の街のモンスターを倒せるのは1番目の勇者だけだから、1番目の勇者は1番目の街を優先的に倒す。

        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            var capacity = yuushaList[i];

            if (cityList[i] > 0)
            {
                var val = Math.Min(capacity, cityList[i]);                
                ans += val;
                cityList[i] -= val;
                capacity -= val;
            }
            if (cityList[i + 1] > 0)
            {
                var val = Math.Min(capacity, cityList[i + 1]);
                ans += val;
                cityList[i + 1] -= val;
                capacity -= val;
            }
        }

        Console.WriteLine(ans);
    }
    
}

Measured memory_bytes: 34140
#include<iostream>
#include<string>
#include<vector>
#include<map>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
using namespace std;

vector<ll> vv[200010];
ll ar[200010];
ll ce = 0;

void dfs(ll a){

ll i,j,k,b,c,d;
ar[a] = 1;
ce++;
for(i=0;i<vv[a].size();i++){
    if(ar[vv[a][i]]==0){
        ar[vv[a][i]]==1;
        dfs(vv[a][i]);
    }
}

}

int main()
{
    ll i,j,a,k,b,c,n,t,m,p,q,d,e,f,y,g,z,h,r,l,x,o;
    ld aa,bb,cc,ee,dd,ff,kk,gg;
    vector<ll > v,s;
//    map<ll,vector<ll> > me;
//    map<ll,ll > sa,ta,pa,ma;
//    priority_queue<ll, vector<ll>, greater<ll> > aq,tq,pq;
  string st,et,ft,pt,ct;
//    deque<ll> de,pe,ne;
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>a>>b;
        vv[a].pb(b);
        vv[b].pb(a);
    }
    e = 1;
    for(i=1;i<=n;i++){
        if(ar[i]==0){
                dfs(i);
            e = max(e,ce);
            ce = 0;
        }
    }
    cout<<e<<endl;
}


Measured memory_bytes: 22328
// WARNING: Add compile option "-std=c++11" for C++11 compile.

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

// Macro
#define REP(i, N) for(int i=0; i<(int)N; i++)
#define REPR(i, N) for(int i=(int)N-1; i>=0; i--)

// Type
using ll = long long;
template <typename T = int> using P = pair<T, T>;

// Constants
const ll MOD = 1000000007;

/**
  型に合わせたINFを返す
  int: 214,748,364 (2.14 * 1e8)
  ll : 922,337,203,685,477,580 (9.22 * 1e17)
*/
template <typename T = int>
T getINF() {
  // NOTE: INF同士を足してもオーバーフロー起こさないように、10で割っている
  return numeric_limits<T>::max() / 10;
}

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)


/**
  辺
  to: 辺の行き先
  cost: 辺の重み
  T: 重みの型
  */
template <typename T = int>
struct Edge {
  int to;
  T cost;
  Edge(int to, T cost) : to(to), cost(cost) {}
};

/**
  n: 頂点数
  graph: グラフ本体
  */
template <typename T = int>
class Graph {
  public:
    int n;
    vector<vector<Edge<T>>> graph;

    Graph(int n) {
      this->n = n;
      this->graph.assign(n, vector<Edge<T>>());
    }

    void addEdge(int from, int to, T cost) {
      this->graph[from].push_back(Edge<T>(to, cost));
    }
};

/**
  ベルマンフォード法 (単一始点最短経路問題 / 辺の重みが負数でもOK)
  WARNING: 辺の重みが負数でもOK / 重みが全て正数ならdijkstra法の方が速い

  引数:
    - Graph<T> g: グラフ
    - int s: 出発地点のノード番号

  計算量:
    - O(|V|・|E|)

  返り値:
    - 出発地点sからのそれぞれのノードへの距離

  依存ライブラリ:
    - template.hpp
    - Graph/ShortestPath/common.hpp
*/
template <typename T = int>
vector<T> bellmanFord(Graph<T> g, int s) {
  // 距離情報初期化
  T INF = getINF<T>();
  vector<T> d(g.n, -INF);
  d[s] = 0;

  // 全ての辺に対して、頂点の数分の更新をかける
  int n = g.n;
  for(int _ = 0; _ < n; _++) {
    for(int from = 0; from < n; from++) {
      for(Edge<T> edge : g.graph[from]) {
        if(d[from] + edge.cost > d[edge.to]) {
          d[edge.to] = d[from] + edge.cost;

          // 負閉路検出
          // WARNING: 不平路を検出した時、d[n-1]にINFを埋め込んで返しているので、返した後の判定注意
          if(_ == n-1 && edge.to == n-1) {
            d[n-1] = -INF;
            return d;
          }
        }
      }
    }
  }
  return d;
}

int main() {
  int N, M;
  cin >> N >> M;
  Graph<ll> g = Graph<ll>(N);
  for(int i = 0; i < M; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--; b--;
    g.addEdge(a, b, c);
  }

  vector<ll> d = bellmanFord<ll>(g, 0);

  if(d[N-1] != -getINF<ll>()) {
    cout << d[N-1] << endl;
  } else {
    cout << "inf" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
N, M =      map(int, input().split())
S    = list(map(int, input().split()))
T    = list(map(int, input().split()))
assert len(S) == N
assert len(T) == M

modulo = 10 ** 9 + 7

# tab[j][i] = S[i] == T[j]
tab = [[s == t for s in S] for t in T]

# 番兵
for t in tab:
    t.append(1)
tab.append([1] * (len(S) + 1))

# 右下から計算
for j in range(M - 1, -1, -1):
    for i in range(N - 1, -1, -1):
        v  = tab[j + 1][i] + tab[j][i + 1]
        v -= 0 if tab[j][i] else tab[j + 1][i + 1]
        tab[j][i] = v % modulo

print(tab[0][0])


Measured memory_bytes: 135900
//
// Created on 2020/05/17.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    string s;
    int k;
    cin>>k;
    cin>>s;
    string ans = "";
    if(s.size() <= k){
        cout<<s<<endl;
        return 0;
    }
    for (int i = 0; i < k; ++i) {
        ans += s[i];
    }
    ans +="...";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
N, Q = map(int, input().split())
S = str(input())

l_list = []
r_list = []

s_count = [0]
for i in range(len(S) - 1):
    if S[i:i+2] == 'AC':
        s_count.append(1)
    else:
        s_count.append(0)
#print(s_count)

n_count = []
n_sum = 0
for n in s_count:
    n_sum = n_sum + n
    n_count.append(n_sum)

#print(n_count)


for x in range(Q):
    l, r = map(int, input().split())
    ans = n_count[r-1] - n_count[l-1]
    print(ans)
    
    




Measured memory_bytes: 8556
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int N,A[100001]={0};
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  ll sum(abs(A[0]));
  for (int i(0);i<N-1;i++) sum+=abs(A[i]-A[i+1]);
  sum+=abs(A[N-1]);
  int now(0);
  for (int i(0);i<N;i++){
    if (now <= A[i] && A[i] <= A[i+1] || A[i+1] <= A[i] && A[i] <= now) cout << sum << endl;
    else if (now <= A[i+1] && A[i+1] <= A[i] || A[i] <= A[i+1] && A[i+1] <= now) cout << sum - abs(A[i]-A[i+1])*2 << endl;
    else {
      cout << sum - 2 * abs(now - A[i]) << endl;
    }
    now = A[i];
  }
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
long long n, m;
int main() {
    cin >> n >> m;
    long long ans = 0;
    if(n*2 > m) {
        ans += m/2;
    }else {
        ans += n;
        ans += (m-n*2)/4;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n =scan.nextInt();

		for(int i=3;i<=n;i++){
			if(i%3 == 0){
				System.out.print(" "+i);
			}else{

			int a = i;
			if(a/1000 == 3){
				System.out.print(" "+i);
			}else{
				a =a - a/1000 *1000;
				if(a/100==3){
					System.out.print(" "+i);
				}else{
						a =a - a/100 *100;
						if(a/10==3){
							System.out.print(" "+i);
						}else{
							a = a -a/10*10;
							if(a==3){
								System.out.print(" "+i);

							}
						}
					}
				}
			}
		}


		System.out.println();
	}
}

Measured memory_bytes: 28520
#include <stdio.h>

int main(void)
{
    int n;
    static long r[200000];
    long maxv;
    long minv;
    
    scanf("%d", &n);
    
    for ( int i = 0; i < n; i++ ) {
        scanf("%ld", &r[i]);
    }
    
    maxv = r[1] - r[0];
    minv = r[0];
    
    for ( int j = 1; j < n; j++ ) {
        if ( r[j] - minv > maxv ) {
            maxv = r[j] - minv;
        }
        if ( r[j] < minv ) {
            minv = r[j];
        }
    }
    
    printf("%ld\n", maxv);
    
    return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	ll sum=0LL;
	ll sz=s.size(),i;
	for(i=0;i<s.size();i++)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9LL)
	{
		cout << "No";
	}
	else
	{
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<cstdio>
using namespace std;
int k,s,cnt;
int main()
{
    scanf("%d%d",&k,&s);
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            if(s-i-j>=0&&s-i-j<=k)cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}

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

int main() {
  string s;
  cin >> s;

  if (s[0]=='R' && s[1]=='R' && s[2]=='R')
  cout << 3 << endl;
  else if (s[0]=='R' && s[1]=='R')
  cout << 2 << endl;
  else if (s[1]=='R' && s[2]=='R')
  cout << 2 << endl;
  else if (s[0]=='R' || s[1]=='R' || s[2]=='R')
  cout << 1 << endl;
  else
  cout << 0 << endl;
}

Measured memory_bytes: 3600
#include <stdio.h>
int main(){
    int i,n,k,s=0;
    scanf("%d",&n);
    for(i=1;i<=n;++i){
        scanf("%d",&k);
        if(k%2)++s;
    }
    if(s%2&&n>1)puts("NO");
    else puts("YES");
    return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# みんなのプロコン 2019：C - When I hit my pocket...


def main():
    K, A, B = [int(i) for i in raw_input().strip().split(' ')]

    if B - A > 2:
        bis = 1

        b = A - 1
        l = K - b
        bis += b

        b = (l / 2) * (B - A)
        l = l - (l / 2) * 2
        bis += b

        bis += l

        print bis
    else:
        print 1 + K


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
const int N_MAX = 1000000;

int main()
{
	int res, st, ed;
	vector<bool> jud(N_MAX, false);
	jud[1] = true;

	for(int i = 1; i <= N_MAX/2; i++)
	{
		if(jud[i])
		{
			jud[i*2] = true;
			if(i*3 <= N_MAX)
			{
				jud[i*3] = true;
			}
			if(i*5 <= N_MAX)
			{
				jud[i*5] = true;
			}
		}
	}

	while(cin >> st, st)
	{
		cin >> ed;
		res = 0;
		for(int i = st; i <= ed; i++)
		{
			if(jud[i])
			{
				res++;
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1316
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t,u;
    int a,b;
    cin>>s>>t;
    cin>>a>>b;
    cin>>u;
    if(u==s){
        a--;
    }else if(u==t) {
        b--;
    }
    cout<<a<< " "<<b<<endl;
    return 0;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}

ll mx=-1,n,m,arr[15],arr1[55][4],q;
void calc(ll a,ll idx)
{

    // if(idx>n or a>m)
    //     return;
    if(idx==n+1)
    {
        // for(ll i=1;i<=n;i++)
        //     cout<<arr[i]<<" ";
        // cout<<endl;
        ll sum=0;
        for(ll i=0;i<q;i++)
        {
            if(arr[arr1[i][1]]-arr[arr1[i][0]]==arr1[i][2])
                sum+=arr1[i][3];
        }
        mx= max(mx,sum);
        return;
    }
    for(ll i=a;i<=m;i++)
    {
        arr[idx]=i;
        calc(i,idx+1);
    }
}

int main()
{

// ll t,i,j,k,n,m,a,b,x,y,u,temp;
cin>>n>>m>>q;
rep(i,0,q)
    rep(j,0,4)
        cin>>arr1[i][j];
calc(1,1);
cout<<mx;
return 0;
}

Measured memory_bytes: 3632
import java.io.PrintWriter

data class Edge(val a: Int, val i: Int, val j: Int)

fun main(args: Array<String>) = with(PrintWriter(System.out)) {
    val n = readLine()!!.toInt()
    val uf = IntArray(n)
    val a = mutableListOf<Edge>()
    for (i in 0 until n) {
        uf[i] = i
        readLine()!!.trim().split(' ').forEachIndexed { j, s ->
            if (j > i-1)
                return@forEachIndexed
            val a_ij = s.toInt()
            if (a_ij != -1)
                a.add(Edge(a_ij, i, j))
        }
    }
    a.sortBy { it.a }

    fun find(_n: Int): Int {
        if (_n == uf[_n]) {
            return _n
        } else {
            uf[_n] = find(uf[_n])
            return uf[_n]
        }
    }

    fun isSame(_i: Int, _j: Int): Boolean {
        return find(_i) == find(_j)
    }

    fun join(_i: Int, _j: Int) {
        uf[find(_i)] = find(_j)
    }

    var sum = 0
    a.forEach{ a_ij ->
        if (!isSame(a_ij.i, a_ij.j)) {
            sum += a_ij.a
            join(a_ij.i, a_ij.j)
        }
    }
    println(sum)
    flush()
}



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

int main() {
	int n;
	cin >> n;
	vector<int> tmp(n);
	for (int i = 0; i < n; ++i) tmp[i] = i + 1;
	do {
		cout << tmp[0];
		for (int i = 1; i < n; ++i) cout << ' ' << tmp[i];
		cout << endl;
	} while (next_permutation(tmp.begin(), tmp.end()));
}


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

int main()
{
	int n;
	scanf("%d", &n);
	long long ans =1;
	long long array[n];
	for(int i=0;i<n;i++){
		scanf("%lld", &array[i]);
	}
	sort(array,array+n);
	for(int i=0;i<n;i++){
		if(array[i]==0){
			printf("0\n");
			return 0;
		}
		ans = ans*array[i];
		if(ans>(long long)(1e18) || ans<=0){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4008
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int MOD;
class mint {
public:
    ll x;
    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;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};


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

    ll N;
    string S;
    cin >> N >> MOD >> S;

    if (MOD != 2 and MOD != 5) {
        vector<mint> f(N+1);
        f[N] = 0;
        f[N-1] = mint(S[N-1] - '0');
        for (ll i = N-1; i > 0; i--) {
            f[i-1] = f[i] + mint(S[i-1]-'0') * mint(10).pow(N-i);
        }

        // for (auto e : f) {
        //     cout << e << "\n";
        // }

        ll ans = 0;
        vec cnt(MOD, 0);
        cnt[0]++;
        for (ll i = N-1; i >= 0; i--) {
            ans += cnt[f[i].x];
            cnt[f[i].x]++;
        }
        cout << ans << endl;
    } else if (MOD == 2) {
        ll ans = 0;
        Rep (i, N) {
            ll num = S[i] - '0';
            if (num == 0 or num == 2 or num == 4 or num == 6 or num == 8) {
                ans += i+1;
            }
        }
        cout << ans << endl;
    } else {
        ll ans = 0;
        Rep (i, N) {
            ll num = S[i] - '0';
            if (num == 0 or num == 5) {
                ans += i+1;
            }
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 2180
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  int n; cin>>n;
  vector<int> vec(n);
  rep(i,n) cin >>vec[i];
  int ans=1000010;
  rep(i,101){
    int sum=0;
    rep(j,n) sum+=(i-vec[j])*(i-vec[j]);
    ans=min(sum,ans);

  }
  cout <<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<long long> ball;
    map<long long, long long> sum;
    for (int i = 0; i < n; i++)
    {
        int temp;
        cin >> temp;
        ball.push_back(temp);
        sum[temp]++;
    }
    long long ans = 0;
    for (map<long long, long long>::iterator it = sum.begin(); it != sum.end(); ++it)
    {
        ans += (it->second - 1) * it->second / 2;
    }
    for (int i = 0; i < n; ++i)
    {
        long long temp = ans;
        temp = temp - (sum[ball[i]] - 1) * sum[ball[i]] / 2 + (sum[ball[i]] - 1 - 1) * (sum[ball[i]] - 1) / 2;
        cout << temp << "\n";
    }
}

Measured memory_bytes: 11120
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
///////////////////////////

#define N 100005
struct edge{
    ll to, cost;
};
vector<edge>v[N];
ll dis[N];
ll dfs(ll id,ll par){
    //dis[id]=0;
    for(auto x:v[id]){
        if(x.to==par)continue;
        Max(dis[id],dfs(x.to,id)+x.cost);
    }
    return dis[id];
}
ll dis2[N];
void dfs2(ll id,ll d_par,ll par){
    vector<ll>come;come.pb(d_par);come.pb(0);
    for(auto x:v[id]){
        if(x.to==par)continue;
        come.pb(dis[x.to]+x.cost);
    }
    sort(come.rbegin(),come.rend());
    dis2[id]=come[0]+come[1];
    
    vector<l_l>res;
    for(auto x:v[id]){
        if(x.to==par){
            res.pb({d_par,x.to});
        }else{
            res.pb({dis[x.to]+x.cost,x.to});
        }
    }
    res.pb({0,-1});
    sort(res.rbegin(),res.rend());
    for(auto x:v[id]){
        if(x.to==par)continue;
        if(x.to==res[0].se){
            dfs2(x.to,res[1].fi+x.cost,id);
        }else{
            dfs2(x.to,res[0].fi+x.cost,id);
        }
    }
}
int main(){fastio
    ll n;cin>>n;
    rep(i,1,n-1){
        ll a,b,c;cin>>a>>b>>c;
        v[a].pb({b,c});
        v[b].pb({a,c});
    }
    dfs(0,-1);
    //rep(i,0,n-1)cout<<dis[i]<<" ";cout<<endl;
    dfs2(0,0,-1);
    //rep(i,0,n-1)cout<<dis2[i]<<" ";cout<<endl;
    ll ans=0;rep(i,0,n-1)Max(ans,dis2[i]);
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 42940
/**
 *  author:   TakeruOkuyama
 *  created:  2020-04-15 11:17:28
**/
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
const int INF = 999999999;

int main(){
    int N, K;
    cin >> N >> K;
    ll ans = K;
    rep(i, N-1){
        ans *= K - 1;
    }
    cout << ans << endl;
return 0;}

/**
 * g++ code.cpp
 * ./a.out
 * shift + ctrl + i
**/ 

Measured memory_bytes: 256
#include<algorithm>
#include<set>
#include<iostream>
#include<cassert>
#include<complex>
#include<vector>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
const double eps = 1e-10;
typedef complex<double> P;
typedef vector<P> Polygon;
#define N 4002


double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

bool isp(P a,P b,P c){
  return abs(a-c)+abs(b-c)<abs(a-b)+eps;
}

bool is_intersected_ls(P a1,P a2,P b1,P b2){
  if ( isp(a1,a2,b1)||isp(a1,a2,b2)||isp(b1,b2,a1)||isp(b1,b2,a2))return true;
  if ( cross(a2-a1,b1-a1)*cross(a2-a1,b2-a1)<0 &&
       cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<0)return true;
  return false;
}

P intersection_ls(P a1,P a2,P b1,P b2){
  P b=b2-b1;
  double d1=abs(cross(b,a1-b1));
  double d2=abs(cross(b,a2-b1));
  double t =d1/(d1+d2);
  return a1+(a2-a1)*t;
}


int make_data(Polygon &a,int y){
  int n = a.size();
  vector<pair<int,int> > block;
  rep(i,n){
    P a1=a[i],a2=a[(i+1)%n];
    P tmp[4];
    tmp[0].real()=-2001;
    tmp[0].imag()=y+1;
    tmp[1].real()=2001;
    tmp[1].imag()=y+1;
    tmp[2].real()=-2001;
    tmp[2].imag()=y;
    tmp[3].real()=2001;
    tmp[3].imag()=y;
    if (is_intersected_ls(a1,a2,tmp[0],tmp[1]) &&is_intersected_ls(a1,a2,tmp[2],tmp[3])){
      P b1=intersection_ls(a1,a2,tmp[0],tmp[1]);
      P b2=intersection_ls(a1,a2,tmp[2],tmp[3]);
      pair<int,int> ins=make_pair((int)floor(min(b1.real(),b2.real())),(int)ceil(max(b1.real(),b2.real())));
      block.push_back(ins);
    }

  }

  int ret=0;
  sort(block.begin(),block.end());

  if ( block.size()!=0){
    int prev=-10000;
    for(int i=0;i<block.size();i+=2){
      ret+=block[i+1].second-max(prev,block[i].first);
      prev=block[i+1].second;
    }
    //cout <<"end"<<endl;
  }
  return ret;
}


int solve(Polygon & a){
  int ret=0;
  REP(i,-2000,2001)ret+=make_data(a,i);


  return ret;
}


main(){
  int n;
  while(cin>>n && n){
    Polygon a;
    P tmp;
    rep(i,n){
      cin>>tmp.real()>>tmp.imag();
      a.push_back(tmp);
    }
    cout << solve(a)<<endl;
  }
}

Measured memory_bytes: 988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define fs first
#define sc second
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<tuple<ll,ll>> vtl;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
void solve(){
    ll n;
    cin>>n;
    vector<string>s(n);
    vl a(5);
    rep(i,n){
        cin>>s[i];
        if(s[i][0]=='M')a[0]++;
        else if(s[i][0]=='A')a[1]++;
        else if(s[i][0]=='R')a[2]++;
        else if(s[i][0]=='C')a[3]++;
        else if(s[i][0]=='H')a[4]++;
}
ll cnt=0;
rep(i,5){
     if(a[i]==0)cnt++;
}
if(cnt>=3){
    cout<<0<<endl;
    return;
}

ll ans=0;
ll d[10]={0,0,0,0,0,0,1,1,1,2};
ll e[10]={1,1,1,2,2,3,2,2,3,3};
ll f[10]={2,3,4,3,4,4,3,4,4,4};
rep(i,10){
    ans+=a[d[i]]*a[e[i]]*a[f[i]];
}
cout<<ans<<endl;
}

int main(){
    cout<<std::fixed<<std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
}



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

int main(){
 
  int K, A, B, c;
  cin >> K;
  cin >> A >> B;
  int largest = (B / K) * K;
  if(A <= largest){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
  
  return 0;
}

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

string number_to_alphabet(long long x){
	if (x <= 26){
		string ans = "";
		char c = 'a' + x - 1;
		ans.push_back(c);
		return ans;
	}else if(x % 26 == 0){
		long long n = x / 26 - 1;
		string ans = number_to_alphabet(n);
		ans.push_back('z');
		return ans;
	}else{
		long long n = x / 26;
		string ans = number_to_alphabet(n);
		char c = 'a' + x % 26 - 1;
		ans.push_back(c);
		return ans;
	}
}

int main() {
	long long x;
	cin >> x;
	cout << number_to_alphabet(x) << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int do_stuff(int n)
{
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    int max_so_far = 0;
    int max_ending_here = 0;

    for (int i = 0; i < n; ++i) {
        int curr = a[i];
        max_ending_here = max(max_ending_here + curr, 0);
        max_so_far = max(max_so_far, max_ending_here);
    }

    if (max_so_far == 0) {
        max_so_far = *max_element(a.begin(), a.end());
    }
    return max_so_far;
}

int main(int argc, char* argv[])
{
    //freopen("input.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    while (n != 0) {
        int ans = do_stuff(n);
        printf("%d\n", ans);
        scanf("%d", &n);
    }
    return 0;
}

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

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    if ( (100 * r + 10 * g + b) % 4 == 0 ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
class SegTree:
  def segfunc(self, x, y):
    return gcd(x, y) #ここ判定関数（ただし結合則があるもの）
  def __init__(self, n, ide_ele, init_val):
    #####単位元######
    self.ide_ele = ide_ele
    #num:n以上の最小の2のべき乗
    self.num = 2 ** (n - 1).bit_length()
    self.seg = [self.ide_ele] * 2 * self.num
    #set_val
    for i in range(N):
      self.seg[i + self.num - 1] = init_val[i]    
    #built
    for i in range(self.num - 2, -1, -1) :
      self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) 
  def update(self, k, x):
    k += self.num - 1
    self.seg[k] = x
    while k + 1:
      k = (k - 1) // 2
      self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) 
  def query(self, p, q):
    if q <= p:
      return self.ide_ele
    p += self.num - 1
    q += self.num - 2
    res = self.ide_ele
    while q - p > 1:
      if p & 1 == 0:
        res = self.segfunc(res, self.seg[p])
      if q & 1 == 1:
        res = self.segfunc(res, self.seg[q])
        q -= 1
      p = p // 2
      q = (q - 1) // 2
    if p == q:
      res = self.segfunc(res, self.seg[p])
    else:
      res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
    return res
sg = SegTree(N, 0, A)
res = 0
for i in range(N):
  res = max(res, gcd(sg.query(0, i), sg.query(i + 1, N)))
print(res)

Measured memory_bytes: 92128
#include <stdio.h>

int main(void){

  int h,w,n;
  scanf("%d %d %d", &h, &w, &n);
  int operation = h;
  if (w > operation) {
    operation = w;
  }
  int answer = n/operation;
  if (n%operation != 0) {
    answer++;
  }
  printf("%d\n", answer);

  return 0;
}

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

long long N, M, R, r[211], A[1 << 18], B[1 << 18], C[1 << 18], dist[211][211], minx = (1 << 30);

int main() {
    cin >> N >> M >> R;
    for (int i = 1; i <= R; i++) cin >> r[i];
    for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) dist[i][j] = (1 << 30); dist[i][i] = 0; }
    for (int i = 1; i <= M; i++) {
        cin >> A[i] >> B[i] >> C[i];
        dist[A[i]][B[i]] = C[i]; dist[B[i]][A[i]] = C[i];
    }
    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
    }
    int G[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
    
    do {
        long long sum = 0;
        for (int i = 0; i < R - 1; i++) sum += dist[r[G[i]]][r[G[i + 1]]];
        minx = min(minx, sum);
    } while (next_permutation(G, G + R));
    
    cout << minx << endl;
    return 0;
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<vector<int>> c(n, vector<int>(26));
    for(int i = 0; i < n; i++){
        cin >> s[i];
        for(int j = 0; j < s[i].size(); j++)
            c[i][s[i].at(j) - 'a']++;
    }
    vector<int> x(26);
    fill(x.begin(), x.end(), 51);
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < n; j++)
            x[i] = min(x[i], c[j][i]);
        for(int j = 0; j < x[i]; j++)
            cout << (char)(i + 'a');
    }
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    ll sum[N+1];
    sum[0] =0;
    ll canNotNum =0;
    for(int i=0;i<N-1;i++){
        sum[i+1] = sum[i] + A[i];
        if(sum[i+1]*2 < A[i+1]){
            // cerr << "can Not A[i]=" << A[i] <<"sum=" <<sum[i+1] << endl; 
            canNotNum = (i+1);
        }
    }
    cout << N- canNotNum << endl;

    return 0;
}

Measured memory_bytes: 1920
S = input()

# 奇数番目の文字を抽出
extract1 = S[::2]
#print(extract1)
odd = extract1.find("L")


# 偶数番目の文字を抽出
extract2 = S[1::2]
#print(extract2)
even = extract2.find("R")

if odd == -1 and even == -1:
    print('Yes')

else:
    print("No")


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

int main(){
    long long a,b;
    long long c,e,f;
    cin >> a >> b;
    vector<vector<long long>> x(16,vector<long long>(40));
    e = a;
    f = b;
    for(int i = 0;i < 8;i ++){
        c = a;
        for(int j = 39;j >= 0;j --){
            x.at(i).at(j) = c % 2;
            c /= 2;
        }
        if(x.at(i).at(39)==1 && x.at(i).at(38)==1 && x.at(i).at(37)==1){
            break;
        }
        if(a == b){
            break;
        }
        a ++;
    }

    for(int i = 8;i < 16;i ++){
        if(b == a){
            break;
        }
        c = b;
        for(int j = 39;j >= 0;j --){
            x.at(i).at(j) = c % 2;
            c /= 2;
        }
        if(x.at(i).at(39)==0 && x.at(i).at(38)==0 && x.at(i).at(37)==0){
            break;
        }
        b --;
    }

    vector<long long> y(40);
    for(int i = 0;i < 40;i ++){
        for(int j = 0;j < 16;j ++){
            y.at(i) += x.at(j).at(i);
        }
    }

    for(int i = 0;i < 40;i ++){
        y.at(i) %= 2;
    }
    long long ans = 0;

    for(int i = 39;i >= 0;i --){
        for(int j = 39;j > i;j --){
            y.at(i) *= 2;
        }
    }

    for(int i = 0;i < 40;i ++){
        ans += y.at(i);
    }

    if(e == f){
        ans = e;
    }


    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  ll ms_process = M*1900+(N-M)*100;
  ll n = (1<<M);
  cout << ms_process * n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int gcd(int x, int y) {
	if (x < y) {
		swap(x, y);
	}
	if (y == 0) {
		return x;
	}
	return gcd(y, x%y);
}

int main() {
	int N, X;
	cin >> N >> X;
	vi x(N);
	REP(i, N) {
		cin >> x[i];
	}

	x.push_back(X);
	sort(ALL(x));
	vi d;
	REP(i, N) {
		d.push_back(x[i + 1] - x[i]);
	}

	int ans = d[0];
	FOR(i, 1, N - 1) {
		ans = gcd(ans, d[i]);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1528