akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<bitset>
#define MN 100000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n,m,a[MN+5],b[MN+5],num=0,ans=0;
bitset<400*399/2+5> fail,s[405];
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j)
		++num,s[i][num]=1,s[j][num]=1;
	for(int i=1;i<=m;++i) a[i]=read(),b[i]=read();
	for(int i=m;i;--i)
	{
		fail|=s[a[i]]&s[b[i]];
		s[a[i]]|=s[b[i]];s[b[i]]|=s[a[i]];
	}
	for(int i=1;i<=num;++i) if(!fail[i]) ++ans;
	cout<<ans; 
	return 0;
}



Measured memory_bytes: 4992
#include <stdio.h>
int main(){
    int array[3][3];
    int n; 
    int add;
    int check[3][3]={0};
    int count;
    for(int i = 0; i < 3; i++)
	{ 
        for(int j = 0; j < 3; j++)
		{ 
            scanf("%d", &array[i][j]);
        } 
    }
    scanf("%d",&n);
    for(int k = 0; k < n; k++)
	{
        scanf("%d",&add);
        for(int i = 0; i < 3; i++)
		{
            for(int j = 0; j < 3; j++)
			{
                if(array[i][j] == add)
                {
                    check[i][j] = 1;
                }
            }
        }
    }
    if(check[0][0] + check[1][1] + check[2][2] == 3 || check[0][2] + check[1][1] + check[2][0] == 3)
	{
        printf("Yes\n");
        return 0;
    }
    for(int i = 0; i < 3; i++){
        if(check[i][0] + check[i][1] + check[i][2] == 3 || check[0][i] + check[1][i] + check[2][i] == 3)
		{
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
       
        int k = scan.nextInt();
        String s = scan.next();
        
        int n = s.length();
        
		if ( n <= k ) {
		    System.out.println(s);	
		}
        else {
            System.out.println(s.substring(0,k) + "...");
        }
    }
}


Measured memory_bytes: 38628
#include <iostream>
#include <algorithm>
#define nmax 100005
using namespace std;
int n, v[nmax];
long long sol;

int main()
{
    int i, j, k, p, s;
    cin >> n;
    for (i = 1; i <= n; i++)
        cin >> v[i];

    sort (v + 1, v + n + 1);

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

            s=v[i] + v[j];
            for (k = j + 1, p = 1<<10; p; p >>= 1)
                if (k + p <= n && v[k + p] < s)
                    k += p;

            if (v[k] >= s)
                continue;

            //cout << i << ' ' << j << ' ' << k << '\n';
            sol += (k - j);
        }

    cout << sol << '\n';
    return 0;
}


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

int main() {
  long long k, a, b;
  cin >> k >> a >> b;
  long long ans = 1;
  if (a + 3 > b) {
    ans += k;
  }
  else {
    if (k - 2 < a - 1) {
      ans += k;
    }
    else {
      k -= a + 1;
      ans = b;
      while (k > 1) {
        k -= 2;
        ans += b - a;
      }
      ans += k;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) cout << "YES";
    else cout << "NO";
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

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

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	for(ll x;cin>>x&&x;){
		ll y=x/11*2; x%=11;
		y=y+(x>0)+(x>6);
		cout<<y<<endl;
	}
}


Measured memory_bytes: 384
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let mut a = sc
        .vec::<i64>(n)
        .into_iter()
        .enumerate()
        .map(|(i, a)| (-a, i))
        .collect::<Vec<_>>();
    a.sort();
    let mut ans = vec![0; n];

    let mut garbage_count = 0;
    let mut garbage_num = -a[0].0;
    let mut stack = vec![];
    let mut cur = a[0].1;
    for &(a, i) in a.iter() {
        let a = -a;
        if cur > i {
            ans[cur] += garbage_count * (garbage_num - a);
            garbage_num = a;
            while let Some(b) = stack.pop() {
                ans[cur] += b - a;
                garbage_count += 1;
            }
            cur = i;
        }
        stack.push(a);
    }
    ans[cur] += stack.into_iter().sum::<i64>();
    ans[cur] += garbage_count * garbage_num;
    for c in ans.into_iter() {
        println!("{}", c);
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
#include <iostream>

using namespace std;
typedef long long lint;

lint Count(lint hp) { return (hp == 1) ? 1 : 1 + (2 * Count(hp / 2)); }

void resolve()
{
    lint H;
    cin >> H;

    cout << Count(H) << endl;
}

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


Measured memory_bytes: 256
<?php
$A=[];
for($i=97;$i<123;$i++) $A[$i]=0;

while(1){
  $S=trim(fgets(STDIN));
  if(!$S){break;}

  foreach(str_split($S) as $c){
    $n=ord($c);
    if($n<65) continue;
    elseif($n<91) ++$A[$n+32];
    elseif($n<97) continue;
    elseif($n<123) ++$A[$n];
  }
}

for($i=97;$i<123;$i++) echo chr($i),' : ',$A[$i],PHP_EOL;

Measured memory_bytes: 15436
#include<stdio.h>
void insertionSort(int [], int); // N個の要素を含む0-オリジンの配列A
void test(int [], int);

int main(){
  int i,j,M;
  int A[100];

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


  test(A,M);
  insertionSort(A,M);

  return 0;
}

void insertionSort(int A[], int M) {
  int i,j,x;
  for (i=1;i<M;i++){
    x= A[i];
    j = i-1;
    while (j>=0 && A[j] > x){
      A[j+1] = A[j];
      j--;

    }
     A[j+1] = x;
     test(A,M);
  }

}

void test(int A[], int M){
  int i;
  for(i=0;i<M;i++){
    if(i>0) printf(" ");
    printf("%d",A[i]);

  }
  printf("\n");

}



Measured memory_bytes: 2752
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main() {
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  
  int cnt = 0;
  for (int i=0;i<N; i++) {
    cnt += (D-1)/A[i];
  }
  int ans = N+cnt+X;
  cout << ans << endl;
}
    

Measured memory_bytes: 384
//看题解了，重做 
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int NN = 700;
int x, y, ans, n, m, q, a[NN][NN], b[NN][NN], c[NN][NN];

int main(){
	//freopen("atcoderabc106d.in", "r", stdin);
	
	scanf("%d%d%d", &n, &m, &q);
	for (int i=1; i<=m; i++) {
		scanf("%d%d", &x, &y);
		a[x][y]++;
	}
	
	for (int i=1; i<=n; i++)
		for (int j=i; j<=n; j++)
			for (int k=i; k<=j; k++) b[i][j] += a[i][k];  //b[i][j]表示以i为起点，终点在j及j之前的边的个数 
	
	for (int i=1; i<=n; i++)
		for (int j=i; j<=n; j++)
			for (int k=i; k<=j; k++) c[i][j] += b[k][j]; 
	
	
	while (q--){
		scanf("%d%d", &x, &y);
		printf("%d\n", c[x][y]);
		//printf("%d %d %d\n", r[y] - l[x-1], r[y], l[x-1]);
	} 
	
	return 0;
} 

Measured memory_bytes: 5504
#include <stdio.h>
int main ()
{
  int a,n,i,MAX=-2147483648,min=2147483647;
  long long t=0;
  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&a);

    t+=a; 

    if( MAX<a)
      MAX=a;
    if( min>a)
      min=a;
  }
  printf("%d ",min);
  printf("%d ",MAX);
  printf("%lld\n",t);
  return 0;
}

Measured memory_bytes: 600
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N = ii()
N_f = float(N)
A = li()

cnt = [0, 0, 0]
for a in A:
    cnt[a-1] += 1

#dp = dp3(-1.0, cnt[2]+1, cnt[1]+cnt[2]+1, N+1)
dp = dp3(0.0, N+1, N+1, N+1)
#dp = dp3(0.0, 301, 301, 301)
dp[0][0][0] = 0

for k in range(cnt[2]+1):
#for i in range(N+1):
    for j in range(cnt[1]+cnt[2]+1-k):
    #for j in range(N+1):
        #for k in range(cnt[2]+1):
        #for k in range(N+1):
        for i in range(N+1-j-k):
            #print(i, j, k)
            if i+j+k == 0:
                continue
            num = i+j+k
            dp[i][j][k] = N_f
            if i > 0:
                dp[i][j][k] += dp[i-1][j][k] * i
            if j > 0:
                dp[i][j][k] += dp[i+1][j-1][k] * j
            if k > 0:
                dp[i][j][k] += dp[i][j+1][k-1] * k
            dp[i][j][k] /= num

print(dp[cnt[0]][cnt[1]][cnt[2]])

Measured memory_bytes: 254472
#include <iostream>

using namespace std;

int main(){
    int N;
    int A[200000];
    long ans;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    if(A[0] != 0) cout << -1 << endl;
    else{
        int prev = A[0];
        int cnt = 0;
        for(int i = 1; i < N; i++){
            if(A[i] > prev+1){
                cout << -1 << endl;
                return 0;
            }else if(A[i] == prev+1){
                cnt++;
                prev = A[i];
            }else{
                ans += cnt + A[i];
                cnt = 0;
                prev = A[i];
            }
        }
        ans += cnt;
        cout << ans <<endl;
    }
}

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

int main()
{
  int N,M,C;
  int r=0,sum=0;
  scanf("%d %d %d",&N,&M,&C);
  vector<int> b(M);
  vector<vector<int>> a(N,vector<int> (M));
  for(int i=0;i<M;i++){
    scanf("%d",&b[i]);
  }     
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      scanf("%d",&a[i][j]);
      r+=a[i][j]*b[j];
    }
    r+=C;
    if(r>0)
      sum++;
    r=0;
  }       
  printf("%d",sum);
  return 0;
}


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

using namespace std;

int num(string& s, int& p) {
	int res = 0;
	while (isdigit(s[p])) {
		res *= 10;
		res += s[p] - '0';
		p++;
	}
	return res;
}

int solve(string& s, int& p) {
	vector<int> v;
	while (p < s.size()) {
		if (s[p] == '[') {
			p++;
			v.push_back(solve(s, p));
		}
		else {
			return (num(s, p) + 1) / 2;
		}
		p++;
		if (s[p] == ']') break;
	}
	sort(v.begin(), v.end());
	int res = 0;
	for (int i = 0; i < (int)(v.size() + 1) / 2; i++) {
		res += v[i];
	}
	return res;
}

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

	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		int p = 0;
		int res = solve(s, p);
		cout << res << endl;
	}
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    ll res1=a*x+b*y;
    ll res2=min(x,y)*c*2+((x>y)? (x-y)*a:(y-x)*b);
    ll res3=max(x,y)*c*2;
    ll res=min(res1,min(res3,res2));
    cout<<res<<endl;
}

Measured memory_bytes: 3632
main :: IO ()
main = do
  bs <- getLine
  print $ ans (nannko bs)

ans :: [Int] -> Int
ans [a,b,c,d] = min (a+d) (b+c)

--ki0,guu0,ki1,guu1
nannko :: String -> [Int]
nannko bs = tail $ foldl func [0,0,0,0,0] bs
  where
   func [n,a,b,c,d] k
    | n == 0 && k == '0' = [1,a+1,b,c,d]
    | n == 0 && k == '1' = [1,a,b,c+1,d]
    | n == 1 && k == '0' = [0,a,b+1,c,d]
    | n == 1 && k == '1' = [0,a,b,c,d+1]

Measured memory_bytes: 7548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long maxS = 1e9 + 7;

int main(){
    float a , b , c;
    cin>>a>>b>>c;
    float t = a/b;
    if(t <= c){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MM=1000000007;
 
int main() {
  int N;
  ll K;
  cin >> N;
  cin >> K;
 
  int A[N];
  rep(i,N){
    cin >> A[i];
  }
 
  ll b[N]={};
  ll c[N]={};
 
 
  rep(i,N){
    rep(j,N){
      if(A[i] > A[j] && i > j ) b[i]++;
      if(A[i] > A[j] && i < j ) c[i]++;
    }
  }
 

 
  ll ans = 0;
 
  rep(i,N){

    ll x1 = (c[i] * ((K * (K + 1) / 2) % MM)) % MM;
    ll y1 = (b[i] * ((K * (K - 1) / 2) % MM)) % MM;
    ll z = (x1 + y1) % MM;
    ans = (ans + z) % MM;
  }
 
 
  cout << ans << endl;
 
 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    char s[1200] = {0};
    int c[26] = {0};
    int i=0;
    int j;
    int p;
    while(scanf("%c",&s[i])!=EOF){
        if(s[i]>=65&&s[i]<=90){
            p = s[i]-65;
            c[p]++;
        }
        else if(s[i]>=97&&s[i]<=122){
            p = s[i]-97;
            c[p]++;
        }
        i++;
    }
    /*for(i=0;i<1200;i++){
        printf("%c",s[i]);
        if(s[i]>=65&&s[i]<=90){
            p = s[i]-65;
            c[p]++;
        }
        else if(s[i]>=97&&s[i]<=122){
            p = s[i]-97;
            c[p]++;
        }
    }*/
    for(i=0;i<26;i++){
        printf("%c : %d\n",i+97,c[i]);
    }
    return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> score(N, K-Q);
  int t;
  for (int i = 0; i < Q; i++){
    cin >> t;
    score.at(t-1) += 1;
  }
  for (int i = 0; i < N; i++){
    if (score.at(i) >= 1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >>N;
  int cnt = 0;
  vector<int> order_p(N);
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
    order_p.at(i) = i + 1;
  }
  
  for(int i = 0; i < N; i++){
    if(p.at(i) != order_p.at(i)) cnt++;
  }
  
  if(cnt == 0 or cnt == 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;


long long gcd(long long a, long long b) {
    if(a < b) swap(a, b);
    long long ret = 1;
    while(b) {ret = b; b = a % b; a = ret;}
    return ret;
}

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

const int MAX = 1e5 + 10;
LL N, K;
LL A[MAX];
const string ok = "POSSIBLE";
const string ng = "IMPOSSIBLE";
set<LL> se;

int main(void) {
    scanf("%lld%lld", &N, &K);
    LL ma = 0;
    bool exist = false;
    bool odd = false;
    REP(i, N) {
        scanf("%lld", A + i);
        chmax(ma, A[i]);
        exist |= A[i] == K;
        se.insert(A[i]);
        odd |= (A[i] % 2);
    }    
    if (exist) {
        cout << ok << endl;
        return 0;
    }
    if (se.size() == 1) {
        cout << ng << endl;
        return 0;
    }
    if (ma < K) {
        cout << ng << endl;
        return 0;
    }
    sort(A, A + N);
    bool f = false;
    LL mi = LLINF;
    LL gcdNum = A[0];
    REP(i, N) gcdNum = gcd(gcdNum, A[i]);
    REP(i, N - 1) {
        f |= (se.count(A[i + 1] - A[i]) == 0);
        chmin(mi, A[i + 1] - A[i]);
    }
    if (f) {
        if (K % gcdNum == 0) cout << ok << endl;
        else cout << ng << endl;
    }
    else {
        cout << ng << endl;
    }
}


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

const int maxn = 1e4 + 10;
char s[maxn];
void solved(){
	scanf("%s",s+1);
	int len = strlen(s + 1);
	int l = (len - 1) / 2;
	int r = (len + 3) / 2;
	bool flag1 = true,flag2 = true;
	bool flag = true;
	for(int i = 1,j = len; i <= j ; i++,j--){
		if(s[i]!=s[j])flag = false;
	}
	for(int i = 1,j = l; i <= j ; i++,j--){
		if(s[i] != s[j])flag1 = false;
	}
	for(int i = r,j = len; i <= j ; i++,j--){
		if(s[i] != s[j])flag2 = false;
	}
	if(flag1 && flag2 && flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main(){
	solved();
	return 0;
}

Measured memory_bytes: 256
function Main(input){
	var xs = input.trim().split('\n').map(v=>parseInt(v,10));
      var A = 0;
      if(xs[0] <= xs[1]){
      A = A + xs[0];
      }else if(xs[0] >= xs[1]){
      A = A + xs[1];
      }
      var B = 0;
      if(xs[2] <= xs[3]){
      B = B + xs[2];
      }else if(xs[2] >= xs[3]){
      B = B + xs[3];
      }
    console.log(A+B);      
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b,q;
    cin>>a>>b>>q;
    vector<int>x(a),y(b);
    int m1=inf,m2=inf;
    for(int&t:x)
        cin>>t,m1=min(m1,t);
    for(int&t:y)
        cin>>t,m2=min(m2,t);
    int m=m1+m2;
    while(q-->0)
    {
        int p,q,r;
        cin>>p>>q>>r;
        m=min(m,x[p-1]+y[q-1]-r);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 100000000

using namespace std;

int main()
{
    int n;
    cin >> n;
    int tmp1, tmp2, ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> tmp1 >> tmp2;
        ans += (tmp2 - tmp1) + 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
h, w = map(int,input().split())
alphabet_large = [chr(i) for i in range(65, 65+26)]

for i in range(1,h+1):
    S = list(map(str,input().split()))
    for j in range(w):
        if S[j] == 'snuke':
            print(alphabet_large[j] + str(i))
            exit()

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	if(s.length() == 2){
		if(s[0] == s[1]) cout << "1 2" << endl;
		else cout << "-1 -1" << endl;
		return 0;
	}
	for(int i = 0; i < s.length()-2; i++){
		if(s[i] == s[i+1] || s[i+1] == s[i+2] || s[i+2] == s[i]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

const int N = 100;
int a[N];

void output_result(int a[], int n) {
  for (int i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

void insertion_sort(int a[], int n) {
  for (int i = 1; i < n; i++) {
    int key = a[i];
    /* insert A[i] into the sorted sequence A[0,...,j-1] */
    int j = i - 1;
    while (j >= 0 && a[j] > key) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = key;

    output_result(a, n);
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];

  output_result(a, n);

  insertion_sort(a, n);

  return 0;
}


Measured memory_bytes: 3084
class Dice
  def initialize(faces)
    @top = faces.shift
    @front = faces.shift
    @right = faces.shift
    @left = faces.shift
    @back = faces.shift
    @bottom = faces.shift
  end

  def turn_to_n
    old_top = @top
    @top = @front
    @front = @bottom
    @bottom = @back
    @back = old_top
  end

  def turn_to_e
    old_top = @top
    @top = @left
    @left = @bottom
    @bottom = @right
    @right = old_top
  end

  def turn_to_w
    old_top = @top
    @top = @right
    @right = @bottom
    @bottom = @left
    @left = old_top
  end

  def turn_to_s
    old_top = @top
    @top = @back
    @back = @bottom
    @bottom = @front
    @front = old_top
  end

  def rotate
    old_front = @front
    @front = @right
    @right = @back
    @back = @left
    @left = old_front
  end

  def right_when_top_and_front_are(top, front)
    set_top_to(top)
    keep_top_and_set_front_to(front)
    @right
  end

  def ==(other)
    return true if is_same?(other)
    4.times {
      other.rotate
      return true if is_same?(other)
    }
    3.times {
      turn_to_e
      4.times {
        other.rotate
        return true if is_same?(other)
      }
    }
    turn_to_e
    turn_to_n
    4.times {
      other.rotate
      return true if is_same?(other)
    }
    turn_to_s
    turn_to_s
    4.times {
      other.rotate
      return true if is_same?(other)
    }
    false
  end

  def is_same?(other)
    @top == other.top && @front == other.front && @right == other.right \
      && @left == other.left && @back == other.back && @bottom == other.bottom
  end

  attr_reader :top, :front, :right, :left, :back, :bottom

  private

  def set_top_to(top)
    return if @top == top
    case top
      when @front then turn_to_n
      when @left then turn_to_e
      when @right then turn_to_w
      when @back then turn_to_s
      else turn_to_s; turn_to_s
    end
  end

  def keep_top_and_set_front_to(front)
    return if @front == front
    case front
      when @left then turn_to_e; turn_to_s; turn_to_w
      when @right then turn_to_w; turn_to_s; turn_to_e
      when @back then turn_to_e; turn_to_s; turn_to_s; turn_to_w
    end
  end
end

dice1 = Dice.new(gets.split(" ").map(&:to_i))
dice2 = Dice.new(gets.split(" ").map(&:to_i))
puts dice1 == dice2 ? "Yes" : "No"

Measured memory_bytes: 8720
import java.util.Scanner;
class Main{
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){	
			int a = scanner.nextInt();//??????????????°??????????????????
			int b = scanner.nextInt();//????????????????????????????????°??????????????????
			int ans = a+b;
			if(ans<10){
				System.out.println("1");
			}
			if(ans<100 && ans>9){
				System.out.println("2");
			}
			if(ans<1000 && ans>99){
				System.out.println("3");
			}
			if(ans<10000 && ans>999){
				System.out.println("4");
			}
			if(ans<100000 && ans>9999){
				System.out.println("5");
			}
			if(ans<1000000 && ans>99999){
				System.out.println("6");
			}
			if(ans<10000000 && ans>999999){
				System.out.println("7");
			}
		}
	}
}

Measured memory_bytes: 26440
#include <bits/stdc++.h>
using namespace std;
long long color(int n, int k) {
    if (n == 1) return k;
    else return color(n - 1, k) * (k - 1);
}
int main() {
    int n, k;
    cin >> n >> k;
    cout << color(n, k);
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
using namespace std;
int a[100005];
long long int b[100005][2][2];
int main(){
	int n;
	long long int s=0,m=0;
	int i,j,k;
	long long int c,d,e;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	for(i=0,j=0;i<n;i++){
		while(m<(s/3)){
			m+=a[j];
			j++;j%=n;
		}
		b[i][0][0]=(j+n-1)%n;
		b[i][0][1]=m-a[b[i][0][0]];
		b[i][1][0]=j;
		b[i][1][1]=m;
		m-=a[i];
	}
	m=0;
	for(i=0;i<n;i++){
		for(j=0;j<2;j++){
			for(k=0;k<2;k++){
				c=b[i][j][1];
				d=b[b[i][j][0]][k][1];
				e=s-c-d;
				if(c>d)c=d;
				if(c>e)c=e;
				if(m<c)m=c;
			}
		}
	}
	cout<<m<<endl;
	return 0;
}

Measured memory_bytes: 6592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <functional>
#include <set>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(){
	int q, com;
	long x;
	std::set<long> s;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif

#if INPUT_FROM_FILE
	ifs >> q;
#else
	std::cin >> q;
#endif
	
	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		ifs >> com >> x;
#else
		std::cin >> com >> x;
#endif
		if(com == 0){
			s.insert(x);
			std::cout << s.size() << std::endl;
		}
		else if(com == 1){
			std::cout << s.count(x) << std::endl;
		}
		else{
			s.erase(x);
		}
	}
	return 0;
}


Measured memory_bytes: 12372
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9;

vector<vector<ll>> graph;
ll col[SIZE], dist[SIZE], par[SIZE];
pair<ll, ll> bst[SIZE];
bool used[SIZE];

pair<ll, ll> dfs(int v, int par = -1) {
    used[v] = 1;

    /*if (col[v] != -1) {
        if (abs(col[par] - col[v]) % 2 != abs(dist[par] - dist[v]) % 2) {
            cout << "No";
            exit(0);
        }
    }*/
    pair<ll, ll> pr = { -INF, INF };
    if (par != -1) pr = { col[par] - 1, col[par] + 1 };
    if (col[v] != -1) {
        pr = { col[v], col[v] };
    }
    for (auto to : graph[v]) {
        if (!used[to]) {
            dist[to] = dist[v] + 1;
            if (col[v] == -1) {
                pair<ll, ll> q = dfs(to, par);
                pr.first = max(pr.first, q.first - 1);
                pr.second = min(pr.second, q.second + 1);
            }
            else {
                pair<ll, ll> q = dfs(to, v);
                pr.first = max(pr.first, q.first - 1);
                pr.second = min(pr.second, q.second + 1);
            }
        }
    }

    bst[v] = pr;
    return pr;
}

void ch(int v, int par = -1) {
    used[v] = 1;

    if (col[v] != -1 && !(bst[v].first <= col[v] && bst[v].second >= col[v])) {
        cout << "No";
        exit(0);
    }

    bool flag = true;
    if (col[v] == -1) {
        if (bst[v].first <= col[par] - 1 && bst[v].second >= col[par] - 1) {
            col[v] = col[par] - 1;
            flag = false;
        }
        if (flag && bst[v].first <= col[par] + 1 && bst[v].second >= col[par] + 1) {
            flag = false;
            col[v] = col[par] + 1;
        }
    }
    else {
        flag = false;
    }

    if (flag) {
        cout << "No";
        exit(0);
    }
    for (auto to : graph[v]) {
        if (!used[to]) {
            ch(to, v);
        }
    }
}

int main() {
    fastInp;

    string s;
    ll cnt[2];
    cnt[0] = 0;
    cnt[1] = 0;

    cin >> s;

    ll pr = -1;
    for (int i = 0; i < s.size(); i++) {
        ll cr = 0;
        if (s[i] == 'W') cr = 1;

        if (cr != pr) {
            cnt[pr]++;
            pr = cr;
        }
    }

    cnt[pr]++;

    cout << cnt[0] + cnt[1] - 1;
    return 0;
}



Measured memory_bytes: 512
n = int(input())
d = []
for i in range(n):
  d.append(input().split())

ans = 'No'
cnt = 0
for x in d:
  if x[0] == x[1]:
    cnt += 1
    if cnt >= 3:
      ans = 'Yes'
      break
  else:
    cnt = 0
    
print(ans)

Measured memory_bytes: 62196
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    n <- fst . fromJust . B.readInt <$> B.getLine
    as <- V.fromList .(\s -> "0" : s) . B.words <$> B.getLine
    let printn i = do
            B.putStr $ as V.! i
            B.putStr " "
    mapM_ printn [n, (n - 2) .. 1]
    mapM_ printn $ if even $ length as then [2, 4 .. n] else [1, 3 .. n]


Measured memory_bytes: 24956
#include<bits/stdc++.h>
using namespace std;
char s[5][200007];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=3;i++){
        scanf("%s",s[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[1][i]==s[2][i]&&s[2][i]==s[3][i])
            continue;
        else if(s[1][i]==s[2][i]||s[1][i]==s[3][i]||s[2][i]==s[3][i]){
            ans++;
        }
        else
            ans+=2;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    int cnt[n + 1] = {};
    k = min(k, 50);
    while (k--) {
        rep(i, 0, n) {
            int s = max(0, i - a[i]);
            int e = min(n - 1, i + a[i]);
            cnt[s]++;
            cnt[e + 1]--;
        }
        rep(i, 0, n - 1) cnt[i + 1] += cnt[i];
        rep(i, 0, n) a[i] = cnt[i];
        rep(i, 0, n + 1) cnt[i] = 0;
    }
    rep(i, 0, n) cout << a[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 5184
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define MOD 1000000007

int main(){
	int H,W; cin>>H>>W;

	string grid[H];
	rep(h, H) cin>>grid[h];

	int dp[H+1][W+1];
	rep(h, H+1) rep(w, W+1) dp[h][w] = 0;
	dp[1][1] = 1;

	rep(h, H){
		rep(w, W){
			if(grid[h][w] == '#') continue;
			if(w+1 < W && grid[h][w+1] == '.')
				dp[h+1][w+2] = (dp[h+1][w+1] + dp[h][w+2]) % MOD;
			if(h+1 < H && grid[h+1][w] == '.')
				dp[h+2][w+1] = (dp[h+1][w+1] + dp[h+2][w]) % MOD;
		}
	}
	cout<< dp[H][W] <<endl;
}


Measured memory_bytes: 5248
/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 ヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll n;
	cin>>n;
	cout<<(n*(n-1))/2;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var n, m int
	fmt.Fscanf(reader, "%d %d\n", &n, &m)
	fmt.Fprintf(writer, "%d\n", (n-1)*(m-1))
}


Measured memory_bytes: 640
s = gets.chomp.split("")
t = gets.chomp.split("")

flag = true
if s.uniq.count < t.uniq.count
  # お手本よりも文字種別数が少ない場合にはそもそも無理。
  flag = false
else
  # tに含まれている各文字について、tにおいてその文字が現れる箇所を抽出し、
  # sにおける同じ箇所の文字を確認。このときその文字種別が1でない場合には
  # 一致させることはできない。
  t.uniq.each do |char|
    # p char
    # p t.map.with_index { |e, i| e==char ? i : nil }.compact
    # p t.map.with_index { |e, i| e==char ? i : nil }.compact.map { |i| s[i] }
    # p t.map.with_index { |e, i| e==char ? i : nil }.compact.map { |i| s[i] }.uniq
    # p t.map.with_index { |e, i| e==char ? i : nil }.compact.map { |i| s[i] }.uniq.size
    # p t.map.with_index { |e, i| e==char ? i : nil }.compact.map { |i| s[i] }.uniq.size == 1
    if t.map.with_index { |e, i| e==char ? i : nil }.compact.map { |i| s[i] }.uniq.size != 1
      flag = false
      break
    end
  end
end

puts flag ? "Yes" : "No"


Measured memory_bytes: 38100
S = list(input())
T = list(input())

S.sort()
T.sort(reverse = True)

if len(S) < len(T):
    for i in range(len(S)):
        if S[i] < T[i]:
            print("Yes")
            quit()
        if S[i] > T[i]:
            print("No")
            quit()
    print("Yes")

else:
    for i in range(len(T)):
        if S[i] < T[i]:
            print("Yes")
            quit()
        if S[i] > T[i]:
            print("No")
            quit()
    print("No")


Measured memory_bytes: 38352
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

vector<long long> a;
int n;

vector<pair<long long, int>> arr;

void push(long long b, long long m) {
  while (arr.size() > 0 && arr[arr.size() - 1].first > b) {
    arr.pop_back();
  }
  if (arr.size() == 0 || arr[arr.size() - 1].first < b) {
    arr.push_back(make_pair(b, 1));
  } else {
    arr[arr.size() - 1].second++;
    if (arr[arr.size() - 1].second >= m) {
      push(b - 1, m);
    }
  }
}

void drop(long long b, long long m) {
  while (arr.size() > 0 && arr[arr.size() - 1].first > b) {
    arr.pop_back();
  }
}

bool f(long long m) {
  if (m == 1) {
    for (int i = 1; i < n; i++)
      if (a[i] <= a[i - 1])
        return false;
    return true;
  }

  arr.clear();
  for (int i = 1; i < n; i++) {
    if (a[i] <= a[i - 1]) {
      push(a[i], m);
    } else {
      drop(a[i - 1], m);
    }
  }
  bool ret = true;
  for (auto &it : arr) {
    if (it.first <= 0)
      ret = false;
  }

  return ret;
}

int main() {
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  if (f(1)) {
    cout << 1 << endl;
    return 0;
  }
  if (f(2)) {
    cout << 2 << endl;
    return 0;
  }
  if (f(3)) {
    cout << 3 << endl;
    return 0;
  }

  long long mx = n;
  long long my = 0;
  while (mx - my > 1) {
    long long mm = (mx + my) / 2;

    if (f(mm)) {
      mx = mm;
    } else {
      my = mm;
    }
  }
  cout << mx << endl;

  return 0;
}


Measured memory_bytes: 1792
/* 
/*-----------------------------------------------*/
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long int ll;
typedef vector<ll> vll;
/*-----------------------------------------------*/
// #define DBGMODE
#ifdef DBGMODE
	#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
	#define debug(...)
#endif
/*-----------------------------------------------*/
const int MOD = 1e9 + 7;
int N;
vector<string> perms;
map<string, ll> M[110];
string ch [] = { "A", "C", "G", "T" };

void generate_perms () {
	for (int a = 0; a < 4; a++)
		for (int b = 0; b < 4; b++)
			for (int c = 0; c < 4; c++)
				perms.push_back(ch[a] + ch[b] + ch[c]);
}

bool can_add_c (string p) {
	bool b1 = p[0] == 'A' && (p[1] == 'G' || p[2] == 'G');
	bool b2 = p[1] == 'A' && p[2] == 'G';
	bool b3 = p[2] == 'A' && p[1] == 'G';
	return !(b1 || b2 || b3);
}

bool can_add_g (string p) {
	return !(p[1] == 'A' && p[2] == 'C');
}

bool valid (string p) {
	if (p == "AGC" || p == "ACG" || p == "GAC") return false;
	return true;
}
/*-----------------------------------------------*/
int main() {
	#ifdef DBGMODE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	generate_perms();
	for (string s : perms) debug("%s\n", s.c_str());
	scanf("%d", &N);
	for (int i = 0; i < perms.size(); i++) 	{
		if (valid(perms[i])) M[3][perms[i]] = 1;
	}

	for (int i = 4; i <= N; i++) {
		for (int j = 0; j < perms.size(); j++) {
			string p = perms[j];
			string q = p.substr(1);
			ll cnt = M[i - 1][p];
			vi can = { 0, 3 };
			if (can_add_c(p)) can.push_back(1);
			if (can_add_g(p)) can.push_back(2);
			for (int z : can) {
				string tmp = q + ch[z];
				// ll& tmp = M[i][q + ch[z]]
				M[i][q + ch[z]] = ( M[i][q + ch[z]] + cnt ) % MOD;
			}
		}
	}
	ll ans = 0;
	for (auto it = M[N].begin(); it != M[N].end(); it++) ans = (ans + it->second) % MOD;
	printf("%lld\n", ans);
}

Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
import math
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = 10**15

a, b, x = [int(item) for item in input().split()]
s = x / a
if s >= a * b / 2:
    hgt = (a * b - s) * 2 / a
    ans = math.atan2(hgt, a) / math.pi * 180.0
    print(ans)
else:
    hgt = s*2 / b
    ans = (0.5 * math.pi - math.atan2(hgt, b)) / math.pi * 180.0
    print(ans)

Measured memory_bytes: 3064
from fractions import gcd


def is_prime(n):
    if n < 2:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    m = 3
    while m ** 2 <= n:
        if n % m == 0:
            return False
        m += 2
    return True


A, B = map(int, input().split())
d = gcd(A, B)
n = 1
s = set()
while n ** 2 <= d:
    if d % n == 0:
        if is_prime(n):
            s.add(n)
        if is_prime(d // n):
            s.add(d // n)
    n += 1
s.add(1)
print(len(s))

Measured memory_bytes: 65896
use std::str::FromStr;



fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let nk : Vec<usize> = get_vec();
    let n : usize = nk[0];
    let k : usize = nk[1];
    let v : Vec<f64> = get_vec();
    let mut ev : Vec<f64> = Vec::new();
    for x in v {
        ev.push((1_f64 + x) / 2_f64);
    }
    let mut sm = 0_f64;
    for i in 0..k {
        sm += ev[i];
    }
    //println!("{:?}", ev);
    let mut ans = sm;
    for i in k..n {
        sm -= ev[i-k];
        sm += ev[i];
        //println!("{} {}", ans, sm);
        if sm > ans {
            ans = sm;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 10492
import java.util.Scanner;

public class Main {

   public static void main(String[] args) {
       Scanner in= new Scanner(System.in);
        int a=in.nextInt(),b=in.nextInt();
        if(a%2==b%2){
            System.out.println((a+b)/2);
        }else {
            System.out.println("IMPOSSIBLE");
        }


       }
}

Measured memory_bytes: 35712
#include<iostream>
using namespace std;
int main(){
  int p,j,P,J;
  cin>>P;
  for(int i=0;i<2;i++){
    cin>>p;
    if(p<P)P=p;
  }
  cin>>J;
  cin>>j;
  if(j<J)J=j;
  cout<<J+P-50<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

#define int long long

using namespace std;

const int N = 2e5 + 10;

int32_t main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if (!a) cout << 1;
    else if (!b) cout << 2;
    else if (!c) cout << 3;
    else if (!d) cout << 4;
    else cout << 5;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int MaxCM(vector<int> A){
	int n = A.size() - 1, min, val;
	vector< vector<int> > table(n, vector<int>(n, 0));
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n - i; j++){
			for (int k = 0; k < i; k++){
				val = table[j][j + k] + table[j + k + 1][j + i] + A[j] * A[j + k + 1] * A[j + i + 1];
				if (k == 0 || val < min) min = val;
			}
			if (i != 0) {
				table[j][j + i] = min;
			}
			else{
				table[j][j] = 0;
			}
		}
	}
	return table[0][n - 1];
}

int main(){
	int n, dum;
	scanf("%d", &n);
	vector<int> A(n + 1);
	for (int i = 0; i < n; i++){
		if (i == 0){
			scanf("%d%d", &A[0], &A[1]);
		}
		else{
			scanf("%d%d", &dum, &A[i + 1]);
		}
	}
	printf("%d\n", MaxCM(A));

	return 0;
}


Measured memory_bytes: 3316
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var n=arr.shift()-0;
var a=arr.shift().split(" ").map(Number);
var q=arr.shift()-0;
for(var i=0;i<q;i++){
   var [b,e,t]=arr[i].split(" ").map(Number);
   var k=e-b;
   for(var j=0;j<k;j++){
      [a[b+j],a[t+j]]= [a[t+j], a[b+j]];
   }
}
console.log(a.join(" "));


Measured memory_bytes: 19520
import java.util.Scanner

fun main(args:Array<String>){
    val sc = Scanner(System.`in`);
    val a: Int = sc.nextInt()
    val b: Int = sc.nextInt()
    val c: Int = sc.nextInt()
    val list = listOf(a*10+b+c, b*10+a+c, c*10+a+b)
    println(list.max())
}

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

int puede[100005][2];
int as[105];
int n;

int calc(int k, int p){
    if(puede[k][p]!=0){
        return puede[k][p];
    }
    puede[k][p]=-1;
    for(int i=0; puede[k][p]==-1 && i<n && as[i]<=k; i++){
       if(calc(k-as[i],(p+1)%2)==-1){
           puede[k][p]=1;
       }
    }
    return puede[k][p];
}

int main(){
    int k;
    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>as[i];
    }
    memset(puede, 0, sizeof(puede));
    puede[0][1] = puede[0][0] = -1;
    calc(k,0);
    if(puede[k][0] == 1){
        printf("First\n");
    }
    else{
        printf("Second\n");
    }
    return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  int a;
  a=0;
  for(int i=0;i<N-1;i++){
  if(S.at(i)!=S.at(i+1)){
    a++;
  }
  }
    int ans;
    for(int i=0;i<N-1;i++){
      if(S.at(i)==S.at(i+1)){
        ans++;
      }
    }
    if(a/2>=K){
      ans+=2*K;
    }
      else {
        int c=0;
        c=a/2;
        ans+=K+c;
      }
      if(ans<N-1){
        cout<<ans<<endl;
      }
  else{
    cout<<N-1<<endl;
  }
    
    
  
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
	int a[100005];
	int n;
	scanf("%d",&n);
	int f1=0,f2=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(a[i]%4==0)f1++;
		else if(a[i]%2==0)f2++;
	}
	if(f2!=0){
		if(n-f2-f1<=f1)printf("Yes\n");
		else printf("No\n");
	}	
	else{
		if(f1*2+1>=n)printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 512
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

set<ll> st;

int main()
{
    IOS();
    ll n,y;
    cin>>n>>y;
    y/=1000;
    REP(i,n+1)
    {
      if(i*10>y)break;
      ll k= n-i;
      ll tmp=(y-i*10-k);
      if(tmp>=0&&tmp%4==0&&k-tmp/4>=0)
      {
        cout<<i<<" "<<tmp/4<<" "<<k-tmp/4<<endl;
        return 0;
      }
    }
    cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256