akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  string s;
  cin >> n >> s;
  
  vector<ll> b(n + 1), r(n + 1), g(n + 1);
  b[n] = r[n] = g[n] = 0;

  for (int i = 0; i < n; i++){
    if (s[n-1-i] == 'B'){
      b[n-1-i] = b[n-i] + 1;
      g[n-1-i] = g[n-i];
      r[n-1-i] = r[n-i];
    }
    else if (s[n-1-i] == 'G'){
      b[n-1-i] = b[n-i];
      g[n-1-i] = g[n-i] + 1;
      r[n-1-i] = r[n-i];
    }
    else {
      b[n-1-i] = b[n-i];
      g[n-1-i] = g[n-i];
      r[n-1-i] = r[n-i] + 1;
    }
  }

  /*
  for (int i = 0; i <= n; i++){
    cout << b[i] << " ";
  }
  cout << endl;
  for (int i = 0; i <= n; i++){
    cout << g[i] << " ";
  }
  cout << endl;
  for (int i = 0; i <= n; i++){
    cout << r[i] << " ";
  }
  cout << endl;
  
  */

  ll res = 0;
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R')){
        if (2*j - i < n && s[2*j - i] == 'B'){
          res += b[j + 1] - 1;
        }
        else {
          res += b[j + 1];
        }
      }
      else if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R')){
        if (2*j - i < n && s[2*j - i] == 'G'){
          res += g[j + 1] - 1;
        }
        else {
          res += g[j + 1];
        }
      }
      else if ((s[i] == 'G' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'G')){
        if (2*j - i < n && s[2*j - i] == 'R'){
          res += r[j + 1] - 1;
        }
        else {
          res += r[j + 1];
        }
      }
    }
  }
  
  
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3680
#include <iostream>

void print_rectangle(int& height, int& width);

int main(void)
{
    int width, height;
    while(true) {
        std::cin >> height;
        std::cin >> width;
        if (height == 0 && width == 0) {
            break;
        }
        print_rectangle(height, width);
    }
    return 0;
}

void print_rectangle(int& height, int& width)
{
    int i = 0;
    int j = 0;
    for (i = 0; i < height; ++i) {
        for (j = 0; j < width - 1; ++j) {
            std::cout << "#";
        }
        if (j == width - 1) {
            std::cout << "#" << std::endl;
        }
    } 
    std::cout << "" << std::endl;
}

Measured memory_bytes: 1152
# -*- coding: utf-8 -*-
from functools import lru_cache
from itertools import permutations
import bisect
INF = 2**62-1

def read_str():
    return input().strip()

def slv(A, B, C):
    @lru_cache(maxsize=None)
    def g(x, y):
        m = []
        for i in range(len(x)):
            for j in range(min(len(y), len(x)-i)):
                if not (x[i+j] == '?' or y[j] == '?' or x[i+j] == y[j]):
                    break
            else:
                m.append(i)
        m.append(len(x))
        return m

    def f(x, y, z):
        lx = len(x)
        ly = len(y)
        lz = len(z)
        ans = lx + ly + lz
        xy = g(x, y)
        yz = g(y, z)
        xz = g(x, z)
        xz_set = set(xz)
        for i in xy:
            for j in yz:
                if i + j < lx and i + j in xz_set:
                    s = max(i + ly, i + j + lz, lx)
                elif i + j < lx and i + len(y) :
                    l = bisect.bisect_left(xz, i+ly)
                    if l >= len(xz):
                        continue
                    k = xz[l]
                    s = max(i + ly, k + len(z), len(x))
                elif  i + j >= lx:
                    s = max(i + ly, i + j + lz, lx)
                else:
                    continue
                ans = min(ans, s)
        return ans

    ans = INF
    for a, b, c in permutations((A, B, C)):
        ans = min(ans, f(a, b, c))

    return ans


def main():
    A = read_str()
    B = read_str()
    C = read_str()
    print(slv(A, B, C))



if __name__ == '__main__':
    main()


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

int main() {
    int a, b;
    cin >> a >> b;
    a--; b--;
    vector<bool> ans(3, true);
    ans[a] = false;
    ans[b] = false;
    for (int i = 0; i < 3; i++) {
        if (ans[i]) cout << i+1 << endl;
    }
}

Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int,input().split(" ")))

List1 = [i + A[i] for i in range(N)]
List2 = [i - A[i] for i in range(N)]

ans = 0

CList1 = Counter(List1)
CList2 = Counter(List2)

for i in range(N):
    ans += CList1[i]*CList2[i]
    
print (ans)

Measured memory_bytes: 63520
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;


struct Position {
	Position() {
		x = 0; y = 0;
	}
	Position(int px, int py) {
		x = px;
		y = py;
	}
	int x;
	int y;
	bool operator<(const Position& right) const {
		return (x + y) < (right.x + right.y);
	}
};

void Show(vector<bool> Ps) {
	for (int i = 0; i < Ps.size(); i++) {
		if (Ps[i]) {
			cout << "T" << endl;
		} else {
			cout << "F" << endl;
		}
	}
}

void Show(vector<int> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		cout << Ns[i] << endl;
	}
}



int main() {
	int A,B;
	cin >> A >> B;
	if ((A*B) % 2 != 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

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

#define INF 1e9
template<class T> class treap{
public:
	struct node{
		T val,sum,mini,maxi;
		node *left , *right;
		int pri;
		unsigned sz;
		node(T val,int pri):val(val),sum(val),mini(val),maxi(val),pri(pri),sz(1){
			left = right = NULL;
		}
	};

	node *root;

	treap():root(NULL){
		srand(time(NULL));
	}

	unsigned size(){ return size(root); }
	unsigned size(node *v){ return !v?0:v->sz; }
	T sum(node *v){ return !v?0:v->sum; }
	T MIN(node *v){ return !v?INF:v->mini; }
	T MAX(node *v){ return !v?-INF:v->maxi; }

	node *update(node *v){
		v->sz = size(v->left)+size(v->right)+1;
		v->sum = sum(v->left)+sum(v->right)+v->val;
		v->mini = min( MIN(v->left) , MIN(v->right) );
		v->maxi = max( MAX(v->left) , MAX(v->right) );
		return v;
	}

	node *merge(node *s , node *t){
		if( !s || !t )return s?s:t;
		if( s->pri > t->pri){
			s->right = merge( s->right , t );
			return update(s);
		}
		else{
			t->left = merge( s, t->left);
			return update(t);
		}
	}

	pair<node*,node*> split(node *v,unsigned k){
		
		if(!v)return pair<node*,node*>(NULL,NULL);

		if( k <= size(v->left) ){
			pair<node*,node*> s = split( v->left, k );
			v->left = s.second;
			return make_pair( s.first , update(v) );
		}

		else{
			pair<node*,node*> s = split( v->right, k-size(v->left)-1 );
			v->right = s.first;
			return make_pair( update(v) , s.second );
		}
	}

	node *find(unsigned k){
		node *v=root;
		while(v){
			unsigned s = size(v->left);
			if( s > k ) v = v->left;
			else if( s == k )break;
			else{
				v = v->right;
				k -= s+1;
			}
		}
		return v;
	}

	int getval(int k){
		node *t=find(k);
		return t->val;
	}

	void insert(unsigned k,T val){ root = insert(root,k,val,rand()); }
	node *insert(node *t,unsigned k,T val,int pri){
		pair<node*,node*> s = split(t,k);
		t = merge( s.first , new node(val,pri));
		t = merge( t , s.second );
		return update(t);
	}

	void erase(int k){ root = root->sz==1?NULL:erase( root, k );}
	node *erase(node *t, unsigned k){
		pair<node*,node*>u,v;
		u = split(t,k+1);
		v = split(u.first,k);
		t = merge(v.first,u.second);
		return update(t);
	}

	void range_erase(int l,int r){ root = range_erase( root , l , r );}
	node range_erase(node *t,unsigned k){
		pair<node*,node*>u,v;
	}

	void push_back(T val){ insert(root?root->sz:0,val); }
	void pop_back(){ erase(root->sz-1); }

	void print_array(){
		int k = root->sz;
		cout<<"root value = "<<root->val<<endl;
		cout<<"size of array = "<<k<<endl;
		for(int i = 0; i < k ; i++ ){
			if( i ) cout<<" ";
			cout<<getval(i);
		}
		cout<<endl;
	}
};

int main(){
	treap<int> tri;
	int q;
	cin>>q;
	while(q--){
		int a,b;
		cin>>a;
		if(a!=2)cin>>b;
		if(a==0)tri.push_back(b);
		if(a==2)tri.pop_back();
		if(a==1)cout<<tri.getval(b)<<endl;

	}
	/*while(1){
		int a,b,c;
		cin>>a>>b;

		if(a!=-1)tri.insert(b,a);
		else tri.erase(b);
		tri.print_array();
	}*/
}


Measured memory_bytes: 12376
# include <bits/stdc++.h>
using namespace std;
int main ()
{
	int a,b,c;
	cin>>a>>b>>c;
	long long x=a+b;
	long long  ans;
	if (x==c)
	  { 
	    ans=x+b;
		printf ("%lld\n",ans);	
	  }
	if (x<c)
	  {
	  	ans=x+b+1;
	  	printf ("%lld\n",ans);
	  }
	if (x>c)
	  {
	  	ans=b+c;
	  	printf ("%lld\n",ans);
	  }
	return 0;
 } 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

int main() {

    int N; cin >> N;
    int X;
    int can = 0;
    for (int i = 1; i <= N; i++) {
        int tax_in = i * 1.08;
        if (tax_in == N) {
            X = i;
            can = 1;
        }
    }

    if (can) cout << X << '\n';
    else cout << ":(\n";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int h,n;cin>>h>>n;
    int a[n];
    for(auto& x:a)
    {
    	cin>>x;
    	h-=x;
    }
    if(h<=0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 1024
L,R=map(int, input().split())

if R-L+1>=2019:
    print(0)
else:
    L %= 2019
    R %= 2019
    if L<R:
        m = 2019
        for i in range(L,R+1):
            for j in range(i+1,R+1):
                m = min(m, (i*j)%2019)
        print(m)
    else:
        print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////



//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> cnt(26);
    REP(i, N) {
        cnt[S[i] - 'a'] += 1;
    }
    ll ans = 1;
    REP(i, 26) {
        ans *= (cnt[i]+1);
        ans %= MOD_BIG;
    }
    ans -= 1;
    cout << ans << endl;
    
    return 0;
}


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

int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<10)
	{
		printf("%d\n",b+1000-100*a);
	}
	else
	{
		printf("%d\n",b);
	}
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(a.at(a.at(i)-1)==i+1){
      count++;
    }
  }
  cout << count/2 << endl;
}

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

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    if l // 2019 == r // 2019:
        print((l * (l + 1)) % 2019)
    else:
        print(0)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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


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

// セグメント木
// ref:https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename Mnd>
struct segment_tree {
    int sz;
    vector<Mnd> data;
    function<Mnd(Mnd, Mnd)> f;
    Mnd e;
    //サイズだけ指定して初期化
    segment_tree(int _sz, function<Mnd(Mnd, Mnd)> _f, Mnd _e) : f(_f), e(_e) {
        sz = 1;
        while (sz < _sz) sz <<= 1;
        data.assign(sz * 2, e);
    }
    //参照渡しなので代入とかもできる
    Mnd& operator[](const int& k) {
        return data[k + sz];
    }
    //木を構築 O(n)
    void build() {
        for (int i = sz - 1; i > 0; i--) data[i] = f(data[2 * i], data[2 * i + 1]);
    }
    //更新しつつ木を再構築 O(log n)
    void update(int k, Mnd x) {
        data[k += sz] = x;
        while (k >>= 1) data[k] = f(data[2 * k], data[2 * k + 1]);
    }
    //[a,b)でのクエリに答える　O(log n)
    Mnd query(int a, int b) const {
        Mnd l = e, r = e;
        for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l, data[a++]);
            if (b & 1) r = f(r, data[--b]);
        }
        return f(l, r);
    }
};

int n, m;
vector<pair<int, int>> ab;

int main() {
    cin >> n >> m;
    ab.resize(m);
    for (int i = 0; i < m; i++) {
        cin >> ab[i].first >> ab[i].second;
    }
    auto compare = [](pair<int, int> x, pair<int, int> y) {
        return x.second == y.second ? x.first < y.first : x.second < y.second;
    };
    sort(ab.begin(), ab.end(), compare);
    // cut[i]:i~i+1が切れてるかどうか
    segment_tree<bool> cut(
        n - 1, [](bool p, bool q) { return p || q; }, false);
    int ans = 0;
    for (int i = 0; i < m; i++) {
        if (!cut.query(ab[i].first, ab[i].second)) {
            ans++;
            cut.update(ab[i].second - 1, true);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
using namespace std;
using LL = long long;

set<int>s;
int bigc = 0;
int main(void)
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if (a >= 3200)
		{
			bigc++;
		}
		else
		{
			s.insert(a / 400);
		}
	}
	cout << max<int>(s.size(),1) << " " << s.size() + bigc << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
data = [0] * (10**5+1)
for ai in A:
  data[ai] += 1
for i ,di in enumerate(data):
  if di >= 3 and di%2 == 1:
    data[i] =1
  elif di >= 3:
    data[i] = 2
c1 = c2 = 0
for i,di in enumerate(data):
  if di == 1:
    c1 += 1
  elif di == 2:
    c2 += 1

print(c1+c2//2*2)

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


int main() {
	int n;
	scanf("%d", &n);
	int x[n], y[n];
	for (int i = 0; i < n; i++) scanf("%d%d", x + i, y + i);
	
	double res = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			res += 2.0 / n * std::hypot(x[i] - x[j], y[i] - y[j]);
		}
	}
	printf("%.11f\n", res);
	
	return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn main() {
  input! {
    n: usize,
    a: [usize;n]
  }
  let mut memo: HashMap<usize, bool> = HashMap::new();
  
  for v in a {
    if memo.contains_key(&v) {
      println!("NO");
      return
    } else {
      memo.insert(v, true);
    }
  }
  println!("YES");
}
  

Measured memory_bytes: 12132
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    vector<int>  p(n);
    for(int i = 0; i<n; i++){
        cin>>p[i];
    }
    int count=0;
    for(int i = 1; i<n-1;  i++){
        if(p[i-1] <  p[i] && p[i]<p[i+1]) count++;
        else  if(p[i+1] <  p[i] && p[i]<p[i-1])count++;
    }

    cout <<count<< endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(){
  int a[10];
  rep(i,10){
    cin >> a[i];
    a[i] = -1*a[i];
  }

  sort(a, a+10);
 
  rep(i,3) cout << -1 * a[i] << endl;
 
     
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void) {
	int a, b, c;
	int cnt = 0;
	int i;
	scanf("%d %d %d", &a, &b, &c);
	while (1) {
		
		b -= a;
		
		if (b == 0) {
			cnt++;
			break;
		}
		else if (b < 0) {
			break;
		}
		cnt++;
		if (c <= cnt) {
			break;
		}
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
str = input()
xLoop = int(input())

for x in range(xLoop):
    xCmd= input()
    if xCmd[0:7] == 'replace':
        xCmd,a,b,p = xCmd.split()
        a = int(a)
        b = int(b)
        if a == 0:
            str = p + str[b+1:len(str)]
        else:
            str = str[0:a] + p + str[b+1:len(str)]
        
    elif xCmd[0:7] == 'reverse':
        xCmd,a,b = xCmd.split()
        a = int(a)
        b = int(b)
        p = str[a:b+1]
        p = p[::-1]
        if a == 0:
            str = p + str[b+1:len(str)]
        else:
            str = str[0:a] + p + str[b+1:len(str)]

    else:
        xCmd,a,b = xCmd.split()
        a = int(a)
        b = int(b)+1
        print(str[a:b])


Measured memory_bytes: 5616
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


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

	bool ans = false;
	for(int i = 0; i < s.length(); ++i){
		if(s == t)	ans = true;
		s = s[s.length() - 1] + s.substr(0, s.length() - 1);
	}
	if(ans)	cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }


int main(void) {
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n)cin >> v[i];
	int sum = 0;
	rep(i, n-1) {
		for (int j = i + 1; j < n;j++) {
			sum += v[i] * v[j];
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int func(char *s,char *t,int n){
  int i;
  char c[256];
  int used[256];
  for(i=0;i<256;i++){
    c[i]='\0';
    used[i]=0;
  }
  for(i=0;i<n;i++){
    if(c[(int)s[i]]=='\0'){
      if(used[(int)t[i]]) return 0;
      used[(int)t[i]]=1;
      c[(int)s[i]]=t[i];
    }
    if(c[(int)s[i]]!=t[i]) break;
  }
  return i==n;
}

void run(void){
  char *s=(char *)malloc(sizeof(char)*(200000+1));
  scanf("%s",s);
  char *t=(char *)malloc(sizeof(char)*(200000+1));
  scanf("%s",t);
  int n=0;
  while(s[n]!='\0') n++;
  printf("%s\n",func(s,t,n)?"Yes":"No");  
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b = i_list()
    if b == 1:
        print(0)
    else:
        i = 1
        while (a + (a - 1) * (i - 1) < b):
            i += 1
        print(i)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 10524
"""
a = 'a'*2000
b = 'b'*2000
c = 'c'*2000
"""
a = input()
b = input()
c = input()


len_a = len(a)
len_b = len(b)
len_c = len(c)

def match(a, b):
    return a=='?' or b=='?' or a==b

dp_len=50000
ab = [True] * dp_len
ac = [True] * dp_len
bc = [True] * dp_len

def check(a, b, ab):
    for i in range(len(a)):
        for j in range(len(b)):
            if not match(a[i], b[j]):
                ab[i-j+dp_len//2] = False

check(a, b, ab)
check(a, c, ac)
check(b, c, bc)

len_max = 2000

ans = len_a+len_b+len_c
for i in range(-2*len_max, 2*len_max+1):
    for j in range(-2*len_max, 2*len_max+1):
        if ab[i+dp_len//2] and ac[j+dp_len//2] and bc[j-i+dp_len//2]:
            ans = min(ans, max(len_a, len_b+i, len_c+j) - min(0, i, j))
print(ans)



Measured memory_bytes: 77096
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll gcd(ll a, ll b)
{
    ll tmp;
    ll c;
    if (a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    do
    {
        c = a % b;
        a = b;
        b = c;
    } while (c != 0);

    return a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main(void)
{
    ll a, b, c, d, e;

    cin >> a >> b >> c >> d;

    e = lcm(c, d);

    cout << (b - (b / c + b / d - b / e)) - (a - 1 - (((a - 1) / c + (a - 1) / d - (a - 1) / e))) << endl;
}

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

using ll = long long;
using uint = unsigned int;
template<uint MOD> struct ModInt {
  using M = ModInt;
  uint v;
  ModInt() : v(0) {}
  ModInt(ll _v) { norm(_v % MOD + MOD); }
  M& norm(uint _v) {
    v = (_v < MOD) ? _v : _v - MOD;
    return *this;
  }
  M operator+(const M x) const { return M().norm(v + x.v); }
  M operator-(const M x) const { return M().norm(v + MOD - x.v); }
  M operator*(const M x) const { return M().norm(ll(v) * x.v % MOD); }
  M operator/(const M x) const { return *this * x.inv(); }
  M& operator+=(const M x) { return *this = *this + x; }
  M& operator-=(const M x) { return *this = *this - x; }
  M& operator*=(const M x) { return *this = *this * x; }
  M& operator/=(const M x) { return *this = *this / x; }
  friend istream& operator>>(istream& input, M& x) {
    input >> x.v, x.norm(x.v); return input;
  }
  friend ostream& operator<<(ostream& output, const M& x) {
    return output << x.v;
  }
  M pow(ll n) const {
    M x(v), res(1);
    while (n) {
      if (n & 1) res *= x;
      x *= x;
      n >>= 1;
    }
    return res;
  }
  M inv() const { return (*this).pow(MOD - 2); }

  static vector<M> fact, finv;
  static void build(int n) {
    fact.assign(n + 1, 1);
    finv.assign(n + 1, 1);
    for (int i = 1; i < n + 1; i++) fact[i] = fact[i - 1] * M(i);
    for (int i = 0; i < n + 1; i++) finv[i] = fact[i].inv();
  }
  static M comb(int n, int k) {
    if (n < k || k < 0) return M(0);
    return fact[n] * finv[n - k] * finv[k];
  }
};
template<uint MOD> vector<ModInt<MOD>> ModInt<MOD>::fact = vector<ModInt<MOD>>(); 
template<uint MOD> vector<ModInt<MOD>> ModInt<MOD>::finv = vector<ModInt<MOD>>(); 

const int MOD = 1e6 + 3;

using mint = ModInt<MOD>;

int main() {
  int q;
  cin >> q;
  mint::build(MOD);
  for (int i = 0; i < q; i++) {
    mint x, d;
    int n;
    cin >> x >> d >> n;
    if (d.v == 0) {
      cout << x.pow(n) << endl;
    } else {
      mint q = x / d;
      if (q.v == 0 || q.v + n - 1 >= MOD) {
        cout << 0 << endl;
      } else {
        cout << mint::fact[q.v + n - 1] * mint::finv[q.v - 1] * d.pow(n) << endl;
      }
    }
  }
}


Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int N;
long long int D;
long long int X[200005], Y[200005];

int main(void) {

	cin >> N >> D;
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i];
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (X[i] * X[i] + Y[i] * Y[i] <= D*D) { ans++; }
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6696
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
//#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)  //最大公約数
{
	if (a < b)
		swap(&a, &b);

	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

long power(long x, int n) { //x^n 計算量O(logn)
	long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

int choose(int n, int k) {
	return k == 0 ? 1 : (long long)choose(n - 1, k - 1) * n % MOD * power(k, MOD - 2) % MOD;
}

void bubble_sort(int a[], int n)
{
	int i, j, tmp;

	for (i = 0; i < n; i++)
	{
		for (int k = 0; k < n; k++)
			printf("%d ", a[k]);

		for (j = n - 1; j > i; j--)
		{
			if (a[j - 1] > a[j])
			{
				tmp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = tmp;
			}
		}
		printf("\n");
	}
}

void selection_sort(int a[], int n)
{
	int i, j, tmp, min, key;

	for (i = 0; i < n - 1; i++)
	{
		min = i;
		key = a[i];

		for (int k = 0; k < n; k++)
			printf("%d ", a[k]);

		for (j = i + 1; j < n; j++)
		{
			if (a[j] < a[min])
			{
				min = j;
				key = a[j];
			}
		}

		tmp = a[i];
		a[i] = a[min];
		a[min] = tmp;

		printf("\n");
	}

	for (int k = 0; k < n; k++)
		printf("%d ", a[k]);
}

void insertion_sort(int a[], int n)
{
	int i, j, tmp;

	for (i = 1; i < n; i++)
	{
		j = i;

		while (j >= 1 && a[j - 1] > a[j])
		{
			tmp = a[j];
			a[j] = a[j - 1];
			a[j - 1] = tmp;
			j--;
		}
	}
}

void shell_sort(int a[], int n)
{
	int h, i, j;

	for (h = 1; h < n / 9; h = h * 3 + 1)
		;

	for (; h > 0; h /= 3)
	{
		for (int k = 0; k < n; k++)
			printf("%d ", a[k]);

		for (i = h; i < n; i++)
		{
			j = i;
			while (j >= h && a[j - h] > a[j])
			{
				swap(&a[j - h], &a[j]);
				j -= h;
			}
		}
		printf("\n");
	}

	for (int k = 0; k < n; k++)
		printf("%d ", a[k]);
}

int partition(int a[], int l, int r)
{
	int i, j, pivot;

	i = l - 1;
	j = r;
	pivot = a[r];

	for (;;)
	{
		while (a[++i] < pivot)
			;
		while (i < j-- && pivot < a[j])
			;

		if (i >= j)
			break;

		swap(&a[i], &a[j]);
	}

	swap(&a[i], &a[r]);
	return i;
}

void quick_sort1(int a[], int l, int r)
{
	int v;

	if (l >= r)
		return;

	v = partition(a, l, r);

	quick_sort1(a, l, v - 1);
	quick_sort1(a, v + 1, r);
}

void quick_sort(int a[], int n)
{
	quick_sort1(a, 0, n - 1);
}

int keta(int a,int n)
{
	if (n == 1)
		return a % 10;

	for (int i = 0; i < n-1; i++)
		a /= 10;

	return a % 10;
}

int main()
{
	int M, L, K;
	int A, B;
	int a[100000];
	char S[5];

	scanf("%d%d", &A, &B);


	for (int i = 1; i < 10000000; i++)
	{

		if ((int)((double)i * 0.08) == A && (int)((double)i * 0.1) == B)
		{
			printf("%d", i);
			return 0;
		}
	}
	printf("-1");
}

Measured memory_bytes: 256
import math

Mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))
Ld = dict()

for a in A:
    #因数分解
    D = dict()
    ra = math.floor(math.sqrt(a))
    if ra>1:
        for i in range(2,ra+1):
            while a%i == 0:
                D[i] = D.get(i,0) + 1
                a //= i
            if a == 1:
                break
        
    if a > 1:
        D[a] = D.get(a,0) + 1

    for d in D:
        Ld[d] = max(Ld.get(d,0), D[d])

lcm = 1
for l in Ld:
    lcm *= pow(l,Ld[l],Mod)
    lcm %= Mod

ans = 0
for a in A:
    ans += ( lcm*pow(a,Mod-2,Mod)) %Mod
    ans %= Mod

print(ans)

Measured memory_bytes: 4596
//
// Created by elegant-belltree on 15/06/03.
//

#include <iostream>

#define N 123456

using namespace std;

bool not_p[2*N];
int num_p[2*N];

int main(int argc, char *argv[]) {
    int n;

    for (int k = 1; k < 2*N; ++k) {
        if(!not_p[k]){
            for (int i = 2; i*(k+1)-1<2*N; ++i) {
                not_p[i*(k+1)-1]=true;
            }
        }
        num_p[k]+=num_p[k-1]+!not_p[k];
    }
    while (cin>>n && 0<n){
        cout<<num_p[2*n-1]-num_p[n-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2364
#include <stdio.h>

int main(){
  int N,L,S=0;
  scanf("%d %d",&N,&L);
  S=N*L+(N*(N-1))/2;
  if(L>=0) S-=L;
  else if(L+(N-1)<0) S-=L+(N-1);
  printf("%d\n",S);
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
ll dp[200005],a[200005],n;
ll solve(ll idx)
{
    if(idx>=n-1)
        return 0;
    if(dp[idx]!=-1)
        return dp[idx];
    ll res=INT_MAX;
    if(idx+1<n)
        res=min(res,abs(a[idx+1]-a[idx])+solve(idx+1));
    if(idx+2<n)
        res=min(res,abs(a[idx+2]-a[idx])+solve(idx+2));
    return dp[idx]=res;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,x,y,z,m,t,l,r;
    cin>>n;
    for(i=0; i<n; i++)
        cin>>a[i];
    memset(dp,-1,sizeof dp);
    cout<<solve(0)<<'\n';
}








Measured memory_bytes: 10660
from scipy.special import comb


s = int(input())

if s < 3:
    print(0)
else:

    count = 0
    total = 0

    while True:
        s = s-3
        count += 1

        if s >= 0:
           total += comb(s+count-1, count-1 ,exact=True)
           total = total% (10**9+7)
        else:
            break

    print(int(total ))


Measured memory_bytes: 41844
#include "bits/stdc++.h"
using namespace std;

int main() {
    string n;
    cin >> n;
    if ( (n[0]==n[1]&&n[1]==n[2]) || (n[1]==n[2]&&n[2]==n[3]) ) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int pm,pe,pj,n;
  while(cin>>n){
    if(n==0) break;
    for(int i=0;i<n;i++){
      cin >> pm >> pe >> pj;
      if(pm==100||pe==100||pj==100) cout << 'A' << endl;
      else if((pm+pe)/2>=90) cout << 'A' << endl;
      else if((pm+pe+pj)/3>=80) cout << 'A' << endl;
      else if((pm+pe+pj)/3>=70) cout << 'B' << endl;
      else if((pm+pe+pj)/3>=50&&pm>=80||pe>=80)	cout << 'B' << endl;
      else cout << 'C' << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

int main(){
  int i,j,k;
  int a[10];
  for(i=0; i<10; i++){
    scanf("%d", &a[i]);
  }
  
  for(i=0; i<10; i++){
     for(j=i+1; j<10; j++){
        if(a[i]<a[j]){
          k= a[i];
          a[i]=a[j];
          a[j]=k;
        }
     }
  }
  printf("%d\n%d\n%d\n",a[0],a[1],a[2]);
   return 0;
}

Measured memory_bytes: 600
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC101 {
    class C {
        static void Main() => CustomMain();

        static void Solve() {
            int n, k;
            ReadMulti(out n, out k);
            var a = ReadIntArray();

            var ans = 0;
            while (0 < n) {
                if (ans == 0) {
                    n -= k;
                } else {
                    n -= k - 1;
                }

                ans++;
            }

            WriteAnswer(ans);
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);
    }
}

Measured memory_bytes: 16992
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef complex<double> comp;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll MOD=998244353;
const ll mod=MOD;
const int MAX=200010;

signed main(){
    string s;cin>>s;
    ll n=s.size();
    if(s[n-1]=='s')s+="es";
    else s+="s";
    cout<<s<<endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
#pragma intrinsic(_umul128)
using namespace std; using namespace atcoder;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//--------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, Q;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q;

	dsu uf(N);
	rep(q, 0, Q) {
		int t, u, v; cin >> t >> u >> v;
		if (t == 0) uf.merge(u, v);
		else {
			printf("%d\n", uf.same(u, v) ? 1 : 0);
		}
	}
}







Measured memory_bytes: 4000
import java.util.ArrayList;
import java.util.Scanner;

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

        int n = in.nextInt();
        int m = in.nextInt();
        int[] a = new int[m];
        ArrayList<ArrayList<Integer>> b = new ArrayList<>();
        for (int i = 0; i < m; ++i) {
            b.add(new ArrayList<>());
        }
        for (int i = 0; i < m; ++i) {
            a[i] = in.nextInt();
            int x = in.nextInt();
            for (int j = 0; j < x; ++j) {
                b.get(i).add(in.nextInt() - 1);
            }
        }

        int[] dp = new int[(1 << n)];
        dp[0] = 0;
        for (int i = 1; i < (1 << n); ++i) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 0; j < m; ++j) {
                int x = i;
                for (int y: b.get(j)) {
                    x ^= (x & (1 << y));
                }
                if (x < i && dp[x] != Integer.MAX_VALUE) {
                    dp[i] = Math.min(dp[x] + a[j], dp[i]);
                }
            }
        }

        if (dp[(1 << n) - 1] != Integer.MAX_VALUE) {
            System.out.println(dp[(1 << n) - 1]);
        } else {
            System.out.println(-1);
        }
    }
}


Measured memory_bytes: 61420
#include <iostream>
#include <string>

using namespace std;

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

  return 0;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn adjacent4(x: usize, y: usize, sx: usize, sy: usize) -> Vec<(usize, usize)> {
    [(-1, 0), (1, 0), (0, -1), (0, 1)]
        .into_iter()
        .filter_map(|&(dx, dy)| {
            let nx = x as isize + dx;
            let ny = y as isize + dy;
            if nx >= 0 && nx < sx as isize && ny >= 0 && ny < sy as isize {
                Some((nx as usize, ny as usize))
            } else {
                None
            }
        })
        .collect()
}

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
fn main() {
    input! {
        a: usize,
        b: usize,
    }
    // 初期値1でa-１個ずつ増える。つまりa-1個ずつ増やしてb-1口増やしたい
    let ans = (b - 1 + (a - 2)) / (a - 1);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	ll n, m;
	string s, t;

	cin >> n >> m >> s >> t;

	ll lcm = LCM(n, m);
	
	ll a = lcm/n, b = lcm/m; // a, bは互いに素
	ll k = a*b; // a, bのLCMはa*b

	ll pos = 0;
	ll spos = 0, tpos = 0;
	while(pos < lcm){
		if(s[spos] != t[tpos]){
			cout << -1 << endl;
			return 0;
		}

		pos += k;
		spos += b;
		tpos += a;
	}
	cout << lcm << endl;
	
	return 0;
}

Measured memory_bytes: 640
N,M = map(int,input().split())
ld = [[]]
for i in range(M):
  ld.append(list(map(int,input().split())))
lp = [0]+list(map(int,input().split()))

ans = 0
for i in range(2**N):
  bs = format(i,"0{}b".format(N+1))
  det = 1
  for j in range(1,M+1):
    c = 0
    for k in ld[j][1:ld[j][0]+1]:
      if int(bs[k]) == 1:
        c += 1
    if c%2 != lp[j]:
      det = 0
      break 
  if det == 1:
    ans += 1
print(ans)  

Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b) {
    if(b <= 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b) {
    return (a * b) / gcd(a,b);
}

int main(int argc,char ** argv) {
    string s,t;
    int p,q;
    cin >> p >> q;
    cin >> s >> t;
    ll n = lcm(s.size(),t.size());
    ll z = n / s.size(),x = n/ t.size();
    map<ll,char> r;
    for(int i = 0;i < s.size();i++) {
        r[i*z] = s[i];
    }
    for(int i = 0;i < t.size();i++) {
        if(r[i*x] != NULL && r[i*x] != t[i]) {
            cout << -1;
            return 0;
        }
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 10880
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int A,B;

signed main(){

    in(A,B);
    puts(A%3==0||B%3==0||(A+B)%3==0?"Possible":"Impossible");

    return 0;
}


Measured memory_bytes: 888