akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

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

	int s=-1,e=-1;
	for(int i=0;i<str.size();i++){
		int a[29] = {0};
		for(int k=0;k<3;k++){
			if(k+i>=str.size()){
				break;
			}
			int c = str[k+i]-'a';
			a[c]++;
			if(a[c]==2){
				s=i+1;
				e=i+k+1;
				break;
			}
		}
		if(s!=-1){
			break;
		}
	}
	
	cout << s << " " << e << endl;
}

Measured memory_bytes: 512
import java.math.BigInteger
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main(args: Array<String>) {
    val (n, a, b) = readLongs()
    if (a == 0L) {
        println(0)
    } else {
        val m = n % (a + b)
        val r = ((n - m) / (a + b)) * a + Math.min(a, m)
        println(r)
    }
}


Measured memory_bytes: 38016
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
var line = chunk.toString().split('\n');
var seconds = Number(line[0]);
var hour_sec = 60*60;
var minute_sec = 60;

var hour = Math.floor(seconds / hour_sec);
var minute = Math.floor((seconds % hour_sec) / minute_sec);
var sec = seconds % hour_sec % minute_sec;
console.log(hour + ':'+minute+':'+sec);
});

Measured memory_bytes: 15540
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
using namespace std;

int main(void) {
  int k, n;
  cin >> k >> n;
  
  vector<int> a(n);
  
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a.push_back(k+a[0]);
  int MaxEdge = 0;
  
  for (int i = 0; i < n; i++) {
    MaxEdge = max(MaxEdge, a[i+1] - a[i]);
  }
  
  int ans = k - MaxEdge;
  
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 5e5 + 5; 
using namespace std;

int n, cnt, dfn[N], low[N], bl[N], rt; 
struct node
{
	int x, id;
	node(int a = 0, int b = 0) { x = a, id = b; }
	bool operator < (const node &p) const { return x < p.x; }
} p[N]; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

namespace Graph
{
	int head[N], cnte, tim, top, scc, instk[N], stk[N]; 
	struct edge { int to, nxt; } e[N << 1]; 
	inline void adde(int u, int v) { e[++cnte] = (edge) { v, head[u] }, head[u] = cnte; }
	void tarjan(int u)
	{
		dfn[u] = low[u] = ++tim, instk[stk[++top] = u] = 1; 
		for(int v, i = head[u]; i; i = e[i].nxt)
		{
			v = e[i].to; 
			if(!dfn[v]) tarjan(v), low[u] = min(low[u], low[v]); 
			else if(instk[v]) low[u] = min(low[u], dfn[v]); 
		}
		if(low[u] >= dfn[u])
		{
			int x; scc++; 
			do { x = stk[top--], instk[x] = 0, bl[x] = scc; } while(x != u); 
		}
	}
	void clear()
	{
		for(int i = 1; i <= cnt; i++) dfn[i] = low[i] = bl[i] = head[i] = 0; 
		scc = tim = top = cnte = 0; 
	}
};
int op(int x) { return x > n ? x - n : x + n; }
struct SegTree
{
	struct Tree { int l, r; } t[N << 2]; 
	void clear() { for(int i = 1; i <= cnt; i++) t[i].l = t[i].r = 0; }
	void build(int &o, int l, int r)
		{
			if(!o) o = ++cnt;
			if(l == r) return Graph :: adde(o, op(p[l].id)); 
			int mid = (l + r) >> 1; 
			build(t[o].l, l, mid), build(t[o].r, mid + 1, r); 
			Graph :: adde(o, t[o].l), Graph :: adde(o, t[o].r); 
		}
	void add(int p, int l, int r, int ql, int qr, int x)
		{
			if(ql <= l && r <= qr) return Graph :: adde(x, p); 
			int mid = (l + r) >> 1;
			if(ql <= mid) add(t[p].l, l, mid, ql, qr, x); 
			if(mid < qr) add(t[p].r, mid + 1, r, ql, qr, x); 
		}
} T; 

bool check(int mid)
{
	Graph :: clear(), T.clear(), rt = 0, cnt = 2 * n; 
	T.build(rt, 1, 2 * n); 
	for(int x, i = 1; i <= 2 * n; i++)
	{
		x = upper_bound(p + 1, p + 2 * n + 1, node(p[i].x - mid)) - p; 
		if(x < i) T.add(rt, 1, 2 * n, x, i - 1, p[i].id); 
		x = lower_bound(p + 1, p + 2 * n + 1, node(p[i].x + mid)) - p - 1;
//		x = upper_bound(p + 1, p + 2 * n + 1, node(p[i].x + mid - 1)) - p - 1; 
		if(x > i) T.add(rt, 1, 2 * n, i + 1, x, p[i].id); 
	}
	for(int i = 1; i <= cnt; i++) if(!dfn[i]) Graph :: tarjan(i); 
	for(int i = 1; i <= n; i++) if(bl[i] == bl[i + n]) return 0; 
	return 1; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp7.in", "r", stdin); 
#endif
	n = read <int> ();
	for(int i = 1; i <= n; i++)
		p[i].x = read <int> (), p[i].id = i, p[i + n].x = read <int> (), p[i + n].id = i + n; 
	sort(p + 1, p + 2 * n + 1); 
	int l = 0, r = p[2 * n].x - p[1].x + 1, mid, ans = 0; 
	while(l <= r)
	{
		mid = (l + r) >> 1;
		if(check(mid)) ans = mid, l = mid + 1; 
		else r = mid - 1; 
	}
	printf("%d\n", ans); 
	return 0; 
}


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


int main(){


 int n;
 cin>>n;

 set<int>ani;

 for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
        ani.insert(i*j);
    }
 }

 if(ani.count(n))
    cout<<"Yes"<<endl;
 else
    cout<<"No"<<endl;


return 0;
}


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

#define REP(i, n) for(int i=0; i<n;i++)
#define REPR(i, n) for(int i=n-1 ; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)

#define INF 2e9
#define ll long long

int main(){
    int n, i, j;
    cin>>n;
    int p[n], q[n];
    for(i=0; i<n; i++){
        cin>>p[i];
        q[i] = p[i];
    }

    sort(q, q+n);
    int ans = 0;
    for(i=0; i<n; i++){
        if(q[i] != p[i]){
            ans++;
        }
    }

    if(ans<=2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
        return 0;
    
}

Measured memory_bytes: 256
/*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1165&lang=jp*/

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int num;
    pair<int,int> direction[]={{-1,0},{0,1},{1,0},{0,-1}};


    while(cin>> num && 0< num){
        vector<int> x;
        vector<int> y;

        x.push_back(0);
        y.push_back(0);
        for (int i = 1; i < num; ++i) {
            int n,d;

            cin>>n>>d;
            x.push_back(x[n]+direction[d].first);
            y.push_back(y[n]+direction[d].second);
        }
        cout<<*max_element(x.begin(),x.end())-*min_element(x.begin(),x.end())+1<<" "<<*max_element(y.begin(),y.end())-*min_element(y.begin(),y.end())+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1216
fun main(args: Array<String>){
  val n = readLine()!!.toLong()
  
  val sqrt = Math.sqrt(n.toDouble()).toInt()
  
  for( i in sqrt downTo 1 )
    if( n % i.toLong() == 0L ){
      println( i + n/i - 2 )
      break
    }
}


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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
const ll MOD1 = 998244353;
//typedef pair<int,int> P;

#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 REP(i,n) rep(i,0,n)
#define RREP(i,n) rrep(i,n,0)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

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

  int a,b;
  cin >> a >> b;
  cout << a - b + 1 << endl;

  return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int a = sc.nextInt();
			if(a==0)break;
			int[] n = new int[12];
			boolean flag = true;
			int sum = 0;
			
			for(int i=0;i<12;i++){
				n[i] = sc.nextInt() - sc.nextInt();
			}
			
			for(int i=0;i<12;i++){
				sum += n[i];
				if(sum>=a){
					System.out.println((i+1));
					flag = false;
					break;
				}
			}
			if(flag==true)System.out.println("NA");
		}
	}	
}

Measured memory_bytes: 32876
#include <stdio.h>

int main(){

  int a, i, j, n, min, minI, sum=0;
  int A[100][100], flag[100], t[100];

  scanf("%d", &n);

  for(i = 0; i < n ; i++){
    flag[i] = 0;
    t[i] = 2001;
  }
  t[0] = 0;

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &A[i][j]);
    }
  }

  // 
  for(a = 0; a < n - 1; a++){
    min = 2001;
    for(i = 0; i < n; i++){
      if(t[i] < min && flag[i] == 0){
	min = t[i];
	minI = i;
      }
    }
    flag[minI] = 1;

    for(i = 0; i < n; i++){
      if(A[minI][i] != -1 && A[minI][i] < t[i] && flag[i]==0){
	t[i] = A[minI][i];
      }
    }

  }

  for(i = 0; i < n; i++){
    sum += t[i];
  }
  printf("%d\n", sum);



  return 0;
}

Measured memory_bytes: 636
import sys


if __name__ == "__main__":
    N, W = map(lambda x: int(x), input().split())
    items = [(0, 0)] * N
    for i in range(N):
        v, w = map(lambda x: int(x), input().split())
        items[i] = (v, w)
    table = [-sys.maxsize] * (W + 1)
    table[0] = 0

    for weight in range(W):
        for idx in range(N):
            if (-sys.maxsize == table[weight]):
                continue
            if (weight + items[idx][1] <= W):
                table[weight + items[idx][1]] = max(
                    table[weight + items[idx][1]], table[weight] + items[idx][0])

    print(max(table))



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

using namespace std;

const int N = 1234567;

int n, k, l;
int from_k[N], from_l[N];
map<pair<int, int>, int> ma;

int find(int x, int from[]) {
  if (x == from[x]) return x;
  return from[x] = find(from[x], from);
}

int main() {
  scanf("%d %d %d", &n, &k, &l);
  for (int i = 0; i < n; i++) {
    from_k[i] = i;
    from_l[i] = i;
  }
  for (int i = 0; i < k; i++) {
    int a, b; scanf("%d %d", &a, &b);
    a--, b--;
    int x = find(a, from_k), y = find(b, from_k);
    if (x != y) {
      from_k[x] = y;
    }
  }
  for (int i = 0; i < l; i++) {
    int a, b; scanf("%d %d", &a, &b);
    a--, b--;
    int x = find(a, from_l), y = find(b, from_l);
    if (x != y) {
      from_l[x] = y;
    }
  }
  for (int i = 0; i < n; i++) {
    pair<int, int> pr = make_pair(find(i, from_k), find(i, from_l));
    ma[pr]++;
  }
  for (int i = 0; i < n; i++) {
    if (i > 0) putchar(' ');
    pair<int, int> pr = make_pair(find(i, from_k), find(i, from_l));
    printf("%d", (int) ma[pr]);
  }
  return 0;
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}


signed main(){
  string s;
  int w;
  cin>>s>>w;
  int idx=0;
  while(idx<s.size()){
    cout<<s[idx];
    idx+=w;
  }

  return 0;
}


Measured memory_bytes: 256
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)
 
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}
 

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


int n;
ll arr[100005];


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>arr[i];

    ll ans1 = 0, sum = 0;
    for(int i=1,need=1;i<=n;i++,need*=-1){
        sum += arr[i];
        if(need == 1){
            if(sum > 0) continue;
            ans1 += 1 - sum;
            sum = 1;
        }
        else{
            if(sum < 0) continue;
            ans1 += sum - (-1);
            sum = -1;
        }
    }

    ll ans2 = 0; sum = 0;
    for(int i=1,need=-1;i<=n;i++,need*=-1){
        sum += arr[i];
        if(need == 1){
            if(sum > 0) continue;
            ans2 += 1 - sum;
            sum = 1;
        }
        else{
            if(sum < 0) continue;
            ans2 += sum - (-1);
            sum = -1;
        }
    }

    cout<<min(ans1, ans2);
    return 0;
}











Measured memory_bytes: 1024
M,D = (int(i) for i in input().split())
ans = 0
for m in range(1,M+1):
    for d in range(1,D+1):
        hoge = [int(s) for s in str(d)]
        if len(hoge) == 1: hoge.insert(0,0)
        do,dt = hoge
        if do >= 2 and dt >= 2 and dt*do == m:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string n;
    cin >> n;
    long long t=0;
    for (int i=0; i<n.size(); ++i)
    {
        t+=(n[i]-'0');
        t=t%9;
    }
    if (t==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

int main(){
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2);
    if(accumulate(a.begin(), a.end(), 0) >= 22)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def GCM(a, b):
  if a < b:
    a, b = b, a
  r = a % b
  if r == 0:
    return b
  else:
    return GCM(b, r)

A, B = map(int, input().split())
g = GCM(A, B)
print((A//g)*B)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
	int ai[3]={0},aa[3]={0},bi[3]={0},ba[3]={0},ci[3]={0},ca[3]={0};
	int i,af,bf,cf,ae,be,ce;
	for(i=0;i<=2;i++){
		scanf("%d",&ai[i]);
	}
	for(i=0;i<=2;i++){
		scanf("%d",&aa[i]);
	}
	for(i=0;i<=2;i++){
		scanf("%d",&bi[i]);
	}
	for(i=0;i<=2;i++){
		scanf("%d",&ba[i]);
	}
	for(i=0;i<=2;i++){
		scanf("%d",&ci[i]);
	}
	for(i=0;i<=2;i++){
		scanf("%d",&ca[i]);
	}
	ae=ai[0]*3600+ai[1]*60+ai[2];
	be=bi[0]*3600+bi[1]*60+bi[2];
	ce=ci[0]*3600+ci[1]*60+ci[2];
	af=aa[0]*3600+aa[1]*60+aa[2];
	bf=ba[0]*3600+ba[1]*60+ba[2];
	cf=ca[0]*3600+ca[1]*60+ca[2];
	ae=af-ae;
	be=bf-be;
	ce=cf-ce;
	ai[0]=ae/3600;
	ae=ae%3600;
	ai[1]=ae/60;
	ae=ae%60;
	ai[2]=ae;
	bi[0]=be/3600;
	be=be%3600;
	bi[1]=be/60;
	be=be%60;
	bi[2]=be;
	ci[0]=ce/3600;
	ce=ce%3600;
	ci[1]=ce/60;
	ce=ce%60;
	ci[2]=ce;
	printf("%d %d %d\n%d %d %d\n%d %d %d\n",ai[0],ai[1],ai[2],bi[0],bi[1],bi[2],ci[0],ci[1],ci[2]);
	return 0;
}

Measured memory_bytes: 600
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.split_whitespace()
    .map(|x| x.parse().ok().unwrap())
    .collect()
}

fn main() {
  let v: Vec<usize> = read_vec();
  let (n, m) = (v[0], v[1]);
  let light: Vec<Vec<usize>> = (0..m).map(|_| read_vec()).collect();
  let p: Vec<usize> = read_vec();

  let ans = (0..1 << n)
    .filter(|i| {
      (0..m).all(|j| {
        let cnt = &light[j][1..]
          .iter()
          .filter(|&s| i & (1 << (s - 1)) > 0)
          .count();
        cnt % 2 == p[j]
      })
    })
    .count();
  println!("{}", ans);
}


Measured memory_bytes: 4352
import sys
bbn=1000000007

#+++++



		
def main():
	n = int(input())
	aal = list(map(int, input().split()))
	cc=[0,0,0]
	total_count=1
	for nh in aal:
		nc = cc.count(nh)
		total_count = (total_count * nc ) % bbn
		if total_count == 0:
			return 0
		
		ii=cc.index(nh)
		#pa((cc, total_count,ii,nh,nc))
		cc[ii]+=1
		
	print(total_count)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 14092
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 1000005
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
  scanf("%d",&head);
  RI(tail...);
}
using namespace std;
typedef long long LL;
int ar[M];
int vis[M];
int f(int x) {
	if(x&1) return 3*x + 1;
	return x/2;
}
int main()
{  
	int s;
	cin >> s;
	vis[s]++;
	for(int i = 1;; i++) {
		ar[i] = f(s);
		s = ar[i];
		vis[s]++;
		if(vis[s] == 2) {
			cout << i+1 << endl;
			break;
		}
	}
  return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

 
int main(){
	int n;
	cin>>n;
	vector<int>p(n);
	rep(i,n)cin>>p[i];
	int cnt=0;
	rep(i,n){
		if(p[i]==i+1){
			cnt++;
			if(i!=n-1){
			    swap(p[i],p[i+1]);
			}else{
				swap(p[i],p[i-1]);
			}
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 640
'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''
'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''
'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''
'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''
'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
'''
リスト同士の演算
list(map(lambda x, y: x+y, el2, el3))
'''
'''
配列の初期化
配列名=[a]*n+[b]*m
'''
'''
重複
list(set())
２次元配列
list(map(list, set(map(tuple, addition))))
'''
'''
順列
for el in itertools.permutations(配列のパターン):
'''
'''
Decimal()
'''
# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()




from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul
def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


d = stdin.readline().rstrip().split()
a = d[0]
b = d[1]
if a != b:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 40564
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    string s;cin >> s;
    ll t = s[0] - 'a';
    cout << char('a' + t + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int N;
VVI X(200200,VI(0));
VI D(200200);
VI O(0);

void dfs(int s){
  int now=s;
  D[s]=1;
  O.pb(now);
  rep(i,X[s].size()){
    int nxt=X[s][i];
    if(!D[nxt]) dfs(nxt);
  }
  O.pb(now);
}

int main(){
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  VI U(N-1),V(N-1);
  rep(i,N-1) cin>>U[i]>>V[i];
  rep(i,N-1){
    X[U[i]-1].pb(V[i]-1);
    X[V[i]-1].pb(U[i]-1);
  }
  dfs(0);
  VI F(N);
  VI dp(N);
  rep(i,N) dp[i]=1001001001;
  stack<PII> S;
  VI ans(N);
  rep(i,O.size()){
    if(!F[O[i]]){
      F[O[i]]++;
      int tmp=lb(all(dp),A[O[i]])-dp.begin();
      S.push(mp(tmp,dp[tmp]));
      dp[tmp]=min(dp[tmp],A[O[i]]);
    }else{
      ans[O[i]]=lb(all(dp),1001001001)-dp.begin();
      dp[S.top().first]=S.top().second;
      S.pop();
    }
  }
  rep(i,N) cout<<ans[i]<<endl;
}


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

int main() {
	int n;
  	cin>>n;
  
  int sum=0;
  int ma=0;
  
  int l[n];
  rep(i,n){cin>>l[i];
           sum+=l[i];
          if(ma<=l[i]){
          	ma=l[i];
          }
       }
  
  if(ma<sum-ma){
  	cout<<"Yes"<<endl;
  }
 
  else{
  	cout<<"No"<<endl;
  }
  
  
  
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
	long long a = rng();
    return a;
}
long long prv[200002], lst[200002];
long long n, dp[200002], v[200002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        cin >> v[i];
        if(lst[v[i]])
            prv[i] = lst[v[i]];
        lst[v[i]] = i;
    }
    dp[0] = 1;
    for(int i = 1; i <= n; ++i)
    {
        dp[i] = dp[i-1];
        if(prv[i] && prv[i] != (i - 1))
            dp[i] = (dp[i] + dp[prv[i]]) % mod;
    }
    cout << dp[n];
    return 0;
}



Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に

int main()
{
    ll N,A,B;
    cin >> N >> A >> B;
    if(N==1){
        if(A==B){
            cout << 1 << endl;
        }    
        else{
            cout << 0 << endl;
        }
    }
    else{
        if(A>B){
            cout << 0 << endl;
        }
        else if(A==B){
            cout << 1 << endl; 
        }
        else{
            cout << (B-A)*(N-2)+1 << endl;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
l = list(map(int,input().split()))

cnt_t = 0
cnt_f = 0

for i in l:
  if i%4==0:
    cnt_f += 1
  elif i%2==0:
    cnt_t += 1

num = N-cnt_t-cnt_f

if cnt_t == 0:
  cnt_f += 1
if num <= cnt_f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 15020
def partition(A, p, r):
  x = A[r]
  i = p - 1
  for j in range (p, r):
    if A[j]  <= x:
      i += 1
      A[i], A[j] = A[j], A[i]
  A[i+1], A[r] = A[r],A[i + 1]
  return i + 1

n = int(input())
a = list(map(int, input().split()))
i = partition(a, 0, n-1)
a[i] = "[" + str(a[i]) + "]"
print(" ".join(map(str, a)))



Measured memory_bytes: 16392
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i = a; i<n; i++)
#define per(i,a,n) for (int i = n-1; i>=a; i--)
#define pb push_back
#define mp make_pair
#define all(now) (now).begin(),(now).end()
#define fi first
#define se second
#define SZ(now) ((int)(now).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod = 1000000007;
inline int read(int &n){char c=getchar();int x=0,f=1;while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+(c-'0');c=getchar();}return n = x*f;}
ll powmod(ll a,ll b,ll mod) {ll res = 1; a%=mod; assert(b>=0); for(;b; b>>=1){if(b&1)res = res*a%mod; a = a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N = 7e2+7;
int T,n,m;
bool f[N][N], g[N][N];
int col[N], ans = 0x7fffffff, now, num[3];
inline int Get(int x){ return x*(x-1)>>1;}
bool dfs(int x, int c)
{
    col[x] = c, num[c]++;
    rep(i,1,n+1) if(!g[x][i]) {
        if(!col[i] && !dfs(i,3-c))
            return 0;
        else if(col[i]==c)
            return 0;
    }
    return 1;
}
int main()
{
    //ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    rep(i,1,m+1){
        int u, v;
        scanf("%d%d", &u, &v);
        g[u][v] = 1, g[v][u] = 1;
    }
    f[0][0] = 1;
    rep(i, 1, n + 1) g[i][i] = 1;
    rep(i,1,n+1) if(!col[i]) {
        num[1] = num[2] = 0;
        if(!dfs(i,1)){
            puts("-1");
            return 0;
        }

        now++;
        rep(j, 0, n + 1) if (f[now - 1][j]) 
            f[now][j + num[1]] = f[now][j + num[2]] = 1;
    }
    rep(i, 0, n + 1) if (f[now][i]) 
        // ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
        ans=min(ans,Get(i)+Get(n-i));
    printf("%d\n", ans);
    return 0;
}
//..

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

int main() {
	long long		a,b,c,i,j,k,n,m,x,y,ans = 0;
	string	str;

	
	cin >> a >> b >> k;
	
	
	if (a > k) {
		a -= k;
	} else {
		b = b + a - k;
		a = 0;
	}
	if (b < 0) b = 0;
	

	cout << a << ' ' << b << endl;
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
ll dp[N],a[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i];
    a[0]=(1e16);
    for(ll i=2;i<=n;i++)dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]) , dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n];
}



Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			
			if (c == '1') {
				System.out.print(9);
			} else {
				System.out.print(1);
			}
		}
	}

	static class FastReader { 
      BufferedReader br; 
      StringTokenizer st; 
  
      public FastReader() { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
      } 

      String next() { 
        while (st == null || !st.hasMoreElements()) { 
          try { 
            st = new StringTokenizer(br.readLine()); 
          } catch (IOException  e) { 
            e.printStackTrace(); 
          } 
       } 
       return st.nextToken(); 
      } 
  
      int nextInt() { 
        return Integer.parseInt(next()); 
      } 
 
      long nextLong() { 
        return Long.parseLong(next()); 
      } 
  
      double nextDouble() { 
        return Double.parseDouble(next()); 
      } 
  
      String nextLine() { 
        String str = ""; 
        try{ 
          str = br.readLine(); 
        } catch (IOException e) { 
          e.printStackTrace(); 
        } 
        return str; 
      } 
    } 
}


Measured memory_bytes: 21332
H, W = list(map(int, input().split()))

m = []
m.append('.'*(W+2))
for i in range(H):
    m.append('.'+input()+'.')

m.append('.'*(W+2))

x, y = 1, 1

while not(x==W and y==H):
    if(m[y][x+1]==m[y+1][x] or m[y][x-1]==m[y-1][x]=='#'):
        print('Impossible')
        exit()
    if(m[y][x+1]=='#'):
        x+=1
    elif(m[y+1][x]=='#'):
        y+=1


print('Impossible' if m[y-1][x]==m[y][x-1]=='#' else 'Possible')

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int q;
	cin >> q;
	vector<int> k(q);
	REP(i, q)cin >> k[i];
	vector<ll> res(q);
	REP(i, q) {
		ll d = 0, m = 0, dm = 0;
		REP(j, n) {
			if (j >= k[i]) {
				if (s[j - k[i]] == 'D') {
					d--;
					dm -= m;
				} else if (s[j - k[i]] == 'M') {
					m--;
				}
			}
			if (s[j] == 'D') {
				d++;
			} else if (s[j] == 'M') {
				m++;
				dm += d;
			} else if (s[j] == 'C') {
				res[i] += dm;
			}
			
		}
	}

	REP(i, q) {
		put(res[i]);
	}

	return 0;
}


Measured memory_bytes: 1412
def main():
    coordinates = list(map(int, input().split()))
    dx = coordinates[2] - coordinates[0]
    dy = coordinates[3] - coordinates[1]
    answer = "R" * dx + "U" * dy + "L" * dx + "D" * dy
    dx += 1
    dy += 1
    answer += "L" + "U" * dy + "R" * dx + "D" + "R" + "D" * dy + "L" * dx + "U"
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
from itertools import accumulate


def search_ab(sss, cursor):
    # print('a', cursor)
    ai = aaa.index(cursor)
    tmp_cur = bbb[ai]
    max_cur = sss.index(0, cursor)
    repeat = 1
    while tmp_cur < max_cur:
        cur = s.find('a', tmp_cur, max_cur)
        if cur == -1:
            break
        ai = aaa.index(cur, ai)
        tmp_cur = bbb[ai]
        repeat += 1
    return repeat, max_cur + 1


def search_ba(sss, cursor):
    # print('b', cursor)
    first_bi = bbb.index(cursor)
    max_cursor = sss.index(0, cursor)
    last_bi = aaa.index(max_cursor)

    tmp_buf = [''] * (last_bi - first_bi + 1) * 2
    tmp_max = ''
    for i in range(last_bi, first_bi - 1, -1):
        tmp_buf[aaa[i] - cursor] = 'a'
        tmp_buf[bbb[i] - cursor] = 'b'
        tmp = ''.join(tmp_buf)
        if tmp > tmp_max:
            tmp_max = tmp
    return tmp_max, max_cursor + 1


def integrate(parts_b):
    tmp_max = ''
    for pb in reversed(parts_b):
        tmp = pb + tmp_max
        if tmp > tmp_max:
            tmp_max = tmp
    return tmp_max


n = int(input())
s = input()

n2 = n * 2
sss = []
aaa, bbb = [], []
for i, c in enumerate(s):
    if c == 'a':
        aaa.append(i)
        sss.append(-1)
    else:
        bbb.append(i)
        sss.append(1)
sss = list(accumulate(sss))
repeats_a = []
parts_b = []
last_b_cur = 0
cursor = 0
while cursor < n2:
    c = sss[cursor]
    if c < 0:
        repeat, cursor = search_ab(sss, cursor)
        repeats_a.append((cursor, repeat))
    else:
        tmp, cursor = search_ba(sss, cursor)
        parts_b.append(tmp)
        last_b_cur = cursor
print(integrate(parts_b) + 'ab' * sum(r for c, r in repeats_a if c > last_b_cur))


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
	int n, m;
	std::cin >> n >> m;
	std::vector<int> c(m);
	int ans = n;
	for (int i = 0; i < m; i++)
		std::cin >> c[i];
	std::vector<int> dp(n + 1, 10000000);
	dp[0] = 0;
	for (int i = 0; i <= n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (i + c[j] <= n)
			{
				dp[i + c[j]] = std::min(dp[i + c[j]], dp[i] + 1);
			}
		}
	}
	std::cout << dp[n] << '\n';
	return (0);
}


Measured memory_bytes: 3172
"use strict";
function main(input) {
  const n = parseInt(input[0]);
  let s = {};

  for(let i=0;i<n;i++){
    s[input[i+1]] = true;
  }

  console.log(Object.keys(s).length);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

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

  S.push_back('#');

  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    int cnt = 0;
    for (int j = i; j < S.size(); j++) {
      char c = S[j];
      if (c == 'A' || c == 'C' || c == 'G' || c == 'T')
        cnt++;
      else {
        ans = max(ans, cnt);
        break;
      }
    }
  }

  cout << ans << endl;
}

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

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007

template <class T>
void printVec(vector<T> vec) {
    size_t len = vec.size();
    REP(i, len) {
        if (i) cout << " ";
        cout << vec[i];
    }
    cout << "\n";
}

int ALDS1_1_A() {
    // input
    ll N;
    cin >> N;
    vector<ll> vec(N), diff(N-1);
    REP(i, N) cin >> vec[i];
    
    // insert sort: 挿入ソートの過程を出力
    //BEGIN CUT
    for (int j = 0; j < N; ++j) {
        ll back = vec[j];
        ll k = j-1;
        while (k >= 0 && vec[k] > back) {
            // 後ろの方が小さかったら入れ替え
            vec[k+1] = vec[k];
            vec[k] = back;
            k--;
        }
        printVec(vec);
    }
    //BEGIN CUT
    return 0;
}

int main() {
    ALDS1_1_A();
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  int ans = 0;
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  for (int i = 0; i < N; i++) {
    ans += max(0, V[i] - C[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
fun main(args:Array<String>){
    val input = readLine()!!.split(" ")
    val N = input[0].toLong()
    val K = input[1].toLong()

    var c: Long = N/K
    c = c*c*c

    if (K%2 == 0L) {
        val k: Long = (N+K/2)/K
        c += k*k*k
    }

    println(c)
}

Measured memory_bytes: 37740
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

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



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

inline int read(){
    int ret=0,pos=1;char c=getchar();
    while(!isdigit(c) && c!='-' )c=getchar();
    if(c=='-')	pos=-1,c=getchar();
    while(isdigit(c))ret=(ret<<3)+(ret<<1)+c-48,c=getchar();
    return pos*ret;
}
map<string,bool> mp;
string str;
signed main(){
	int T=read();
	while(T--){
		cin>>str;
		if(mp.find(str)!=mp.end()){
			puts("NO");return 0;
		}
		else{
			mp[str]=1;
		}
	}
	puts("YES");
}

Measured memory_bytes: 24832
n, x, m = map(int, input().split())
tt = [i*i % m for i in range(m)]
ss = [i for i in range(m)]


def merge(to1, s1, to2, s2):
    to3 = [to2[to1[i]] for i in range(m)]
    s3 = [s1[i] + s2[to1[i]] for i in range(m)]
    return to3, s3


t = [i for i in range(m)]
s = [0] * m
while n:
    if n % 2 == 1:
        t, s = merge(t, s, tt, ss)
    tt, ss = merge(tt, ss, tt, ss)
    n //= 2

print(s[x])


Measured memory_bytes: 168992
n = input()
vs = list( map(int,input().split(" ")) )
def cal(vs):
    if len(vs)==1:
        if vs[0]==1:
            return 1
        else:
            return -1
    if vs[0]>0:
        return -1
    x = 1
    rem_sum = sum(vs)
    res = [1]
    for v in vs[1:]:
        x = min(2*x, rem_sum)
        res.append(x)
        x -= v
        rem_sum -= v
        if x<0:return -1
    #print(res)
    return sum(res)
print(cal(vs))

Measured memory_bytes: 20040
{-# LANGUAGE FlexibleContexts #-}
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import qualified Data.Sequence as S
import Data.Maybe (isJust)
import Data.List (permutations,nub)

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

updArray arr i f = do
  a <- readArray arr i
  writeArray arr i (f a)

path (x:y:xs) es = (isJust $  y `S.elemIndexL` (es!x)) && path(y:xs) es
path _ _ = True

solve n es = length
  [last p |
    p <- permutations [2..n],
    path (1:p) es]

main = do
  [n,m] <- getInts
  arr <- newArray (1,n) S.empty :: IO (IOArray Int (S.Seq Int))
  replicateM_ m $ do
    [a,b] <- getInts
    updArray arr a (\s -> s S.|> b)
    updArray arr b (\s -> s S.|> a)
  es <- freeze arr :: IO (Array Int (S.Seq Int))
  print $ solve n es


Measured memory_bytes: 1788
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;

    for(int i=0; i<10; ++i){
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
#define PB push_back
#define F first
#define S second
const int N=5e1+10;
bool later(pi a,pi b){
    return a.F==b.F?a.S<b.S:a.F<b.F;
}
bool isin(pi a,pi b,pi c){
    if(a.F==b.F){
        if(a.S<=b.S){
            if(b.F==c.F){
                if(b.S<=c.S)return true;
            }
            else if(b.F<c.F)return true;
        }
    }
    else if(a.F<b.F){
        if(b.F==c.F){
            if(b.S<=c.S)return true;
        }
        else if(b.F<c.F)return true;
    }
    return false;
}
int max(int a,int b){return a>b?a:b;}
int main(){
    int n,ans=0,temp;
    pi as[N],ae[N],bs[N],be[N],cs[N],ce[N];
    vector<pi> a,b,c;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&as[i].F,&as[i].S,&ae[i].F,&ae[i].S,&bs[i].F,&bs[i].S,&be[i].F,&be[i].S,&cs[i].F,&cs[i].S,&ce[i].F,&ce[i].S);
        a.PB(as[i]);
        a.PB(ae[i]);
        b.PB(bs[i]);
        b.PB(be[i]);
        c.PB(cs[i]);
        c.PB(ce[i]);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    a.resize(unique(a.begin(),a.end())-a.begin());
    b.resize(unique(b.begin(),b.end())-b.begin());
    c.resize(unique(c.begin(),c.end())-c.begin());
    for(int i=0;i<a.size();i++)for(int j=0;j<b.size();j++)if(later(a[i],b[j]))for(int k=0;k<c.size();k++)if(later(b[j],c[k])){
        temp=0;
        for(int r=0;r<n;r++)if(isin(as[r],a[i],ae[r])&&isin(bs[r],b[j],be[r])&&isin(cs[r],c[k],ce[r]))temp++;
        ans=max(temp,ans);
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 2756
import sys
sys.setrecursionlimit(1145141919)
N=int(input())
d=[-1 for _ in range(N+1)]
e=[[] for _ in range(N+1)]
for _ in range(N-1):
	a,b,c=map(int,input().split())
	e[a].append((b, c))
	e[b].append((a, c))
Q,K=map(int,input().split())
def dfs(now, dis):
	d[now] = dis
	for nxt,cos in e[now]:
		if d[nxt] == -1:
			dfs(nxt, dis+cos)
dfs(K, 0)
for _ in range(Q):
	x,y=map(int,input().split())
	print(d[x]+d[y])


Measured memory_bytes: 133552
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B, x,num=0,q,w,r,t,target;
  cin >> A>>B;

  for(int i=A; i<=B; i++){
    q=i/10000%10;
    w=i/1000%10;
    r=i/10%10;
    t=i/1%10;
    if(q==t &&w==r){
      num+=1;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
import sys
def f0070(A,n,s):
  if n==1:return s in A
  A=sorted(A)
  A1=A[:n][::-1]
  A2=A[-n:]
  b1=0
  b2=0
  c=0
  j=1
  for i in range(n):
    b1+=j*A1[i]
    b2+=j*A2[i]
    j+=1
  if b1<=s<=b2:
    for i in range(len(A)):
      c+=f0070(A[:i]+A[i+1:],n-1,s-A[i]*n)
  return c
for a in sys.stdin:
  n,s=map(int,a.split())
  print f0070(range(10),n,s)

Measured memory_bytes: 4240
N, K = map(int,input().split())
R, S, P = map(int, input().split())
T = input()

point = 0

judge = {"r": R, "s": S, "p": P}
skip = [False] * N

for i in range(N):
  if i < K:
    if T[i] == "r":
      point += judge["p"]
    elif T[i] == "s":
      point += judge["r"]
    elif T[i] == "p":
      point += judge["s"]
  else:
    # K回前を意識しないといけない
    if T[i-K] != T[i] or skip[i-K]:
      if T[i] == "r":
        point += judge["p"]
      elif T[i] == "s":
        point += judge["r"]
      elif T[i] == "p":
        point += judge["s"]
    else:
      skip[i] = True
      
print(point)

Measured memory_bytes: 4084
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <map>
using namespace std;

typedef long long ll;
ll MOD = 1e9+7;
map<char,char> mp;
int main()
{
	char n;
	mp['A']='T';
	mp['C']='G';
	mp['G']='C';
	mp['T']='A';
	int ans=0;
	cin>>n;
	cout<<mp[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    string s[4]={"AC","WA","TLE","RE"};
    map<string,ll> m;
    ll n=nxt();
    rep(a,0,n)
    {
        string ss;
        cin>>ss;
        m[ss]++;
    }
    rep(a,0,4)
    {
        cout<<s[a]<<" x "<<m[s[a]]<<endl;
    }
	printclock;
	return 0;
}

Measured memory_bytes: 3848
// Problem : 
// 			A - Rainy Season
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	string s;
	cin >> s;
	if(s=="RRR")
	cout << 3 << endl;
	else if(s=="RRS" || s=="SRR")
	cout << 2 << endl;
	else if(s=="SSS")
	cout << 0 << endl;
	else
	cout << 1 << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


Measured memory_bytes: 3652