akhauriyash/Code-Regression huggingface dataset:
import Data.Foldable (traverse_)
import Data.Functor ((<$>))

main = do
  xs <- takeWhile (\[x, y] -> [x, y] /= [0, 0]) . map (map read . words) . lines <$> getContents
  traverse_ printBox xs
  where
  printBox [h, w] = putStrLn $ unlines $
    replicate w '#' :
    replicate (h-2) ('#' : replicate (w-2) '.' ++ ['#']) ++
    [replicate w '#']



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


int main(){
    int n;
    cin >> n;
    bool check = false;
    for(int i=0;i<3;i++){
        if(n%10 == 7)check = true;
        n/=10;
    }
    cout << ((check)? "Yes": "No") << endl;
    return 0;
}

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

int main() {
    int N, W, w, v, w0, w1, w2, w3;
    int v0[105], v1[105], v2[105], v3[105];
    for (int i = 0; i < 105; i++) {
        v0[i] = v1[i] = v2[i] = v3[i] = 0;
    }
    w0 = w1 = w2 = w3 = 0;
    int w_1 = 0;
    scanf("%d %d", &N, &W);
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &w, &v);
        if (i == 0) w_1 = w;
        if (w - w_1 == 0) {
            v0[i] = v;
            w0++;
        }
        else if (w - w_1 == 1) {
            v1[i] = v;
            w1++;
        }
        else if (w - w_1 == 2) {
            v2[i] = v;
            w2++;
        }
        else if (w - w_1 == 3) {
            v3[i] = v;
            w3++;
        }
    }
    sort(v0, v0 + N, greater<int>());
    sort(v1, v1 + N, greater<int>());
    sort(v2, v2 + N, greater<int>());
    sort(v3, v3 + N, greater<int>());

    int ans, x;
    ans = 0;
    for (int i = 0; i <= min(N, w0); i++) {
        for (int j = 0; j <= min(N - i, w1); j++) {
            for (int k = 0; k <= min(N - i - j, w2); k++) {
                for (int l = 0; l <= min(N - i- j -k, w3); l++) {
                    if ((long long)w_1 * (i + j + k + l) + j + 2*k + 3*l <= (long long)W) {
                        x = 0;
                        for (int a = 0; a < i; a++) x+= v0[a];
                        for (int a = 0; a < j; a++) x+= v1[a]; 
                        for (int a = 0; a < k; a++) x+= v2[a]; 
                        for (int a = 0; a < l; a++) x+= v3[a];
                        ans = max(ans, x);
                    }
                }
            }
        }
    }
    printf("%d\n", ans);
  
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    println(problem50a(a, b))
}

fun problem50a(a: Long, b: Long): String {

    val sa = Math.abs(a - b)

    if (sa % 2L != 0L) {
        // 中間地点は存在しない
        return "IMPOSSIBLE"
    }

    val min = Math.min(a,b)

    return  (min + (sa / 2L)).toString()
}

Measured memory_bytes: 31264
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    string s,v;
    cin>>s;v=s;
    reverse(v.begin(),v.end());
    for(int i=0;i<v.size();++i)
        v[i]=='b'?v[i]='d':v[i]=='d'?v[i]='b':v[i]=='p'?v[i]='q':v[i]='p';
    cout<<(s==v?"Yes":"No");
    return 0;
}

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

int64_t fnc(int64_t n){
    if(n < 5){
        return 0;
    }
    return n/5 + fnc(n/5);
}

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

    if(n % 2 == 1){
        cout << 0;
    }
    else{
        cout << fnc(n/2);
    }
}

Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto A = sread();
    long N = A.length;
    auto cnt = new long[]('z' - 'a' + 1);
    foreach (c; A)
        cnt[c - 'a']++;
    writeln(N * (N - 1) / 2 - cnt.map!"a*(a-1)/2"().sum() + 1);
}


Measured memory_bytes: 2684
from itertools import product
N, a, b, c = map(int, input().split())
L = []
for i in range(N):
  L.append(int(input()))

abc = [0,a,b,c]
ch = [0,1,2,3]
cal = []

for i in product(ch,repeat=N):
  calc = 0
  su = [0,0,0,0]
  ct = [0,0,0,0]
  temp = list(i)
  for j in range(N):
    su[temp[j]] += L[j]
    ct[temp[j]] += 1
  if (ct[1]==0)|(ct[2]==0)|(ct[3]==0):
    continue
  for k in range(1,4):
    calc += abs(abc[k]-su[k])
    calc += max((ct[k]-1),0)*10
  cal.append(calc)
    
print(min(cal))


Measured memory_bytes: 5004
#include <cstdio>
#include <iostream>

const int N = 100000;

int x[N];

int main()
{
#ifdef LOCAL_JUDGE
    freopen("D.in", "r", stdin);
#endif
    int n, a, b;
    while (scanf("%d%d%d", &n, &a, &b) == 3) {
        for (int i = 0; i < n; ++ i) {
            scanf("%d", x + i);
        }
        long long dp = 0;
        for (int i = 1; i < n; ++ i) {
            dp += std::min((long long)a * (x[i] - x[i - 1]), (long long)b);
        }
        std::cout << dp << std::endl;
    }
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main(){
  char a[100001];
  int b,c,d;

  scanf("%d",&b);

  while(b--){
    int i;
    c = 0;d = 0;
    scanf("%s",a);

    for(i = 0;i < strlen(a)-1;i++){
      if(a[i] == a[i+1]) c = 1; 
      if(a[i] == 'U'){   
        if(i % 2 == 0 && a[i+1] == 'L' ) c = 1;
        if(i % 2 == 1 && a[i+1] == 'R' ) c = 1;
      }
      if(a[i] == 'D'){   
        if(i % 2 == 0 && a[i+1] == 'L' ) c = 1;
        if(i % 2 == 1 && a[i+1] == 'R' ) c = 1;
      }
      if(a[i] == 'R'){   
        if(i % 2 == 0) c = 1;
      }          
      if(a[i] == 'L'){   
        if(i % 2 == 1) c = 1;
      }
    }
    
      for(i = 0;i < strlen(a)-1;i++){
      if(a[i] == a[i+1]) d = 1; 
      if(a[i] == 'U'){   
        if(i % 2 == 1 && a[i+1] == 'L' ) d = 1;
        if(i % 2 == 0 && a[i+1] == 'R' ) d = 1;
      }
      if(a[i] == 'D'){   
        if(i % 2 == 1 && a[i+1] == 'L' ) d = 1;
        if(i % 2 == 0 && a[i+1] == 'R' ) d = 1;
      }
      if(a[i] == 'R'){   
        if(i % 2 == 1) d = 1;
      }          
      if(a[i] == 'L'){   
        if(i % 2 == 0) d = 1;
      }
    }

    if(c == 0 || d == 0) printf("Yes\n");
    else printf("No\n");
  }

  return 0;
}

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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " ";
    cout << max(a + b - n, 0);

    return 0;
}

Measured memory_bytes: 256
H,W = gets.split.map(&:to_i)
SY,SX = gets.split.map { _1.to_i - 1 }
GY,GX = gets.split.map { _1.to_i - 1 }
S = readlines.map { _1.chomp.chars }

B = "#"

MV = [[1,0],[-1,0],[0,1],[0,-1]]
WP = [*-2..2].product([*-2..2]) - [*MV, [0,0]]

dist = Array.new(H) { [-1]*W }
que = [SY,SX]
dist[SY][SX] = 0
mem = Array.new(H) { []*W }
until que.empty?
  break if dist[GY][GX] != -1

  que2 = []
  until que.empty?
    y,x = que.pop(2)
    d = dist[y][x]

    blk = false
    MV.each do |dy,dx|
      yy,xx = y+dy,x+dx
      next if yy < 0 || xx < 0 || H <= yy || W <= xx
      next blk=true if S[yy][xx] == B
      next if 0 <= dist[yy][xx] && dist[yy][xx] <= d
      dist[yy][xx] = d
      mem[yy][xx] = true
      que.push(yy,xx)
    end
    que2.push(y,x) if blk
  end
  
  que2.each_slice(2) do |y,x|
    WP.each do |dy,dx|
      yy,xx = y+dy,x+dx
      next if yy < 0 || xx < 0 || H <= yy || W <= xx
      next if mem[yy][xx]
      next if S[yy][xx] == B
      next if 0 <= dist[yy][xx] && dist[yy][xx] <= d + 1
      dist[yy][xx] = d + 1
      que.push(yy,xx)
    end
  end

end

puts dist[GY][GX]


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

using namespace std;

#define llong long long 
#define ii pair<int, int>
#define xx first
#define yy second
#define len(v) ((int)v.size())
#define rep(i,n) for (int i = -1; ++i < n; )
#define rep1(i,n) for (int i = 0; i++ < n; )

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string s; cin >> s;
  cout << s.substr(0, len(s) - 8);
  
  
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 1e5 + 100;
int arr[N][3];
int dp[N][3];

int main()
{
    int i = 0, j = 0, cs = 0, in;
    int n; cin>>n;
    for(i = 0; i < n; i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    dp[0][0] = arr[0][0], dp[0][1] = arr[0][1], dp[0][2] = arr[0][2];
    for(i = 1; i < n; i++){
        dp[i][0] = arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = arr[i][2] + max(dp[i-1][1], dp[i-1][0]);
    }
    cout << max3(dp[n-1][0], dp[n-1][1], dp[n-1][2]) << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
signed main(){
    string N; cin>>N;
    bool ans = false;
    for(int i=0; i<3; i++){
        if(N[i]=='7'){
        ans = true;
        }
    }
    if(ans) cout <<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int H,W,K;
   cin >> H >> W >> K;
   int x1,y1,x2,y2;
   cin >> x1 >> y1 >> x2 >> y2;
   string M[H];
   x1--;y1--;x2--;y2--;
   for(int i=0;i<H;i++) cin >> M[i];
   int dist[H][W];
   for (int i = 0; i <H; i++) {
     for (int j = 0; j < W; j++) {
        dist[i][j]=INT_MAX/2;
     } 
   }
   queue<pair<int, pair<int,int>>> pq;
   dist[x1][y1]=0;
   pq.push(make_pair(0, make_pair(x1,y1)));
   while(!pq.empty()){
      pair<int,pair<int,int>> top = pq.front();
      pq.pop();
      int di = -top.first;
      int curX= top.second.first;
      int curY= top.second.second;
      if(curX == x2 && curY == y2){
         cout << di << endl;
         return 0;
      }
      if(dist[curX][curY]<di) continue;
      int dx[]={1,0,-1,0};
      int dy[]={0,1,0,-1};
      for(int i = 0; i < 4 ;i++){
         for(int d = 1; d <= K; d++){
            int nx = curX + dx[i]*d;
            int ny = curY + dy[i]*d;
            if(nx < 0 || ny < 0 || nx >= H || ny >= W) break;
            if(M[nx][ny]=='@') break;
            if(dist[nx][ny]==di){break;}
            if(dist[nx][ny]>di+1){
               dist[nx][ny]=di+1;
               pq.push(make_pair(-di-1, make_pair(nx,ny)));
            }
         }
      }
   }
   cout << -1 << endl;
   return 0;
}


Measured memory_bytes: 9908
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n;
char s[1000],t[1000];
int main()
{
////////////////////////b
    n=read();scanf("%s",s+1);scanf("%s",t+1);
    for(reg int i=1;i<=n;++i)cout<<s[i]<<t[i];
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    std::string S;std::cin >> S;
    int ans=0,tempAns=0;
    for (auto itr=S.begin();itr != S.end();++itr) {
        if (*itr == 'R' ) {
            ++tempAns;
            ans = std::max(ans,tempAns);
        } else {
            tempAns=0;
        }
    }

    std::cout << ans;

    return 0 ;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){

  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  if(a < b && b < c){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
    
  return 0;
}


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

#ifdef LOCAL
	#define D(a) cerr << #a << " = " << a << endl
#else
	#define D(a)
	#define cerr false && cerr
#endif
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define dforn(i,n) dforsn(i,0,n)
#define forn(i,n) forsn(i,0,n)
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first
#define endl '\n'
using pii = pair<int,int>;
using vi = vector<int>;
using ll = long long;

const int MAXN = 2000+10,
        INF = MAXN;

vi adj[MAXN];

int dfs(int u,int k, int p = -1){
    int res =(k==0);
    int nxtk = max(k-1,0);
    for(int v: adj[u]){
        if(v!=p)res+= dfs(v,nxtk,u);
    }
    return res;
}

int main() {
	fastio;
	
    int n,k;

    cin >> n >> k;

    forn(_,n-1){
        int u,v;
        cin >> u >> v;
        u--;v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    int res = INF;
    forn(u,n){
        int nodecut = dfs(u,k/2+1);
        res = min(res,nodecut);
        //D(u);D(nodecut);
        for(int v:adj[u]){
            if(v>u){
                int bounds = (k-1)/2+1;
                nodecut = min(
                        dfs(u,bounds,v)+dfs(v,bounds,u),
                        dfs(u,bounds,v)+dfs(v,bounds,u)); 
                //cerr << "u-v = " << u << " " << v << endl;
                //D(nodecut);
                res = min(res,nodecut);
            }
        }
    }

    cout << res << endl;
	
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926535;

class UnionFind {
	std::vector<int> p;

public:
	UnionFind(int n) : p(n, -1) {}

	int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); }

	bool same(int x, int y) { return root(x) == root(y); }

	bool unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (p[y] < p[x]) std::swap(x, y);
		if (p[x] == p[y]) --p[x];
		p[y] = x;
		return true;
	}
};
ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

int main() {
	ll N, M;
	cin >> N >> M;

	vector<ll> Tenbou(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> Tenbou[i];
	}

	vector<vector<ll>> map(N);
	for (ll i = 0; i < M; i++)
	{
		ll a, b;
		cin >> a >> b;
		map[a - 1].push_back(b - 1);
		map[b - 1].push_back(a - 1);
	}

	ll ans = 0;
	for (ll i = 0; i < N; i++)
	{
		ll is_top = true;
		vector<ll> dist = map[i];

		for (auto&& e : dist)
		{
			if (Tenbou[e] >= Tenbou[i]) {
				is_top = false;
			}
		}
		if (is_top) {
			ans++;
		}
	}
	cout << ans << endl;
	//UnionFind* tree = new UnionFind(N);
	//for (ll i = 0; i < M; i++)
	//{
	//	ll a, b;
	//	cin >> a >> b;
	//	tree->unite(a - 1, b - 1);
	//}

	//vector<vector<ll>> sames(N);

	//for (ll i = 0; i < N; i++)
	//{
	//	ll root = tree->root(i);
	//	sames[root].push_back(i);
	//}

	//ll ans = 0;
	//for (auto&& e : sames)
	//{
	//	if (e.size() == 0) {
	//		continue;
	//	}
	//	if (e.size() == 1) {
	//		ans++;
	//	}
	//	else {
	//		sort(e.begin(), e.end(), greater<ll>());
	//		cout << e[0] << "," << e[1] << "," << e[2] << endl;
	//		if (e[0] != e[1]) {
	//			ans++;
	//		}
	//	}
	//}
	//cout << ans << endl;
}

Measured memory_bytes: 9844
n = int(input())
a = list(map(int,input().split()))

dp = [[0]*2 for _ in range(n+1)]
dp[1] = [0,a[0]]
dp[2] = [0,max(a[0],a[1])]
for i in range(3,n+1):
    if i%2 == 0:
        dp[i][0] = max(dp[i-1][0],dp[i-2][0]+a[i-1])
        dp[i][1] = max(dp[i-1][1],dp[i-2][1]+a[i-1])
    else:
        dp[i][0] = max(dp[i-1][1],dp[i-2][0]+a[i-1])
        dp[i][1] = dp[i-2][1]+a[i-1]
        
if n%2 == 0:
    print(dp[n][1])
else:
    print(dp[n][0])

Measured memory_bytes: 54120
N = int(input())
str_fq_dic = {}
for i in range(N):
    s = input()
    if s in str_fq_dic:
        str_fq_dic[s] = str_fq_dic[s] + 1
    else:
        str_fq_dic[s] = 1

# max value search
max_value = sorted(str_fq_dic.values(), reverse=True)[0]
# max key search
ans_list = []
for s in str_fq_dic:
    if str_fq_dic[s]==max_value:
        ans_list.append(s)

# print output
# alphabet sort
ans_list = sorted(ans_list)
for a in ans_list:
    print(a)


Measured memory_bytes: 95320
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<map>
#include<queue>
#include<vector>
#include<set>
#include<iostream>
#include<string>
#define ll long long
#define N 305
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
#define Forn(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int read(){int x=0,f=0;char ch=getchar();for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;return f?-x:x;}
void write(int x){if(x<10) putchar(x+48);else write(x/10),putchar(x%10+48);}
void writeln(int x){if(x<0) putchar('-'),x=-x;write(x);putchar('\n');}
int n,m,a[N][N],b[N],sum,l[N];
bool flag[N];
int main(){
	n=read();m=read();
	For(i,1,n) For(j,1,m) a[i][j]=read();
	For(i,1,n) b[a[i][1]]++;
	For(i,1,n) l[i]=1;
	For(i,1,m) flag[i]=1;
	For(i,1,m) sum=max(sum,b[i]);
	For(i,1,m-1){
		int mxj=0;For(j,1,m) if(b[j]>b[mxj]) mxj=j;
		flag[mxj]=0;
		For(j,1,n) if(a[j][l[j]]==mxj){
			b[a[j][l[j]]]--;
			while(!flag[a[j][l[j]]]) l[j]++;
			b[a[j][l[j]]]++;
		}
		int mx=0;
		For(j,1,m) mx=max(mx,b[j]);
		sum=min(sum,mx);
	}
	writeln(sum);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

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

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

vector<ll> adj[200010];
ll dis[200010];
bool vis[200010];

int main()
{

    ll n, m;
    cin >> n >> m;
    mset(dis,0);
    mset(vis,0);
    for(ll i = 0; i < m; i++)
    {

        ll x, y;
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dis[1]=0;
    vis[1]=1;
    queue<ll> q;
    q.push(1);
    while(!q.empty())
    {

        ll x = q.front();
        q.pop();
        for(ll i = 0; i < adj[x].size(); i++)
        {

            ll v = adj[x][i];
            if(!vis[v])
            {

                vis[v]=1;
                dis[v]=dis[x]+1;
                q.push(v);
            }
        }
    }
    if(dis[n]==2) cout << "POSSIBLE";
    else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 15336
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define INF 1<<20

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int cost[105][105];
int d[105];
bool used[105];

int dijkstra (int n )
{
	memset (used, false, sizeof (used ) );
	fill (d, d+n, INF );
	d[0] = 0;

	while (true ){
		int v = -1;
		// まだ使われていない頂点のうち距離が最小のものを探す
		rep (u, n )
			if (!used[u] && (v == -1 || d[u] < d[v] ) ) v = u;
		
		if (v == -1 ) break;
		
		used[v] = true;
		rep (u, n )
			d[u] = min (d[u], d[v] + cost[v][u] );
	} // end whle
}

int main()
{
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	rep (i, n ) rep (j, n ) cost[i][j] = INF;

	rep (i, n ){
		int u; cin >> u;
		int k; cin >> k;
		while (k-- ){
			int v, c; cin >> v >> c;
			cost[u][v] = c;
		} // end while
	} // end loop

	dijkstra (n );
	rep (i, n ) cout << i << ' ' << d[i] << endl;
		
	return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;


int main(){
    int k;
    string s;
    cin >> k >> s;
    
    if(k>=(int)s.size())
      cout << s << endl;
  else{
    for(int i=0; i<k; i++){
      cout << s[i];
    }
    cout << "..." << endl;
  }
    
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, ans = inf; cin >> n;
	vi x(n);
	rep(i, n) cin >> x[i];
	
	for(int i = 1; i <= 100; i++){
		int s = 0;
		for(int j : x) s += (i - j) * (i - j);
		ans = min(ans, s);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector < vector < int > > dp(n, vector<int> (3));
    int a, b, c;
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(int i = 1;i < n;i++)
    {
        cin >> a >> b >> c;
        dp[i][0] = a + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c + max(dp[i - 1][1], dp[i - 1][0]);
    }
    int val = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main(void){
    int i,t,s,A,B;
    scanf("%d",&A);
    scanf("%d",&B);
    if(B==1){i=0;}
    else{
    
    
    s=A;
    for(t=1;s<B;t++){
        s=s+A-1;
    }
    i=t;
    }
    printf("%d",i);
    return 0;
}



Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*

 */
ll a,b;

ll f(ll x,ll y){
  ll ans = 0;
  for(ll i=x; i<=y; i++){
    ans = ans ^ i;
  }
  return ans;
}

ll fodd(ll x, ll y){
  if((y-x)%4==0) return x;
  else
    return x ^ f(x + 4 * ((y-x)/4) + 1, y);
}

int main(){
  cin>>a>>b;

  ll ans=0;
  if(a%2==1){
    ans = fodd(a,b);
  } else {
    if(a==b) ans = a;
    else
      ans = a ^ fodd(a+1,b);
  }

  cout<<ans<<endl;

  return 0;
}


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

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

  string find = "such";
  int count = 0;
  while( cin >> find && find != "END_OF_TEXT" ){
   for( int i=0; i<find.size(); i++ ){
    if( find[i]>='A' && find[i]<='Z' ){
     find[i] += ('a'-'A');
    }
   }
   if( word == find ){
     count++;
   }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==b&&a!=c)printf("Yes");
    else if(a==c&&a!=b)printf("Yes");
    else if(b==c&&b!=a)printf("Yes");
    else printf("No");
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define sz(c) int((c).size())
#define all(c) (c).begin(), (c).end()
#define pb push_back

#define INF int(1e9)
#define EPS 1e-9
#define MOD int(1e9 + 7)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
		cin >> arr[i];
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		int mini = arr[i], minIdx = i;
		for(int j = i + 1; j < n; j++) {
			if(arr[j] < mini) {
				mini = arr[j];
				minIdx = j;
			}
		}
		if(minIdx != i) {
			swap(arr[i], arr[minIdx]);
			cnt++;
		}
	}
	cout << (cnt <= 1 ? "YES" : "NO") << '\n';
	return 0;
}


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

int main()
{
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    if (s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc090.contest.atcoder.jp/tasks/arc090_b>
問題文============================================================
 x 軸上に N 人の人が立っています。 人 i の位置を xi とします。
 任意の i に対して、xi は 0 以上 109 以下の整数です。
 同じ位置に複数の人が立っていることもありえます。
 
 これらの人の位置に関する情報が M 個与えられます。
 このうち i 個めの情報は (Li,Ri,Di) という形をしています。
 この情報は、人 Ri は人 Li よりも距離 Di だけ右にいること、
 すなわち、xRi−xLi=Di が成り立つことを表します。
 
 これら M 個の情報のうちのいくつかに誤りがある可能性があることがわかりました。
 与えられる M 個すべての情報と矛盾しないような値の組 (x1,x2,…,xN) が存在するかどうか判定してください。
=================================================================

解説=============================================================

================================================================
*/
int N,M;
struct edge{
    int L,R,D;
    edge(){}
    edge(int L,int R,int D):L(L),R(R),D(D){}
};
vector<vector<edge>> G;

bool dfs(int n,bool first,vector<int>& checked,vector<ll>& loc){
    if(first) loc[n] = 0;
    checked[n] = 1;
    for(edge& e:G[n]){
        if(checked[e.R] == 0){
            loc[e.R] = loc[e.L] + e.D;
            if(!dfs(e.R,false,checked,loc))return false;
        }else{
            if(loc[e.R] != loc[e.L] + e.D) return false;
        }
    }
    return true;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    G.resize(N);
    for(int i = 0; i < M;i++){
        int L,R,D; cin >> L >> R >> D;
        L--; R--;
        G[L].push_back(edge(L,R,D));
        G[R].push_back(edge(R,L,-D));
    }
    
    vector<int> checked(N,0);
    vector<ll> loc(N,LINF);
    for(int i = 0; i < N;i++){
        if(checked[i]) continue;
        if(!dfs(i,true,checked,loc)){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 14592
#include <iostream>
#include <vector>
using namespace std;
int main(void)
{
	int n,a,k=0;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;i++) cin >> v[i];
	for(int i=0;i<n;i++){
		for(int j=n-1;i<j;j--){
			if(v[j]<v[j-1]){
				a=v[j];
				v[j]=v[j-1];
				v[j-1]=a;
				k+=1;
			}
		}
	}
	cout << v[0];
	for(int i=1;i<n;i++) cout << " " << v[i];
	cout << endl << k << endl; 
	return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

void solve(){
  int n; cin >> n;
  vector<vector<int> > v(n, vector<int>(n));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      cin >> v[i][j];
    }
  }
  vector<int> t, c(n);
  t.push_back(0);
  c[0] = 1;
  int ans = 0;
  while(t.size() != n){
    int mini, minj, mint = 100000;
    for(int i = 0; i < t.size(); i++){
      for(int j = 0; j < n; j++){
        if(v[t[i]][j] >= 0 && c[j] == 0){
          if(v[t[i]][j] < mint){
            mini = i;
            minj = j;
            mint = v[t[i]][j];
          }
        }
      }
    }
    ans += mint;
    t.push_back(minj);
    c[minj] = 1;
  }
  cout << ans << endl;
  return;
}

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



Measured memory_bytes: 3176
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    s = input()
    if len(s) %2:
        print(no)
        exit()

    for i in range(len(s)):
        if i%2 == 0 and s[i] == 'h':
            continue
        elif i%2 == 1 and s[i] == 'i':
            continue
        else:
            print(no)
            exit()
    
    print(yes)
            




main()



Measured memory_bytes: 5716
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;
int abs(int a){
	if(a<0){
		a*=-1;
	}
	return a;
}

int main(){
	int num=0;
	vector<int> weight;
	cin>>num;
	for(int i=0;i<num;i++){
		int tmp;
		cin>>tmp;
		weight.push_back(tmp);
	}
	int min=-1;
	for(int i=0;i<weight.size();i++){
		int left=0,right=0;
		for(int j=0;j<i;j++){
			left+=weight[j];
		}
		for(int j=i;j<weight.size();j++){
			right+=weight[j];
		}
		if(min>abs(left-right) || min==-1){
			min=abs(left-right);
		}
	}
	cout<<min;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  string s;
  cin>>s;
  int length=s.length();
  int start=-1;
  int end=-1;
  for(int i=0;i<length;i++){
    if(start==-1 && s[i]=='A'){
      start=i;
    }
    if(s[i]=='Z'){
      end=i;
    }
  }
  cout<<end-start+1<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
 
    using namespace std;
    using namespace __gnu_pbds;
 
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define int long long 
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
 
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
 
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
 
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> omultiset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> oset;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> oset1;
 
/*.....................................................................................................................*/
 
    const ll mod=(ll)1e9+ 7;
 
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
 
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;} 
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
 
    //A.erase(unique(A.begin(),A.end()),A.end());
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll  man  =   (int)200005   ,  inf   =   1e18;
 
 
/*......................................................................................................................*/

int n,m;
vector<int>adj1[man],adj2[man];
vector<int>d(man,0);
vector<bool> visited(man);
vector<int> ans;

void dfs(int v) 
{
    visited[v] = true;
    for (int u : adj1[v]) 
    {
        if (!visited[u])
            dfs(u);
    }
    ans.push_back(v);
}
void topological_sort() 
{
    // visited.assign(n, false);
    // ans.clear();
    for (int i = 1; i <= n; ++i) 
    {
        if (!visited[i])
            dfs(i);
    }
    reverse(ans.begin(), ans.end());
}

signed main()
{
    fast;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        adj1[a].push_back(b);
        adj2[b].push_back(a);
    }
    topological_sort();

    for(int i=0;i<ans.size();i++)
    {
        int v=ans[i];
       // what(v)
        for(auto u:adj2[v])
        {
            d[v]=max(d[v],d[u]+1);
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,d[i]);
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 23500
K = input()
T = list(map(int,input().split()))

def main():
    count = 0
    flg = 1
    while(flg):
        for i in range(len(T)):
            if T[i] % 2 == 0:
                T[i] = T[i]/2
            else:
                flg = 0
                break
        count +=1
    print(count-1)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    n = int(input().rstrip())
    a_list = [int(x) for x in input().rstrip().split(" ")]
    a_list.sort(reverse=True)

    alice = 0
    bob = 0
    for i in range(len(a_list)):
        if i % 2 == 0:
            alice += a_list[i]
        else:
            bob += a_list[i]
    print(alice-bob)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9184
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
int main()
{
	string s;
	string t;
	cin>>s>>t;
	s+=t[t.length()-1];
	if(s==t)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  string n;
  cin >> n;
  bool ok = false;
  REP(i, 3) {
    if (n[i] == '7') {
      ok = true;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;

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


Measured memory_bytes: 55272
#include <stdio.h>
#include <math.h>
int main(){
    int n,temp;
    double tot,t;
    while(1){
        scanf("%d",&n);
        if(n==0)return 0;
        tot=t=0;
        for(int i=0;i<n;i++){
            scanf("%d",&temp);
            tot+=temp*temp;
            t+=temp;
        }
        printf("%lf\n",sqrt((tot-t*t/n)/n));
    }
}

Measured memory_bytes: 2576
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[100000];
vector<int> dist(100000, -1);
void bfs(int st) {
	dist[st] = 0;
	queue<int> q;
	q.push(st);
	while (!q.empty()) {
		int n = q.front();
		for (auto v : g[n]) {
			if (dist[v.first] == -1) {
				dist[v.first] = dist[n] + v.second;
				q.push(v.first);
			}
		}
		q.pop();
	}
}
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		g[u].push_back(make_pair(v, w));
		g[v].push_back(make_pair(u, w));
	}
	bfs(0);
	for (int i = 0; i < n; i++) {
		if (dist[i] % 2 == 0) {
			cout << 0 << endl;
		} else {
			cout << 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9588
N,Q=map(int,input().split())
S=input()
L=[0]*len(S)
for i in range(len(S)-1):
  if S[i]=='A':
    if S[i+1]=='C':
      L[i+1]=1
for i in range(1,len(S)):
  L[i]=L[i-1]+L[i]
for i in range(Q):
  l,r=map(int,input().split())
  l-=1
  r-=1
  ans=L[r]-L[l]
  print(ans)

Measured memory_bytes: 7668
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
const ll Maxn=1e5;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}
bool cmp(double x,double y)
{
    return x>y;
}
int d[12][12];
int main()
{
    ios::sync_with_stdio(false);
 ll n,m;
  cin>>n>>m;
   if(m/2019-(n-1)/2019>=1)cout<<0<<endl;
   else {
   int z=2020;
   for(int i=n%2019;i<m%2019;i++)
    for(int j=i+1;j<=m%2019;j++)
   {z=min(z,i*(j)%2019);
  // if(i*(i+1)%2019==0)cout<<i<<endl;
   }
   cout<<z<<endl;
   }

}


Measured memory_bytes: 256
// 2014/05/27 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	int sum1 = 0, sum2 = 0;
	int cnt = 0;

	while(true){
		string s;
		cin >> s;

		if(cin.eof())
			break;

		string::size_type pos = 0;
		while(pos = s.find(",", pos), pos!=string::npos){
			s.replace(pos, 1, " ");
			pos++;
		}

//		cout << s << endl;

		istringstream is(s);

		int m, n;
		is >> m >> n;

//		cout << m << ' ' << n << endl;

		sum1 += (m*n);
		sum2 += n;
		cnt++;
	}

	cout << sum1 << endl;
	cout << (sum2*10/cnt+5)/10 << endl;

	return 0;
}

Measured memory_bytes: 1220
def exception_handling(n, ali, bli):

    bli.append(0)
    count = 0
    ans = 0

    for i in range(n):
        count = min(ali[i], bli[i])
        ans += count
        ali[i] -= count
        bli[i] -= count

        count = min(ali[i+1], bli[i])
        ans += count
        ali[i+1] -= count
        bli[i] -= count

    return ans

def main():
    n = int(input())
    ali = list(map(int, input().split()))
    bli = list(map(int, input().split()))
    print(exception_handling(n, ali, bli))

if __name__ == '__main__':
    main()

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


int main(){
  int n;
  cin>>n;
  char s[n];bool flag =true;
      cin>>s;
      if(n%2==0){
        for(int i=0;i<n/2;i++)
        if(s[i]!=s[n/2+i]){
          flag=false;
          break;}
          if(flag==false)
          cout<<"No";
          else cout<<"Yes";
      }
      else cout<<"No";
 

  

 return 0;
}

Measured memory_bytes: 256
//NEVER GIVE UP I AM GOING TO IMPROVE ONE DAY.
//PRACTICE,PRACTICE,PRACTICE!!!
#include<bits/stdc++.h>
#define int long long int
// #define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e18
#define endl "\n"
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
const int M=1000000000;
const double pi = acos(-1.0);
using namespace std;
// cout<<"Case #"<<test-t<<":"<<" "<<"N"<<endl;
int32_t main(){

    #ifndef ONLINE_JUDGE 
    freopen("in.txt", "r", stdin); 
    freopen("out.txt", "w", stdout); 
    #endif 

    fast;
    int t;
    t=1;
    // cin>>t;
    // int test=t;
    while(t--){
       int a,b,c,k;
       cin>>a>>b>>c>>k;
       int ans=0;
       while(b<=a){
           b*=2;
           ans++;
       }
       while(b>=c){
           c*=2;
           ans++;
       }
       if(ans<=k){
           cout<<"Yes"<<endl;
       }
       else{
           cout<<"No"<<endl;
       }
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
//
//
int V,E;
int d[100][100];
int a[1000],b[1000],c[1000];
//
int main(){
  FOR(i,0,100){
    FOR(j,0,100){
      d[i][j]=INF;
    }
  }
  cin>>V>>E;
  FOR(i,0,E){
    int C;
    cin>>a[i]>>b[i]>>c[i];
    a[i]--;b[i]--;
    d[a[i]][b[i]]=c[i];
    d[b[i]][a[i]]=c[i];
  }
  FOR(k,0,V){
    FOR(i,0,V){
      FOR(j,0,V){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  FOR(i,0,V){
    d[i][i]=0;
  }
  int ans=E;
  FOR(i,0,E){
    bool update=false;
    FOR(j,0,V){
      if(d[j][a[i]]+c[i]==d[j][b[i]]){
        update=true;
      }
    }
    if(update){
      ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){

    while(1){

        string s; cin >> s;
        int n = (int)s.size();
        if(s == "0") break;

        vector<vector<int> > dp(n + 1, vector<int> (11, 0));

        for(int i = 0; i < n; i++){

            int num = (int)(s[i] - '0');

            //つける
            for(int j = 0; j < 11; j++){
                dp[i + 1][(j * 10 + num) % 11] += dp[i][j];    
            }

            //新たに
            if(num != 0) dp[i + 1][num] += 1;
        }


        int ans = 0;
        for(int i = 1; i <= n; i++) ans += dp[i][0];

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

}


Measured memory_bytes: 9876
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 6, mod = (int) 0;
int res[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int a = 0; a < 2; ++a) {
        for (int b = 0; b < 2; ++b) {
            res[0] = a;
            res[1] = b;
            for (int j = 2; j < n; ++j) {
                res[j] = ((s[j - 1] != 'o') ^ res[j - 1]) ^ res[j - 2];
            }
            int flag = 1;
            for (int x = 0; x < n; ++x) {
                int pr = (x - 1 + n) % n, nx = (x + 1 + n) % n;
                if (((s[x] == 'o') ^ res[x]) != (res[pr] == res[nx]))
                    flag = 0;
            }
            if (flag) {
                for (int j = 0; j < n; ++j)
                    cout << (res[j] == 0? 'S': 'W');
                cout << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

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

int main(){
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1||f!=-1||r!=-1){
    if(m==-1||f==-1) cout << "F" << endl;
    else if(m+f>=80) cout << "A" << endl;
    else if(m+f>=65) cout << "B" << endl;
    else if(m+f>=50) cout << "C" << endl;
    else if(m+f>=30)
      if(r>=50) cout << "C" << endl;
      else cout << "D" << endl;
    else cout << "F" << endl;
 
    cin >> m >> f >> r;
  }
}


Measured memory_bytes: 3108
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int N;
string S;
ll dp[100005][13];

int main() {
	cin >> S;
	N = S.size();

	dp[0][0] = 1;
	for (int i = 0; i < N; i++) {
		int c;
		if (S[i] == '?') c = -1;
		else c = S[i] - '0';

		for (int j = 0; j < 10; j++) {
			if (c != -1 && c != j) continue;
			for (int k = 0; k < 13; k++) {
				dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
			}
		}
		for (int j = 0; j < 13; j++) dp[i + 1][j] %= MOD;
	}

	ll res = dp[N][5];
	cout << res;
    return 0;
}


Measured memory_bytes: 10624
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){
    ll N;
    cin >> N;
    vector<char> v;
    ll div=26,flag=1;
    while(flag){
        --N;
        ll tmp = N%div;
        N = N/div;
        if(N==0) flag=0;
        v.push_back(tmp+97);
    }

    for(int i=0,sz=v.size(); i<sz; ++i){
        printf("%c",v[sz-1-i]);
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3624