akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/
int v[1000001];

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


}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

for(int i=1;i<=1000000;i++)
    v[i]=i;
for(ll i=2;i<=1000000;i++){
    if(v[i]==i){
        for(ll j=i*2;j<=1000000;j+=i)
            v[j]=i;
    }
}
int x=0;
int n;
cin>>n;
int a[n];
rep(i,0,n)
cin>>a[i];

set<int> s;
int fl=0;
for(int i=0;i<n;i++)
{
    x=gcd(x,a[i]);
    while(a[i]>1){
        int p=v[a[i]];
        if(s.find(p)!=s.end())
            fl=1;
        s.insert(p);
        while(a[i]%p==0)
            a[i]/=p;

    }


}
if(fl==0)
    cout<<"pairwise coprime"<<endl;
else if(x==1)
    cout<<"setwise coprime"<<endl;
else cout<<"not coprime"<<endl;








    }



Measured memory_bytes: 15084
<?php
fscanf(STDIN,"%d%d",$h,$w);
for($i=0;$i<$h;$i++){
  $c_li[]=str_split(trim(fgets(STDIN)));
}
$re_li = array();
//print_r($c_li);
$ii=0;

  for($i=1;$i<=$h*2;$i++){
    $index = (int)(($i+1)/2);
    for($j=0;$j<$w;$j++){
      echo $c_li[$index-1][$j];

    }
    echo "\n";
  }






Measured memory_bytes: 4604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		sc.close();

		System.out.println(a+((b-a)*2));
	}

}

Measured memory_bytes: 23124
#include <stdio.h>

int selectionSort(int A[], int N){
  int i,j,t,sw=0,minj;
  for(i = 0;i<N-1;i++){
    minj = i;
    for(j = i;j<N;j++){
      if(A[j]<A[minj])minj=j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if(i != minj)sw++;
  }
  return sw;
}

int main(){
  int A[100], N, i, sw;

  scanf("%d",&N);
  for(i = 0;i<N;i++)
    scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for(i = 0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",sw);
  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int a[100];
  double ave=0;
  for(int i=0; i<N; i++){
    cin >> a[i];
    ave+=a[i];
  }
  ave = (double)ave/N;
  vector<pair<double, int> >ans;
  for(int i=0; i<N; i++){
    ans.push_back(make_pair(abs(a[i]-ave), i));
  }
  sort(ans.begin(), ans.end());
  cout << ans[0].second << endl;
  return 0;
}

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

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

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

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

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

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

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

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

fn main() {
    input!{
        a: String,
        b: String,
    }
   println!("{}", if a == 'H'.to_string() {b} else if b == "D".to_string() {"H".to_string()} else {"D".to_string()});
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<string, int> P;
#define mod 1e9 + 7;
ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}

string in;
int tot[55][55];

int main()
{
	ios_base::sync_with_stdio(false);
	ll n;
	cin >> n;
	vs s(n);
	rep(i, n) {
		cin >> s[i];
	}
	REP(i, 1, n) {
		rep(j, i) {
			if (s[i] == s[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		//cout << s[i - 1][s[i - 1].size() - 1] << s[i][0];
		if (s[i - 1][s[i - 1].size() - 1] == s[i][0]) continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 5;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = 5;

			for (int i = 0; i < N; i++) {
				if (inputArray[i]==0) {
					//答えの出力
					var ans = i+1;
					Console.WriteLine(ans);
					return;
				}
			}
			

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 28012
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    if A[i] not in C:
        C[A[i]] = 0
    C[A[i]] += 1
K = 0
for j in C:
    K += (C[j]*(C[j]-1))//2
for k in range(N):
    j = A[k]
    print(K-C[j]+1)

Measured memory_bytes: 88140
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s = to_string(n);
    int sum=0;
    for(int i=0; i<s.size(); i++){
        sum+=s[i]-'0';
    }
    if(n%sum==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 0
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N, K;
  cin >> N >> K;
  int x, y;
  char c;
  vector<vector<int>> v(4 * K, vector<int>(4 * K, 0));
  rep(i, 0, N) {
    cin >> x >> y >> c;
    if (c == 'W') {
      x += K;
    }
    x %= 2 * K;
    y %= 2 * K;

    v[x][y]++;
    v[x + 2 * K][y]++;
    v[x][y + 2 * K]++;
    v[x + 2 * K][y + 2 * K]++;
  }

  rep(i, 1, v.size()) rep(j, 1, v[0].size()) v[i][j] +=
      v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1];
  if(DBG){
    rep(i,0,v.size())rep(j,0,v[0].size())cout<<v[i][j]<<(j==v[0].size()-1?'\n':' ');
  }

  auto get = [&](int a, int b, int c, int d) {
    return v[c][d]-v[c][b]-v[a][d]+v[a][b];
  };
  int ans = 0;
  rep(i, 0, 2 * K) rep(j, 0, 2 * K) {
    int sum = get(i, j, i + K, j + K) + get(i + K, j + K, i + 2 * K, j + 2 * K);
    dump(sum);
    chmax(ans, max(N - sum, sum));
  }

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


Measured memory_bytes: 63104
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#pragma GCC optimize("Ofast")
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native" )
#define endl "\n"
#define int unsigned long long
#define debug(x) cout << #x << " is " << x << endl;
using namespace std;
int fastpow(int a, int b) {
	if (!b) return 1ll;
	if (b % 2 == 1) return fastpow(a, b - 1) * a;
	int t = fastpow(a, b / 2);
	return t * t;
}
void solve() {
	int n; cin >> n;
	string ans = "";
	while (n) {
		int x = 1;
		if (n % 26 == 0) x = -25;
		ans = (char)(n % 26 + 'a' - x) + ans;
		if (n % 26 == 0) n--;
		n /= 26;
		//debug(ans); 
	}
	cout << ans;
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(15);
	int t; t = 1;
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3648
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    int n;string s;
    cin>>n>>s;
    int ans=0,t=0;
    rep(i,0,n){
        if(s[i]=='I')t++;
        else t--;
        ans=max(ans,t);
    }
    cout<<ans<<endl;


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;

#define N_MAX 305
vector<vector<ll>> dp(N_MAX, vector<ll>(N_MAX, MOD*(ll)N_MAX));
int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> h;
    h.push_back(0);
    rep(i, n){ int tmp; cin >> tmp; h.push_back(tmp);}

    // dp[x][y]: x は右端、yはサイズ
    rep(i,n) dp[i][0] = 0;
    // 推移条件の例外となるため最初はh[i]を与える
    rep(i,n+1) dp[i][1] = h[i];
    
    for (int x = 1; x <= n; x++)
    {
        for (int y = 2; y <= n; y++)
        {   
            for (int i = y-1; i <= x-1; i++)
            {
                dp[x][y] = min(dp[x][y], dp[i][y-1]+max((ll)0, h[x]-h[i]));
            }            
        }
    }

    ll ans = MOD*N_MAX;
    for (int x = 1; x <= n; x++)
    {
        if (x < n-k) continue;
        ans = min(ans, dp[x][n-k]);
    }
    
    cout << ans << endl;
}


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

struct Point {
  double x;
  double y;
};

void koch (int n, Point a, Point b) {
  if (n == 0) {
    return;
  }
  Point s, t, u;
  // 度からラジアンに変換
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, b);
}

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

  Point a, b;
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);

  return 0;

}


Measured memory_bytes: 3204
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <locale>

using namespace std;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	int ans = k <= 1 ? 0 : (n - k);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef vector<int> vi;
typedef pair<int, int> P;
 
P operator-(const P &l, const P &r){
    return MP(l.X-r.X, l.Y-r.Y);
}
 
P operator+(const P &l, const P &r){
    return MP(l.X+r.X, l.Y+r.Y);
}

int main(){
    int n, m;
    while(cin >> n, n){
        P prev, start;
        vector<P> mov;
        rep(i, n){
            P p;
            cin >> p.X >> p.Y;
            if(i) mov.push_back(p-prev);
            else start = p;
            prev = p;
        }
		int m;
		cin >> m;
        vector<P> star(m);
        map<P, bool> exist;
        rep(i, m){
            cin >> star[i].X >> star[i].Y;
            exist[star[i]] = true;
        }
        P ans = MP(0, 0);
        rep(i, m){
            P p = star[i];
            bool ok = true;
            rep(j, mov.size()){
                p = p + mov[j];
                if(!exist[p]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                ans = star[i] - start;
            }
        }
        cout << ans.X << ' ' << ans.Y << endl;
    }

 
    return 0;
}

Measured memory_bytes: 1328
#include <iostream>
#include <vector>
using namespace std;
int gcd(int a, int b)
{
  if (b > a)
  {
    int temp = a;
    a = b;
    b = temp;
  }
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
void p_1()
{
  int N;
  cin >> N;
  int num[N];
  for (int i = 0; i < N; i++)
    cin >> num[i];
  int res = num[0];
  for (int i = 1; i < N; i++)
  {
    if (res == 1)
      break;
    res = gcd(res, num[i]);
  }
  cout << res;
}

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


Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

double round_(double x) {
    if(abs((double)x) < 0.001) return 0;
    return x;
}

int main() {
    int a, b, c, d, e, f;
    while(cin >> a >> b >> c >> d >> e >> f) {
        int det = a*e - b*d;
        double x = (e*c - b*f) / (double)det;
        double y = (-d*c + a*f) / (double)det;
        printf("%.3f %.3f\n", round_(x), round_(y));
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
 
using namespace std;
 
const ll MOD = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);


int sa[100005];
int sb[100005];
int ta[100005];
int tb[100005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string S,T;
    cin >> S >> T;
    rep(i,S.size()){
        sa[i+1] = sa[i];
        sb[i+1] = sb[i];
        if(S[i]=='A')sa[i+1]++;
        else sb[i+1]++;
    }
    rep(i,T.size()){
        ta[i+1] = ta[i];
        tb[i+1] = tb[i];
        if(T[i]=='A')ta[i+1]++;
        else tb[i+1]++;
    }
    int q;
    cin >> q;
    rep(i,q){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        int sanum = sa[b]-sa[a-1];
        int sbnum = sb[b]-sb[a-1];
        int tanum = ta[d]-ta[c-1];
        int tbnum = tb[d]-tb[c-1];
        sanum %= 3;
        sbnum %= 3;
        tanum %= 3;
        tbnum %= 3;
        if(sanum==0);
        else if(sanum==1)sbnum+=2;
        else if(sanum==2)sbnum++;
        if(tanum==1)tbnum+=2;
        else if(tanum==2)tbnum++;
        sbnum %= 3;
        tbnum %= 3;
        if(sbnum==tbnum)cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

Measured memory_bytes: 2512
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<iostream>
#include<algorithm>
#define N 200001
#define LL long long
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;	
}
using namespace std;
const int mod=1000000007;
int n,ans,a[N],b[N],f[4001][4001],fac[8001],ifac[8001],inv[8001];
int C(int n,int m)
{
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int main()
{
	re(n);
	for(int i=1;i<=n;++i)	
		re(a[i]),re(b[i]),f[2000-a[i]][2000-b[i]]++;
	for(int i=0;i<=4000;++i)
		for(int j=0;j<=4000;++j)
			f[i][j]=(((i?f[i-1][j]:0)+(j?f[i][j-1]:0))%mod+f[i][j])%mod;
	fac[0]=ifac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=8000;++i)
	{
		if(i>1)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[i]=1ll*fac[i-1]*i%mod;
		ifac[i]=1ll*ifac[i-1]*inv[i]%mod;
	}
	for(int i=1;i<=n;++i)
		ans=(ans+f[a[i]+2000][b[i]+2000]-C((a[i]+b[i])*2,a[i]+a[i]))%mod;
	ans=(1ll*ans*inv[2]%mod+mod)%mod;
	printf("%d\n",ans);
}
/*
ans  = sigma C(ai+bi+aj+bj,ai+aj)
*/

Measured memory_bytes: 64384
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

long long solve(int N, long long K, const std::vector<long long> &P, const std::vector<long long> &C) {
  ll ans = -1e18;
  REP(i, N) {
    vl score;
    int j = P[i];
    score.push_back(C[j]);
    while (i != j) {
      j = P[j];
      score.push_back(score[score.size() - 1] + C[j]);
    }

    ll size = score.size();
    ll tmp = -1e18;
    for (int i = 0; i < min(size, K); i++) {
      chmax(tmp, score[i]);
    }
    chmax(ans, tmp);

    if (score[score.size() - 1] > 0) {
      ll cnt = (K / size);
      if (cnt >= 1) {
        for (const auto el : score) {
          chmax(ans, score[score.size() - 1] * (cnt - 1) + el);
        }
      }
      tmp = 0;
      for (int i = 0; i < K % size; i++) {
        chmax(tmp, score[i]);
      }
      chmax(ans, score[score.size() - 1] * cnt + tmp);
    }
  }
  return ans;
}

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  long long N;
  long long K;
  std::cin >> N;
  std::vector<long long> P(N), C(N);
  std::cin >> K;
  for (int i = 0; i < N; ++i) {
    std::cin >> P[i];
    P[i]--;
  }
  for (int i = 0; i < N; ++i) {
    std::cin >> C[i];
  }
  auto ans = solve(N, K, P, C);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 3776
#include <iostream>
//#include <fstream.h>
//#include <cstring>
using namespace std;

int main() {
 
  for(int i=1;i<10;i++) {
    for(int j=1;j<10;j++) {
      cout << i << "x" << j << "=" << i*j << "\n";
    }
  }

  return 0;
}

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

int main() {
    int n, k;
    long long ans = 0;
    cin >> n >> k;
    if(k == 0){
        cout << (long long)n*n << endl;
        return 0;
    }
    for(int i=k+1;i<=n;i++){
        ans += (n / i) * (i - k);
        int t = n - (n / i)*i - k + 1;
        if(t > 0)ans += t;
    }
    cout << ans << endl;
	return 0;
}

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007

using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

int n;
vector<int> v[MAX];

ll tree[MAX][2];

void dfs(int node, int p) {
    for (int i = 0; i < v[node].size(); i++) {
        if (v[node][i] != p) {
            dfs(v[node][i], node);
            tree[node][0] = (tree[node][0] * (tree[v[node][i]][0] + tree[v[node][i]][1]) % mod) % mod;
            tree[node][1] = (tree[node][1] * tree[v[node][i]][0]) % mod;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    for (int i = 0; i <= n; i++) {
        tree[i][0] = 1;
        tree[i][1] = 1;
    }
    dfs(1, 0);
    cout << (tree[1][0] + tree[1][1]) % mod;
    return 0;
}

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

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

Measured memory_bytes: 19584
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N;
  cin >> N;
  int D[N]; ll cnt[N]={0};
  rep(i, N){
    cin >> D[i];
    cnt[D[i]]++;
  }
  ll ans = 1;
  bool can = true, zerokana=false;
  for(int i=1; i<N; i++){
    if(D[i]!=1) can=false;
    if(D[i]==0) zerokana=true;
  }
  if((zerokana) || D[0]!=0) cout << 0 << endl;
  else if(can) cout << 1 << endl;
  else{
    int maxcnt;
    rep(i, N){
      if(cnt[i]!=0) maxcnt=i;
    }
    for(int i=1; i<maxcnt; i++){
      for(ll j=0; j<cnt[i+1]; j++){
        ans *= cnt[i];
        ans %=  998244353;
      }
    }
    cout << ans << endl;
  }
  
}

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

typedef struct T {
	string op;
	vector<int> k;
};
int n, k;
string M;
T t[1000];

int rec(int d, T &tr) {
	for (int i = 0; i < d; i++) {
		cout << ".";
	}
	cout << tr.op << endl;
	for (int i = 0; i < tr.k.size(); i++) {
		rec(d + 1, t[tr.k[i]]);
	}
	return 0;
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> k >> M;
		string s(M);
		t[i].op = s;
		if (k > 0) {
			t[k - 1].k.push_back(i);
		}
	}
	rec(0, t[0]);


	return 0;
}

Measured memory_bytes: 3392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;
typedef pair<int,int> P;
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,m,N) for(int i=m;i<N;i++)
#define mm(n,m) memset(n,m,sizeof(n))

int main(){
  double n,ans=0;
  cin>>n;
  ans = (100*n)/108;
  int tmp = (int)ans;
  int tmp2 = tmp+1;
  double tax = double(108)/double(100);
  int tmpp = tmp *tax;
  //cout<<"tmp:"<<tmpp<<endl;
  if(tmpp==n){
    cout<<tmp<<endl;
    return 0;
  }else{
    tmpp = tmp2 * tax;
    if(tmpp == n){
      cout<<tmp2<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}


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

int main() {
	long long N,M,A,B;
	vector<char> ans;
	cin >> N;
	M = N;
	while (true) {
		M--;
		A = M / 26;
		B = M % 26;

		ans.push_back(B + 'a');

		if (A==0) {
			break;
		}
		M = A;
	}
	for (int i = ans.size() - 1; i >=0; i--) {
		cout << ans[i];
	}
}

Measured memory_bytes: 3136
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.IntMap as IM

readIntLines :: IO [Int]
readIntLines = map (fst . fromJust . BC.readInt) . BC.lines <$> BC.getContents

type Map = IM.IntMap Int

get :: Int -> Map -> Int
get key m = fromMaybe 0 $ IM.lookup key m

countUp :: Int -> Int -> Map -> Map
countUp = IM.insertWithKey f
  where f _ new old = old + new

record :: [Int] -> Map -> Map
record [] m = m
record (a:as) m = record as $ countUp a 1 m

solve :: [Int] -> Int -> Int -> Map -> [Int]
solve [] _ _ _ = []
solve (i:is) k q m = score : solve is k q m
  where score = k - q + get i m

main :: IO ()
main = do
  [n, k, q] <- map read . words <$> getLine :: IO [Int]
  as <- readIntLines
  mapM_ (putStrLn . (\n -> if n > 0 then "Yes" else "No")) $ solve [1..n] k q $ record as IM.empty


Measured memory_bytes: 17532
#include <iostream>
#include <array>

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

    long long int n;

    while (std::cin >> n, n) {
        
        std::array<long long int, 7> arr{{}};
        int age;

        for (; n--;) {
            std::cin >> age;
            age = (age < 70 ? age : 60);
            ++arr[age / 10];
        }
        
        for (const auto& cnt : arr) {
            std::cout << cnt << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

long max(long a,long b){
  if(a > b){
    return a;
  }
  return b;
}

long min(long a,long b){
  if(a < b){
    return a;
  }
  return b;
}

int main(void){
  int A,B,C;
  long X,Y,ans,money,mini;
  scanf("%d%d%d",&A,&B,&C);
  scanf("%ld%ld",&X,&Y);

  ans = X*A+Y*B;

  money = max(X,Y)*2*C;
  ans = min(ans,money);

  mini = min(X,Y);
  money = mini*2*C;
  X -= mini; Y -= mini;
  money += X*A+Y*B;
  ans = min(ans,money);

  printf("%ld\n",ans);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3

from collections import defaultdict

def main():
    n = int(input())
    ss = defaultdict(int)
    for i in range(n):
        s = "".join(sorted(input()))
        ss[s] = ss[s] + 1

    print(sum(c2(v) for k, v in ss.items()))

def c2(n):
    # Choosing 2 from n
    return n * (n - 1) // 2

if __name__ == "__main__":
    main()


Measured memory_bytes: 18228
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

ll SCORE = 0;
int conds[100][4];

void calc(int idx, int minv, int N, int M, int Q, vector<ll> &arr)
{
  if (idx < N) {
    RNG(i, minv, M+1) {
      arr[idx] = i;
      calc(idx+1, arr[idx], N, M, Q, arr);
    }
  } else {
    // println(arr);
    ll score = 0;
    REP(i, Q) if (arr[conds[i][1]-1] - arr[conds[i][0]-1] == conds[i][2]) {
      score += conds[i][3];
      SCORE = max(score, SCORE);
    }
  }
}

int main(int argc, char const *argv[])
{
  ll N, M, Q; cin >> N >> M >> Q;
  REP(i, Q) cin >> conds[i][0] >> conds[i][1] >> conds[i][2] >> conds[i][3];
  vecll arr(11);
  REP(i, 11) arr[i] = 0;

  calc(0, 1, N, M, Q, arr);
  cout << SCORE << endl;
  return 0;
}


Measured memory_bytes: 3616
import math

def ifprime(num):
  if num == 1:
    return False
  for i in range(2,math.floor(num ** 0.5) + 1):
    if num % i:
      continue
    else:
      return False
  return True

while(True):
  try:
    num = int(input())
  except:
    break
  count = 0
  for i in range(1,num+1):
    if ifprime(i) and ifprime(num+1-i):
      count += 1
  print(count)



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

unsigned int fa(unsigned int n)
{
    unsigned int ret = 1;
    for(unsigned int i = 1; i <= n; ++i)
        ret *= i;
    return ret;
}
int main(){
	long long int n;
	cin >> n;
   //cout << fa(n) << endl;
	vector<pair<long long int,long long int>> xyvec(n);
	long long int tmpx,tmpy;
	rep(i,n){
		cin >> tmpx >> tmpy;
		xyvec.at(i) = make_pair(tmpx, tmpy);
	}
  
    do{
        //for(int i=0; i<4; i++){
          //  cout<<array[i];
            //if(i!=3)cout<<" ";
        //}
        //cout<<endl;
    }while(next_permutation(xyvec.begin(),xyvec.end()));
  
  
	double length=0;
	long long int x,y,nx,ny;
	do{
		rep(i,n-1){
			x = xyvec.at(i).first;
		       y= xyvec.at(i).second;	
		       nx = xyvec.at(i+1).first;
		       ny = xyvec.at(i+1).second;
		       length += sqrt((x-nx)*(x-nx)+(y-ny)*(y-ny));   
        }
      //cout << length << endl;
	}while(next_permutation(xyvec.begin(),xyvec.end()));
	cout << setprecision(10);
	cout << fixed << length/((double)(fa(n))) << endl;
	
		
	


	return 0;
}


Measured memory_bytes: 256
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n;
  cin >> n;
  int x = 2;
  while(1) {
    if(x * (x - 1) / 2 >= n) {
      if(x * (x - 1) / 2 == n) {
        cout << "Yes\n" << x << "\n";
        vector<vector<int>> v(x);
        int cnt = 0;
        for(int i = 0; i < x; i++) for(int j = i + 1; j < x; j++) {
          cnt++;
          v[i].emplace_back(cnt);
          v[j].emplace_back(cnt);
        }
        for(int i = 0; i < x; i++) {
          cout << v[i].size();
          for(int j = 0; j < v[i].size(); j++) {
            cout << " " << v[i][j];
          }
          cout << "\n";
        }
      } else {
        cout << "No\n";
      }
      return 0;
    }
    x++;
  }
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
const ll MOD = 998244353ll;

int n,m;
int a[52525], b[52525], c[52525];
unordered_map<int,int> M[125252];
int dp[252521];

ll modpow(ll a, ll b){
  ll r = 1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

bool ppcnt[16];

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d%d%d",a+i,b+i,c+i),a[i]--,b[i]--;
  REP(i,16)ppcnt[i] = __builtin_popcount(i)%2==0;
  REP(i,m)M[a[i]][b[i]] = c[i];
  REP(j,16){
    if(!ppcnt[j])continue;
    bool ok = true;
    REP(i,4)if(M[i>>1].count(i&1) && M[i>>1][i&1] != (j>>i&1)){
      ok = false;
    }
    if(ok)dp[j>>3&1] += 1;
  }
  REP(i,n-2)REP(r2,2)if(dp[i*2+r2]){
    int ci = i+1;
    REP(ld,2){
      int ru = r2 ^ ld;
      if(M[ci-1].count(ci+1) && M[ci-1][ci+1] != ld)continue;
      if(M[ci+1].count(ci-1) && M[ci+1][ci-1] != ru)continue;
      REP(to,8){
        int nj = to*2+r2;
        if(!ppcnt[nj])continue;
        if(M[ci+1].count(ci+0) && M[ci+1][ci+0] != (nj>>1&1))continue;
        if(M[ci+0].count(ci+1) && M[ci+0][ci+1] != (nj>>2&1))continue;
        if(M[ci+1].count(ci+1) && M[ci+1][ci+1] != (nj>>3&1))continue;
        (dp[(i+1)*2+(nj>>3)] += dp[i*2+r2]) %= MOD;
      }
    }
  }
  ll base = (dp[(n-2)*2] + dp[(n-2)*2+1]) % MOD;
  ll fr = n<=3 ? 0ll : ((ll)n*n - 7ll*2 - 5ll*(n-4))/2;
  REP(i,m){
    int x = a[i], y = b[i], z = c[i];
    if(abs(x-y)<=2)continue;
    if(M[y].count(x)){
      if(M[y][x] != z){
        base = 0;
      }else if(x<y){
        fr--;
      }
    }else{
      fr--;
    }
  }
  ll ans = base * modpow(2ll, fr) % MOD;
  printf("%lld\n",ans);
  return 0;
}


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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef long double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}
bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

pair<int,int>gcd(int a,int b,int i=0){
  if(a>b)return gcd(b,a,i);
  if(a==0)return cons(b,i);
  return gcd(b%a,a,i+1);
}

int main() {

  loop {
    int a, b; cin >> a >> b;
    if (!a &&!b) break;
    auto p=gcd(a,b,0);
    cout<<car(p)<<' '<<cdr(p)<<endl;}

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int gcd(int a, int b) {
  if(a<b) swap(a,b);
  int c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vi a(N);
  rep(i,N) {
    cin >> a[i];
  }
  int n2 = -1;
  rep(i,N) {
    int k = 0;
    int d = 2;
    while(a[i] % d == 0) {
      d <<= 1;
      k++;
    }
    if(n2 < 0) {
      n2 = k;
    } else if(n2 != k) {
      cout << 0 << endl;
      return 0;
    }
  }
  n2--;
  rep(i,N) {
    a[i] /= 2;
  }
  rep(i,n2) {
    M /= 2;
    rep(j,N) {
      a[j] /= 2;
    }
  }
  ll l = a[0];
  rep(i,N) {
    l = lcm(l,a[i]);
    if(l > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll s = M / l;
  ll ans = (s+1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
s = input()
length = len(s)

def insert(s,pos,k):
    return s[:pos+1+k] + '+' + s[pos+1+k:]

ans = 0
for i in range(2**(length-1)):
    ss = s
    bit = format(i,'b')
    bit = bit.rjust(length-1,'0')
    k = 0
    for j in range(len(bit)):
        if bit[j]=='1':
            ss = insert(ss,j,k)
            k += 1
    ans += eval(ss)

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    string s;
    cin>>s;
    
    rep(i,s.size()-1){
        if(s.substr(i,2)=="AC"){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 768
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        k: i32, x: i32,
    }
    for i in x - k + 1..k + x {
        puts!("{} ", i);
    }
    puts!("\n");
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>
int main()
{
    unsigned int K,i,length;
    scanf("%u",&K);
    char S[100];
    scanf("%s",S);
    length=strlen(S);
    if(K<length)
    {
        for(i=0;i<K;i++)
        {
            printf("%c",S[i]);
        }
        printf("...");
    }
    else
        printf("%s\n",S);
}



Measured memory_bytes: 1692
import java.util.*;
 class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        for(int i = 0;i < n;i++){
            int num = sc.nextInt();
            list.add(num);
        }
        Collections.sort(list);
        int sum = 0;
        for(int i = 0;i < k;i++){
            sum += list.get(i);
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 39100
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int H,W;
		while(true){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H==0&&W==0) break;
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					if(i==0||i==H-1||j==0||j==W-1)System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
			
		}
	}
}

Measured memory_bytes: 24676
#![allow(clippy::needless_range_loop)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        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 main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [chars; h]
    }
    let ans = (0..(1 << (h + w))).map(|i| {
        (0..w).map(|x| {
            (0..h).filter(|y| {
                i & (1 << x) == 0 &&
                i & (1 << (y + w)) == 0 &&
                c[*y][x] == '#'
            }).count()
        }).sum::<usize>()
    }).filter(|x| x == &k).count();
    println!("{}", ans);
}


Measured memory_bytes: 2152