akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000006
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

lli r, c;
lli ch, cw;
lli dh, dw;
vector<string>ara;
string str;
char sara[1004];
lli level[1000006];
lli vis[1004][1004];
vector<pair<lli, lli> >compo[1000006];
lli cur=1;

lli fx[]= {+1, -1, 0, 0};
lli fy[]= {0, 0, +1, -1};

queue<lli >q;


void dfs(lli x, lli y)
{
    for(lli i=0; i<4; i++)
    {
        lli nx= x+fx[i];
        lli ny= y+fy[i];

        if(nx>=0 && nx<r && ny>=0 && ny<c && ara[nx][ny]=='.' && vis[nx][ny]==0)
        {
            vis[nx][ny]= cur;
            dfs(nx, ny);
        }
    }
}



int main()
{
    scanf("%lld %lld", &r, &c);
    scanf("%lld %lld", &ch, &cw);
    scanf("%lld %lld", &dh, &dw);

    ch--;
    cw--;
    dh--;
    dw--;


    for(lli i=0; i<r; i++)
    {
        scanf("%s", &sara);
        str= sara;

        ara.push_back(str);
    }

    for(lli i=0; i<r; i++)
    {
        for(lli j=0; j<c; j++)
        {
            if(vis[i][j]==0 && ara[i][j]=='.')
            {
                vis[i][j]= cur;
                dfs(i, j);
                cur++;
            }
        }
    }

    for(lli i=0; i<r; i++)
    {
        for(lli j=0; j<c; j++)
        {
            if(vis[i][j]) compo[vis[i][j]].push_back({i, j});
        }
    }

    memset(level, -1, sizeof level);
    q.push(vis[ch][cw]);
    level[vis[ch][cw]]=0;

    while(q.size())
    {
        lli node= q.front();

        q.pop();

        for(lli k=0; k<compo[node].size(); k++)
        {
            lli x= compo[node][k].first;
            lli y= compo[node][k].second;

            for(lli i=x-2; i<=x+2; i++)
            {
                for(lli j=y-2; j<=y+2; j++)
                {
                    if(i>=0 && i<r && j>=0 && j<c && ara[i][j]=='.' && level[vis[i][j]] ==-1)
                    {
                        level[vis[i][j]]=level[node]+1;
                        q.push(vis[i][j]);
                    }
                }
            }
        }
    }

    cout<<level[vis[dh][dw]]<<endl;








    return 0;
}


Measured memory_bytes: 55392
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

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

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> n >> m >> k)
    {
		ll ans = n / m;

		if(n % m) ans++;

		cout << ans * k << endl;
    }

}





Measured memory_bytes: 3632
using System;
using System.Text;

namespace ITP_7_C{
    public class Program{
        public static void Main(string[] args){
            string[] temp = Console.ReadLine().Split(' ');
            int row = int.Parse(temp[0]);
            int column = int.Parse(temp[1]);
            int[] lastRow = new int[column];
            StringBuilder ans = new StringBuilder();

            //???????????????????¨?????????????
            for(int i=0; i<row; i++){
                string[] data = Console.ReadLine().Split(' ');
                int sum = 0;

                for(int k=0; k<column; k++){
                    int num = int.Parse(data[k]);
                    sum += num;
                    lastRow[k] += num;
                    ans.Append(num + " ");
                }
                ans.AppendLine(sum.ToString());
            }

            int last = 0;
            //?????????????¨????
            for(int i=0; i<column; i++){
                last += lastRow[i];
                ans.Append(lastRow[i] + " ");
            }
            ans.AppendLine(last.ToString());
            Console.Write(ans.ToString());
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<int> P(n);
    for (int i = 0; i < n; i++){
        cin >> P.at(i);
    }
    int count;
    for (int i = 1; i < n - 1; i++){
        if (P.at(i-1) > P.at(i) && P.at(i) > P.at(i+1)){
            count++;
        }
        if (P.at(i-1) < P.at(i) && P.at(i) < P.at(i+1)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[5];
void solve()
{
    int val = 0;
    for(int i = 1 ;i <=5; i++){
        cin>>a[i];
        if(val == a[i]){
            cout<<i;
            return;
        }
    }
    
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //cerr.tie(nullptr)
    
        solve();
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=200005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

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

    ll x;
    cin >> x;
    x-=400;
    x/=200;
    cout << 8-x << endl;
}


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

int main(){
    int N;
    string S;
    cin >> N >> S;
    if(N%2==1){
        cout << "No";
        return 0;
    }
    rep(i,N/2){
        if(S[i]!=S[i+N/2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    vector<int> A(3); rep(i, 3) cin >> A[i];
    sort(A.begin(), A.end(), greater<int>());

    cout << 10 * A[0] + A[1] + A[2] << endl;
    return 0;
}


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

using namespace std;

int main()
{
  int N, Command, Val;
  string Color, LB, UB;
  map<string, int> Map;

  cin >> N;

  for(int i = 0; i < N; ++i)
  {
    cin >> Command >> Color;

    if(Command == 0)
    {
      cin >> Val;
      Map[Color] = Val;
    }
    else if(Command == 1)
      cout << (Map.find(Color) != Map.end() ? Map[Color] : 0) << endl;
    else if(Command == 2)
      Map.erase(Color);
    else 
    {
      LB = Color;
      cin >> UB;

      map<string, int>::iterator ite = Map.lower_bound(LB);
      map<string, int>::iterator last = Map.upper_bound(UB);

      while(ite != last)
      {
	cout << ite->first << " " << ite->second << endl;
	++ite;
      }

    }
  }
  return 0;
}


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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d||abs(b-a)<=d&&abs(c-b)<=d) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*
           Nothing is absolute.
     This is the only absolute truth.
*/

#include<bits/stdc++.h>

using namespace std;

using ull = unsigned long long;
using ll = long long;

#define READ freopen("in.txt", "r", stdin)
#define ROUT freopen("out.txt", "w", stdout)
#define pb push_back
#define endl '\n'

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

void fileIO()
{
    READ;
    //ROUT;
}

int main()
{
    //fileIO();
    fasterIO();

    int n, m, sum = 0;
    cin>>n>>m;

    if(n>1) {
        for(int i = n-1; i>=1; i--) {
            sum+=i;
        }
    }

    if(m>1) {
        for(int i = m-1; i>=1; i--) {
            sum+=i;
        }
    }

    cout<<sum<<endl;

    exit(0);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int h,m,s,hh,mm,ss,tsec,tsec3;
		while(scanf("%d%d%d",&h,&m,&s) , h != -1){
			tsec = h * 3600 + m * 60 + s;
			tsec = 7200 - tsec;
			tsec3 = tsec * 3;
			hh = tsec / 3600;
			tsec = tsec - hh * 3600;
			mm = tsec / 60;
			tsec = tsec - mm * 60;
			ss = tsec;
			printf("%02d:%02d:%02d\n",hh,mm,ss);
			hh = tsec3 / 3600;
			tsec3 = tsec3 - hh * 3600;
			mm = tsec3 / 60;
			tsec3 = tsec3 - mm * 60;
			ss = tsec3;
			printf("%02d:%02d:%02d\n",hh,mm,ss);
		}
	return 0;
}

Measured memory_bytes: 612
import java.util.Scanner;

public class Main{
    public static void main(String args[]){

    Scanner scan = new Scanner(System.in);

    String s = scan.nextLine();
    String t = scan.nextLine();

      
    String tt = t.substring(0, t.length()-1);

    
      
  
      if ( (s.length() == t.length() -1) && (s.equals(tt)) ){
          System.out.println("Yes");
      } else {
          System.out.println("No");
      }

      scan.close();
    }
  }

Measured memory_bytes: 35740
import java.util.Scanner;

public class Main {

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

		int count = n / x;
		if (n % x != 0) {
			count++;
		}

		print(count * t);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}
}


Measured memory_bytes: 35716
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static long N = sc.nextLong();
	static long P = sc.nextLong();
	static class Pair {
		public long x;
		public long y;
		public Pair(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}
	public static void main(String[] args) {
		long ans = 1;
		Queue<Pair> que = new ArrayDeque<>();
		for (long i = 2; i*i <= P; i++) {
			if (P%i != 0) continue;
			long count = 0;
			while (P % i == 0) {
				count++;
				P /= i;
			}
//			System.out.println(count);
			Pair pair = new Pair(i, count);
			que.add(pair);
		}
		if (P != 1) {
			que.add(new Pair(P, 1));
		}
		while (!que.isEmpty()) {
			Pair pair2 = que.poll();
			for (int i = 0; i < pair2.y/N; i++) {
				ans *= pair2.x;
			}
		}
		System.out.println(ans);
	}
}



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

int main() {
  int A;
  int B;
  cin >> A >> B;

  int total = 1;

  int taps = 0;

  while(total < B) {
    total += (A-1);
    taps++;
  }

  cout << taps << endl;

  return 0;

}

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

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> p(n);
	for(auto&a:p) cin >> a,--a;
	int ans=0;
	for(int i=0;i<n;++i) {
		if(p[i]==i) {
			if(i==n) swap(p[i-1],p[i]);
			else swap(p[i],p[i+1]);
			++ans;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 640
public class Main{
  public void run(java.io.InputStream in,java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*????????§Input*/
    int i, n;
    for(i = 1;;++i){
      n = sc.nextInt();
      if(n != 0){
        System.out.println("Case " + i + ": " + n);
      }else{
        break;
      }
    }
    sc.close();
/*answer*/
/*???????????±?????????????????\???????????????????????????????????????????????????????????¨??????*/

  }
  public static void main(String[] args){
    (new Main()).run(System.in,System.out);
  }
}

Measured memory_bytes: 33028
a=input()
List=list(a)
n=len(List)

for i in range(2**(n-1)):
    s=['-']*(n-1)
    for j in range(n-1):
        if i>>j & 1:
            s[j]='+'

    formula=''

    for num,sign in zip(List,s):
        formula += (num + sign)
    formula += List[n-1]

    if eval(formula)==7:
        print(formula+'=7')
        break

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>

using namespace std;

int main(){
    set<int> s;
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        int d;
        cin >> d;
        s.insert(d);
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cmath>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 10000007

typedef  long long ll;

using namespace std;

void solve(void){
   ll a,b,c;
   cin >> a >> b >> c;
   if(a-c >= 0) cout << a-c << ' ' << b << endl;
   else cout << 0 << ' ' << max(b+a-c,(ll)0) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define DEBUG

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 52, maxm = (1 << 21);
const double PI = acos(-1);
vector<pii> adj[maxn];
vector<set<int>> xs;
ll memo[maxn][maxm];

void create_path(int start, int finish, int n){
    vector<int> pai(n+1), indice(n+1), vis(n+1, 0);
    queue<int> fila;

    fila.push(start);
    vis[start] = 1;

    while(not fila.empty()){

        int atual = fila.front();
        fila.pop();

        for (auto p: adj[atual]){
            int next = p.ff, id = p.ss;

            if (not vis[next]){
                pai[next] = atual;
                indice[next] = id;
                vis[next] = 1;

                fila.push(next);
            }
        }
    }

    int d = finish;
    set<int> path;

    while(start != d){
        path.insert(indice[d]);
        d = pai[d];
    }

    xs.push_back(path);
}

ll dp(int aresta, int mask, int N, int M){
    if (aresta == N-1){
        if (mask == (1 << M) - 1) return 1;
        return 0;
    }

    if (memo[aresta][mask] != -1) return memo[aresta][mask];

    ll res = dp(aresta+1, mask, N, M);
    int nmask = mask;

    for (int i=0; i<M; i++){
        if (xs[i].count(aresta)) nmask |= (1 << i);
    }

    res += dp(aresta + 1, nmask, N, M);

    memo[aresta][mask] = res;
    return res;
}

int main (){
    int n, u, v, m;
    memset(memo, -1, sizeof memo);
    cin >> n;

    for (int i=0; i<n-1; i++){
        cin >> u >> v;
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }

    cin >> m;

    for (int i=0; i<m; i++){
        cin >> u >> v;
        create_path(u, v, n);
    }

    cout << dp(0, 0, n ,m) << endl;
    return 0;
}

Measured memory_bytes: 852224
#include <stdio.h>

int main(){

    long long N;

    long long cnt = 0;

    scanf("%lld", &N);

    long long num;

    for(long long i = 1; i <= N; i++){
        if(N%i == 0){
            num = (N/i) - 1;
            cnt += num;
        }else{
            num = N/i;
            cnt += num;
        }
    }

    printf("%lld\n", cnt);

    return 0;
}

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

int myMap[51][51];
int w, h;
int ans;

bool safe(int x, int y){
    return (0 <= x && 0 <= y) && (x < h && y < w);
}

void del(int x, int y){
    myMap[x][y] = 0;
    if (safe(x+1, y) && myMap[x+1][y]) del(x+1, y);
    if (safe(x+1, y+1) && myMap[x+1][y+1]) del(x+1, y+1);
    if (safe(x+1, y-1) && myMap[x+1][y-1]) del(x+1, y-1);
    if (safe(x, y+1) && myMap[x][y+1]) del(x, y+1);
    if (safe(x, y-1) && myMap[x][y-1]) del(x, y-1);
    if (safe(x-1, y-1) && myMap[x-1][y-1]) del(x-1, y-1);
    if (safe(x-1, y+1) && myMap[x-1][y+1]) del(x-1, y+1);
    if (safe(x-1, y) && myMap[x-1][y]) del(x-1, y);
    return;
}

int main(){

    while (1){
	cin >> w >> h;
	if (w == 0 && h == 0) break;

	for (int i = 0; i < h; i++){
	    for (int j = 0; j < w; j++){
		cin >> myMap[i][j];
	    }
	}

	ans = 0;	
	for (int i = 0; i < h; i++){
	    for (int j = 0; j < w; j++){
		if (myMap[i][j] == 1){
		    ans++;
		    del(i, j);
		}
	    }
	}

	cout << ans << endl;
    }
}

Measured memory_bytes: 0
/*
    	Samrat De
    	NIT Durgapur
    	A Noob Coder
    */
     
    /*#include<iostream>
    #include<functional>
    #include<ext/pb_ds/assoc_container.hpp>
    #include<ext/pb_ds/tree_policy.hpp>*/
    #include<bits/stdc++.h>
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define ll long long int
    #define vec(x) vector<x> 
    #define st(x) set<x> 
    #define mpp(x,y) map<x,y>
    #define qq(x) queue<x>
    #define pqq(x) priority_queue<x> 
    #define min_heap(x) priority_queue<x, vector<x>, greater<x> >
    #define pi(x,y) pair<x,y>
    #define rep(i,x,y) for(ll i=x;i<y;i++)
    #define rel(i,x,y) for(ll i=x-1;i>=y;i--)
    #define rev(x) reverse(x.begin(),x.end())
    #define mem(x,a) memset(x,a,sizeof(x))
    #define mod 1000000007
    #define nxt_per(x) next_permutation(x.begin(),x.end())
    #define pb push_back
    #define pf push_front
    #define vp(x,y) vec(pi(x,y) )
    #define all(x) x.begin(),x.end()
    #define indexof order_of_key
    #define valueat find_by_order
    #define myds tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> 
     
    int dx[4]={0,0,1,-1};
    int dy[4]={1,-1,0,0};
    int dxx[8]={0,0,1,-1,-1,-1,1,1};
    int dyy[8]={1,-1,0,0,-1,1,1,-1};
     
    /*
    unordered_map<ll,ll> um
    um.reserve(1<<15);
    um.max_load_factor(0.25);
    */
     
    using namespace std;
    //using namespace __gnu_pbds;
     
    int32_t main()
    {
    	fastio;
    // best of luck don't loose hope man	
     
        int n,m,c;
        cin>>n>>m>>c;
        ll arr[m];
        rep(i,0,m)
        	cin>>arr[i];
        vec(ll) v[n];
        rep(i,0,n){
        	rep(j,0,m)
        	{	ll x;cin>>x;
        		v[i].pb(x);
        	}
        }
        int count=0;
        rep(i,0,n){
        	ll ans=0;
     		rep(j,0,m)
     			ans+=v[i][j]*arr[j];
     		if(ans+c>0)
     			count++;
        }
        cout<<count;
    	return 0;
    }

Measured memory_bytes: 256
use std::io::*;
mod fenwick_tree {
    use std::ops::*;
    pub struct FenwickTree<T> {
        data: Vec<T>,
        identity: T,
    }
    impl<T: Copy + Clone + AddAssign + Sub<Output = T>> FenwickTree<T> {
        pub fn new(size: usize, id: T) -> FenwickTree<T> {
            FenwickTree {
                data: vec![id; size + 1],
                identity: id,
            }
        }
        fn prefix_sum(&self, i: usize) -> T {
            let mut res = self.identity;
            let mut idx = i;
            while idx > 0 {
                res += self.data[idx];
                idx -= ((idx as isize) & -(idx as isize)) as usize;
            }
            res
        }
        pub fn update(&mut self, i: usize, x: T) {
            let mut idx = i;
            while idx < self.data.len() {
                self.data[idx] += x;
                idx += ((idx as isize) & -(idx as isize)) as usize;
            }
        }
        pub fn query(&self, l: usize, r: usize) -> T {
            self.prefix_sum(r) - self.prefix_sum(l - 1)
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n = itr.next().unwrap().parse::<usize>().unwrap();
    let m = itr.next().unwrap().parse::<usize>().unwrap();
    let mut ft = fenwick_tree::FenwickTree::new(n, 0);
    let mut out = Vec::new();
    for _ in 0..m {
        let c: usize = itr.next().unwrap().parse().unwrap();
        let x: usize = itr.next().unwrap().parse().unwrap();
        let y: usize = itr.next().unwrap().parse().unwrap();
        if c == 0 {
            ft.update(x, y);
        } else {
            writeln!(out, "{}", ft.query(x, y)).unwrap();
        }
    }
    stdout().write_all(&out).unwrap();
}



Measured memory_bytes: 6976
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def is_ok(s):
    return s == ''.join(reversed(s))

def main():
    s = input().strip()
    n = len(s)
    if is_ok(s) and is_ok(s[0:(n-1)//2]) and is_ok(s[(n+3)//2-1:n]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38528
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

count = 0
(0...n).each do |i|
  if a[i] >= b[i] 
    count += b[i]
  elsif a[i] + a[i+1] >= b[i]
    count += b[i]
    a[i+1] -= b[i]-a[i]
  else
    count += a[i]+a[i+1]
    a[i+1] = 0
  end
end

puts count

Measured memory_bytes: 15508
A, B, C, X, Y = map(int, input().split())
ans = A * X + B * Y
for i in range(max(X, Y)):
    ans_temp = ans
    if i >= X:
        ans_temp += A
    if i >= Y:
        ans_temp += B
    ans = min(ans, ans_temp - A - B + 2 * C)
print(ans)


Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
	int a,b;
	char op;
	cin >> a >> op >> b;
	if(op == '+')
	{
		cout << a + b <<endl;
	}
	if(op == '-')
	{
		cout << a - b <<endl;
	}
	return 0;
}

Measured memory_bytes: 764
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 1000000007;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

Int f(Int a, Int b) {
    return max(digits(a), digits(b));
}

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

    Int n;
    cin >> n;

    vector<Int> divs = divisor(n);
    Int ans = INF;
    Int ro = divs.size();
    for (Int i = 0; i < ro; i++) {
        ans = min(ans, f(divs[i], divs[ro - i - 1]));
    }

    cout << ans << endl;

    return 0;
}

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

#define MAX 1000000

int suretsu(int a,int d,int i){
     return a+d*(i-1);
}

int main(){
     bool sosu[MAX+1];
     for(int i=0;i<MAX;i++)sosu[i]=true;
     for(int i=2;i<sqrt(MAX)+1;i++){
	  if(sosu[i]){
	       for(int j=2;j<MAX/i+1;j++)
			sosu[i*j]=false;
	  }
     }
     sosu[1]=false;
     int a,d,n;
     while(cin>>a>>d>>n,a||d||n){
	  int count=0;
	  int i=1;
	  while(count!=n){
	       if(sosu[suretsu(a,d,i)])count++;
	       i++;
	  }
	  cout<<suretsu(a,d,i-1)<<endl;
     }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<int>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e18

ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}

int main(){
	float h, w;
	cin >> h >> w;
	float x;
	cin >> x;

	cout << ceil(x/max(h, w));
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <sstream>
#include <deque>
#include <cmath>

using namespace std;
using ll = long long;

int main() {

    int a, b, c, k;

    cin >> a >> b >> c >> k;

    int sum = 0;
    if (k > 0) {
        int drawn = min(a, k);
        sum += drawn;
        k -= drawn;
    }
    if (k > 0) {
        int drawn = min(b, k);
        k -= drawn;
    }
    if (k > 0) {
        int drawn = min(c, k);
        sum -= drawn;
        k -= drawn;
    }

    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int ar[]=new int[n-1];
		for(int i=0;i<n-1;i++)
		{
			ar[i]=scan.nextInt();
		}
		int sum=0;
		for(int i=0;i<n-2;i++)
		{
			sum+=Math.min(ar[i],ar[i+1]);
		}
		sum+=ar[0]+ar[n-2];
		System.out.println(sum);
	}
}


Measured memory_bytes: 21716
import bisect
n = int(input())
w = list(map(int, input().split()))
mean = sum(w)/len(w)
is_complete = False
idx = bisect.bisect_left(w, mean)
while not is_complete:
    is_complete = True
    diff = abs(sum(w[:idx:]) - sum(w[idx::]))
    if idx != 0:
        diff_left = abs(sum(w[:idx-1:]) - sum(w[idx-1::]))
        if diff_left < diff:
            diff = diff_left
            idx = idx - 1
            is_complete = False
    if idx != len(w)-1:
        diff_right = abs(sum(w[:idx+1:]) - sum(w[idx+1::]))
        if diff_right < diff:
            diff = diff_right
            idx = idx + 1
            is_complete = False
print(diff)

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

const int MAX=510000;

int main()
{
    string s;
    cin>>s;
    rep(i,3)
    {
        if(s[i]==s[i+1])
        {
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(int argc, char const *argv[]) {
    int c[3][3];
    int a[3]={0},b[3]={0};

    rep(i,3)rep(j,3)cin>>c[i][j];
    // rep(i,3){
    //     rep(j,3){
    //         cout << c[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    int itr=101;
    rep(i,itr)rep(j,itr)rep(k,itr){
        int b_cand[3];
        a[0]=i;
        a[1]=j;
        a[2]=k;
        rep(h,3){
            b_cand[h]=c[0][h]-a[0];
        }
        //printf("%d %d %d\n",b_cand[0],b_cand[1],b_cand[2]);
        int cnt=0;
        rep(l,2)rep(m,3){
            if(c[l+1][m] != a[l+1] + b_cand[m]){
                //printf("%d = %d + %d \n",c[l+1][m],a[l+1],b_cand[m]);
                cnt++;
            }
        }
        if(cnt==0){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int gcd(int a, int b){return (b==0?a:gcd(b,a%b));}

int main(){
  int N;
  cin >> N;
  priority_queue<int> que;
  rep(i,N){
    int a;
    cin >> a;
    que.push(a);
  }

  while(que.size() > 1){
    int a = que.top(); que.pop();
    int b = que.top(); que.pop();
    if(a == b){
      que.push(a);
    }
    else {
      que.push(gcd(a,b));
    }
  }

  cout << que.top() << endl;
  
  return 0;
}



Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s,t=1,cnt=0;
  int64_t k;
  cin >> n >> k;
  int a[n],b[(1<<25)];
  for(int i=1;i<=n;i++)cin >> a[i];
  while(k--){
    t=a[t];
    if(b[t])k%=cnt-b[t];
    b[t]=cnt++;
  }
  cout << t << endl;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    int a[n],b[n],c[n];
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n+1][400][400];
    rep(i,n+1) rep(j,400) rep(k,400) dp[i][j][k] = 400000;
    dp[0][0][0] = 0;
    rep(i,n){
        rep(j,400) rep(k,400) {
            // 選ばない場合
            dp[i+1][j][k] = MIN(dp[i+1][j][k],dp[i][j][k]);
            // 選ぶ場合
            if(j-a[i]>=0 && k-b[i]>=0){
                dp[i+1][j][k] = MIN(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
            }
        }
    }
    int out = 40000;
    rep(j,400) rep(k,400) {
        if(j==0&&j==0) continue;
        if(ma*k == mb*j) out = MIN(dp[n][j][k],out);
    }
    if(out==40000) cout << -1 << endl;
    else cout << out << endl;

    return 0;
}

Measured memory_bytes: 25856
fun main(arg: Array<String>) {
    val (N, Ma, Mb) = listOfInt()
    val ABC = Array(N) { listOfInt() }
    val INF = 1000009
    val ABMAX = 10
    val NABMAX = N * ABMAX
    val dp = Array(N + 1) { Array(NABMAX + 1) { IntArray(NABMAX + 1) { INF } } }
    dp[0][0][0] = 0
    for (n in 0 until N)
    for (a in 0 .. NABMAX)
    for (b in 0 .. NABMAX) {
        if (dp[n][a][b] == INF) continue
        dp[n + 1][a][b] = Math.min(dp[n + 1][a][b], dp[n][a][b])
        dp[n + 1][a + ABC[n][0]][b + ABC[n][1]] = 
            Math.min(dp[n + 1][a + ABC[n][0]][b + ABC[n][1]], dp[n][a][b] + ABC[n][2])
    }
    var ans = INF
    for (a in 1 .. NABMAX)
    for (b in 1 .. NABMAX) {
        if (Ma * b == Mb * a) ans = Math.min(ans, dp[N][a][b])
    }
    if (ans == INF) ans = -1
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

// ------------------------------------------------------------------------------------------

string a, b, c;
map<int, char> mp;

signed main() {
  int n;
  cin >> n;
  cin >> a >> b >> c;
  int ans = 0;
  rep (i, a.size()) {
    set<char> s;
    s.insert(a[i]);
    s.insert(b[i]);
    s.insert(c[i]);
    if (s.size() == 2)  ans++;
    if (s.size() == 3)  ans+=2;
  }

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

Measured memory_bytes: 256
from sys import stdin
from collections import Counter
N = int(stdin.readline().rstrip())
mod = 10**9+7
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
fact = Counter()
for i in range(1,N+1):
    fact += Counter(prime_factorize(i))
ans = 1
for j in fact.values():
    ans = ans * (j+1)
print(ans%mod)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, m, dp[100001], MOD = 1e9 + 7;

int main() {
	cin >> n >> m;
	vector<int> b(n + 1, 1);
	inc(i, m) {
		int a;
		cin >> a;
		b[a] = 0;
	}
	
	incII(i, 0, n) { dp[i] = b[i] * (i < 2 ? 1 : dp[i - 1] + dp[i - 2]) % MOD; }
	
	cout << dp[n] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
/**
 * THIS IS CFMASTER'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  cout << (n + 1) / 2 << '\n';
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 10*40+100;
const int inf = 1e9;


int n, ma, mb;
int dp[45][maxn][maxn];


void push(int& x, int y) {
    x=min(x,y);
}

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

    cin>>n>>ma>>mb;


    for (int i=0; i<=n; i++) {
	for (int x=0; x<maxn; x++) {
	    for (int y=0; y<maxn; y++) {
		dp[i][x][y]=inf;
	    }
	}
    }


    
    dp[0][0][0]=0;


    
    for (int i=0; i<n; i++) {
	int a,b,c; cin>>a>>b>>c;
	for (int x=0; x<=10*40; x++) {
	    for (int y=0; y<=10*40; y++) {
		if (dp[i][x][y]<inf) {
		    push(dp[i+1][x+a][y+b],dp[i][x][y]+c);
		}
		push(dp[i+1][x][y],dp[i][x][y]);
	    }
	}
    }


    int res=inf;

    for (int x=1; x<=10*40; x++) {
	for (int y=1; y<=10*40; y++) {
	    int g=__gcd(x,y);
	    int a=x/g;
	    int b=y/g;
	    if (ma==a && mb==b) res=min(res,dp[n][x][y]);
	}
    }


    if (res==inf) out(-1);
    out(res);

    return 0;
}


Measured memory_bytes: 41216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int a,b,c,d,e,f;
int r1,r2;
map<PII, bool> mp;
inline void dfs(int x,int y)
{
	if (x*100+y>f) return;
	if (mp[MP(x,y)]) return;
	mp[MP(x,y)]=1;
	if ((y+e-1)/e<=x)
	{
    	//cout <<x*100<<" "<<y<<" ##\n";
		if ((r1*100+r2)*y>(x*100+y)*r2 || (!r1 && !r2))
		{
			r1=x;
			r2=y;
		}
		dfs(x,y+c);
		dfs(x,y+d);
	}
	dfs(x+a,y);
	dfs(x+b,y);
}
int main()
{
	cin >>a>>b>>c>>d>>e>>f;
	dfs(0,0);
	cout <<r1*100+r2<<" "<<r2;
	return 0;
}

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

using namespace std;

using ll = long long;

ll gcd(ll a, ll b) {
  while (b) {
    ll c = b;
    b = a % b;
    a = c;
  }
  return a;
}

ll lcm(ll a, ll b) {
  if (!a || !b) return 0;
  return a * b / gcd(a, b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = b - a + 1;
  ans -= b / c - (a - 1) / c;
  ans -= b / d - (a - 1) / d;
  ans += b / lcm(c, d) - (a - 1) / lcm(c, d);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n;
    cin >> n;
    set<int> syu;
    map<int, int> cnt;
    rep(i,n){
        int a;
        cin >> a;
        syu.insert(a);
        cnt[a]++;
    }
    if (syu.size()==1){
        if (cnt[0]>0)
          {  cout << "Yes" << endl;
        return 0;}
    }
    else if (syu.size()==2){
        vii x;
        vii y;
        for (auto p:syu){
            x.push_back(p);
            y.push_back(cnt[p]);
        }
        if (y[0]*2==y[1]){
            if (x[0]==0)
             {   cout << "Yes" << endl;
            return 0;}
        }
        else if(y[1]*2==y[0]){
            if (x[1]==0)
              {  cout << "Yes" << endl;
            return 0;}
        }
    }
    else if (syu.size()==3)
    {
        vii x;
        vii y;
        for (auto p : syu)
        {
            x.push_back(p);
            y.push_back(cnt[p]);
        }
        if (y[0]==y[1] && y[1]==y[2] && 
        (x[0]^x[1])==x[2] &&
        (x[1]^x[2])==x[0] && 
        (x[2]^x[0]==x[1]))
            {cout << "Yes" << endl;
        return 0;}
    }
    cout << "No" << endl;
}

Measured memory_bytes: 7552
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.09 02:35:30
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;



template< typename T >
struct BinaryIndexedTree {
    std::vector< T > data;
    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }
    
    inline T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }
    
    inline T sum(int left, int right) {
        return sum(right) - sum(left - 1);
    }
    
    
    inline void add(int k, T x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }
    
    int lower_bound(ll k) {
        if (k <= 0) return 0;
        int res = 0;
        int N = 1; while (N < (int)data.size()) N *= 2;
        for (int i = N / 2; i > 0; i /= 2) {
            if (res + i < (int)data.size() && data[res + i] < k) {
                k -= data[res + i];
                res += i;
            }
        }
        return res;
    }
    void print() {
        std::cout << "[ ";
        for (int i = 0; i < data.size() - 1; i++) {
            std::cout << sum(i, i);
            if (i < data.size() - 2) cout << ", ";
        }
        std::cout << " ]" << endl;
    }
};
int main() {
    int n,q;cin >> n >> q;
    BinaryIndexedTree<ll> bit(n);
    for (int i = 0; i < n; i++) {
        int a;cin >> a;
        bit.add(i,a);
    }
    while(q--) {
        int t;cin >> t;
        if (t == 0) {
            int p,x;cin >> p >> x;
            bit.add(p,x);
        }
        else {
            int l,r;cin >> l >> r;
            cout << bit.sum(l,r-1) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8212
import numpy as np

x = list(map(int,input().split()))
if x[0] > x[1]:
    ans = np.repeat(x[1],x[0])
    for i in ans:
        print(i, end="")
    
elif x[0] < x[1]:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")
    
else:
    ans = np.repeat(x[0],x[1])
    for i in ans:
        print(i, end="")

Measured memory_bytes: 22320
#include <stdio.h>

int main(void) {
	int i, a[101], b[101], k, count=0;
	
	for(i=1;i<101;i++){
		a[i] = i ;
		b[i] = 0 ;
	}
	
	while(scanf("%d", &k) != EOF){
		for(i=1;i<101;i++){
			if(a[i] == k){
				b[i] += 1;
			}
		}
		count += 1; 
	}

	for(i=1;i<101;i++){
	b[i] -= count ;	
	}
	
	while(1){
		for(i=1;i<101;i++){
			if(b[i] == 0) goto finish;
		}
		for(i=1;i<101;i++){
			b[i] += 1;
		}
	}
	
	finish:
	for(i=1;i<101;i++){
		if(b[i] == 0){
		printf("%d\n", a[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <math.h>
 
int main() {
  int n,i;
  double s[1000];
  double a2,m;
   
  while(1) {
    m=0;
    a2 = 0;
    scanf("%d" , &n);
    if(n == 0) {
      break;
    }
 
    for(i=0;i<n;i++) {
      scanf("%lf", &s[i]);
    m=m+s[i];
    //printf("m[%d] = %lf\n",i ,m);
    }
    m=m/n;
 
    for(i=0; i<n; i++) {
      a2 =a2+(s[i]-m)*(s[i]-m);
    }
    a2 = a2/n;
 
    printf("%.11lf\n",sqrt(a2));
 
  }
 
  return 0;
 
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
bool f[100009];
bool a[100009];
int sum[100009];

int main(){
  int q;
  for(int i=2;i<=10000;i++){
    if(f[i]==0){
      for(int j=2;i*j<=100000;j++){
        f[i*j]=1;
      }
    }
  }
  f[1]=1;
  cin>>q;
  for(int i=1;i<=100000;i+=2){
    if(f[i]==0&&f[(i+1)/2]==0)a[i]=1;
  }
  for(int i=1;i<=100000;i++){
    sum[i]=sum[i-1]+a[i];
    //cout<<sum[i]<<endl;
  }
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<sum[r]-sum[l-1]<<endl;
  }
  return(0);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

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

    map<char, ll> rec;
    rep(h, 0, H){
        string a;
        cin >> a;
        rep(w, 0, W){
            rec[a[w]]++;
        }
    }

    if(H % 2 == 0 && W % 2 == 0){
        for(auto r : rec){
            if(r.second % 4 != 0){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else if(H % 2 == 1 && W % 2 == 1){
        ll num = 0;
        for(auto r : rec){
            if(r.second % 2 == 1){
                rec[r.first]--;
                num++;
            }
        }
        if(num != 1){
            cout << "No" << endl;
            return 0;
        }
        num = 0;
        for(auto r : rec){
            if(r.second % 4 == 2){
                rec[r.first] -= 2;
                num += 2;
            }        
        }
        if(num > (H-1) + (W-1) || ((H-1) + (W-1) - num) % 4 != 0){
            cout << "No" << endl;
            return 0;
        }
        cout << "Yes" << endl;
    }else{
        ll num = 0;
        for(auto r : rec){
            if(r.second % 2 == 1){
                rec[r.first]--;
                num++;
            }
        }
        if(num != 0){
            cout << "No" << endl;
            return 0;
        }
        num = 0;
        for(auto r : rec){
            if(r.second % 4 == 2){
                rec[r.first] -= 2;
                num += 2;
            }        
        }
        if(H % 2 == 0){
            if(num > H || (H - num) % 4 != 0){
                cout << "No" << endl;
                return 0;
            }
            cout << "Yes" << endl;
        }else{
            if(num > W || (W - num) % 4 != 0){
                cout << "No" << endl;
                return 0;
            }
            cout << "Yes" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x,y,i;
	char s[15];
	scanf("%d %s %d",&x,s,&y);
	for(i=0;i<x;i++){
		if(s[i]!=s[y-1])s[i]='*';
	}
	puts(s);
	
	
} 

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

class UF {

  vector<int> par; // 親
  vector<int> rank; // 深さ

public:

  void init(int n) { // n個で初期化
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  UF(int n) {
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  int find(int x) { // 木の中のxの深さを返す
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y) { // xとyを統合する
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) { // xとyが等しいかどうか判定する
    return find(x) == find(y);
  }
};


signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  vector<vector<int>> g(n+1);
  int a, b;
  REP(i, m) {
    cin >> a >> b;
    g[a].pb(b);
    g[b].pb(a);
  }

  UF uf(n);

  REP(i, g[1].size()) {
    uf.unite(1, g[1][i]);
  }
  REP(i, g[n].size()) {
    uf.unite(n, g[n][i]);
  }

  if(uf.same(1, n)) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 16020