akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    a = LI()
    ans = float("inf")
    for b in range(1<<n):
        if bin(b).count("1") < k:
            continue
        m = 0
        s = 0
        for i in range(n):
            if not b&(1<<i):
                if m < a[i]:
                    m = a[i]
            else:
                if a[i] <= m:
                    m += 1
                    s += m-a[i]
                else:
                    m = a[i]
        if s < ans:
            ans = s
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 41708
def parse(j, y, p, J, Y):
    if j == J and y == Y:
        print(p)
        return
    elif j == 5 and y <= 3 or y == 5 and j <= 3:
        return

    if  j > J or y > Y:
        return

    parse(j+1, y, p + "A", J, Y)
    parse(j, y+1, p + "B", J, Y)

J,Y = map(int, input().split())
parse(0, 0, "", J, Y)



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

using namespace std;

const int MAX_N = 500;

struct Item {
    int ind, value;

    Item() {
        this->ind = 0;
        this->value = 0;
    }

    Item(int ind, int value) {
        this->ind = ind;
        this->value = value;
    }

    friend bool operator < (const Item& a, const Item& b) {
        return a.value < b.value;
    }
};

int n, x[MAX_N + 1], a[MAX_N * MAX_N + 1];
int p;

Item xSort[MAX_N + 1];

bool isAns = true;

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> x[i];
    }

    for (int i = 1; i <= n; i++) {
        xSort[i] = Item(i, x[i]);
    }

    sort(xSort + 1, xSort + n + 1, less<Item>());

    for (int i = 1; i <= n * n; i++) {
        a[i] = 0;
    }

    for (int i = 1; i <= n; i++) {
        a[x[i]] = i;
    }

    p = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < xSort[i].ind; j++) {
            while (p < xSort[i].value && a[p] != 0) {
                p++;
            }

            if (p == xSort[i].value) {
                isAns = false;

                break;
            }

            a[p] = xSort[i].ind;
        }

        if (!isAns) {
            break;
        }
    }

    p = n * n;
    for (int i = n; i >= 1; i--) {
        for (int j = n; j > xSort[i].ind; j--) {
            while (p > xSort[i].value && a[p] != 0) {
                p--;
            }

            if (p == xSort[i].value) {
                isAns = false;

                break;
            }

            a[p] = xSort[i].ind;
        }

        if (!isAns) {
            break;
        }
    }

    if (isAns) {
        cout << "Yes" << '\n';

        for (int i = 1; i <= n * n; i++) {
            cout << a[i];

            if (i < n * n) {
                cout << ' ';
            } else {
                cout << '\n';
            }
        }
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A != B && A != C && B != C){
    cout << "No" << endl;
  }else if(A == B && A == C){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl; 
  }
}

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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


int main(void){

    int n;
    cin >> n;

    ll ans = 0;
    for(int a = 1; a < n; ++a){
        ans += (n - 1) / a;
    }

    cout << ans << "\n";


    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
typedef long long ll;
using namespace std;

int main(void){
  string s;
  int n,i,ans=0;
  cin>>s;
  n=s.size();

  for(i=0;i<n/2;i++){
    if(s[i]!=s[n-1-i]){
      ans++;
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <iostream>

using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b >> s;
  int index = 0;
  bool ok = true;
  for (int i = 0; i < a; i++) {
    if (!isdigit(s[index++])) {
      ok = false;
    }
  }
  if (s[index++] != '-') {
    ok = false;
  }
  for (int i = 0; i < b; i++) {
    if (!isdigit(s[index++])) {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3028
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string s;
	cin >> s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import copy
n = int(input())
c = input().split()
c = [[c[i][0], int(c[i][1])] for i in range(n)]
ba = copy.deepcopy(c)
sa = copy.deepcopy(c)

def bubble_sort(a, n):
    flag = 1
    i = 0
    while flag:
        flag = 0
        for j in reversed(range(i+1, n)):
            if a[j][1] < a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]
                flag = 1
        i += 1
    return a

def selection_sort(a, n):
    for i in range(n-1):
        minj = i
        for j in range(i, n):
            if a[j][1] < a[minj][1]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
    return a

ba = bubble_sort(ba, n)
sa = selection_sort(sa, n)

def is_stable(x, y):
    for i in range(n):
        if x[i][0] != y[i][0]:
            return False
    return True

fba = [i[0] + str(i[1]) for i in ba]
print(' '.join(fba))
print('Stable')
fsa = [i[0] + str(i[1]) for i in sa]
print(' '.join(fsa))
print('Stable' if is_stable(ba, sa) else 'Not stable')


Measured memory_bytes: 6348
a,l,$,=:+,:<,' '
puts [6484,a,0,1,3,l,2,3,3]+[0,1].map{|x|[a,x,3,x]+(0..29).map{|t|v=x+4;u=x*60+9+t;[a,v,v,v,a,v,3,6,*[a,6,6,6]*(29-t),l,6,x,u,a,v,u,v]}}+(0..59).map{|t|[a,2,2,2]+(0...t).map{|s|[a,8+t-s,69+s,5,l,3,5,6,a,2,6,2]}}

Measured memory_bytes: 14768
#include <iostream>

using namespace std;

int n;
bool is_all_even(int arr[]);

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

    int count = 0;

    while (is_all_even(arr)) {
        count++;
        for (int i = 0; i < n; i++) {
            arr[i] /= 2;
        }
    }

    cout << count << endl;
    return 0;
}

bool is_all_even(int arr[]) {
    bool result = true;
    for (int i = 0; i < n; i++) {
        if (arr[i] % 2 != 0) {
            result = false;
        }
    }
    return result;
}


Measured memory_bytes: 256
fn main() {
    let s: String = read();
    if s == "Sunny" {
        println!("Cloudy");
    } else if s == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}





//**********************************************************************************************************************************************//

// 標準入力から一行を読み取り、指定の型に変換する関数
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

// 標準入力からn行を読み取り、各行を空白文字で分割し、各要素を指定の型に変換する関数
pub fn read_vec2<T: std::str::FromStr>(n: u64) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

// 10進数での各桁の和
pub fn sum_dights(x: isize) -> isize {
    if x % 10 == 0 {
        return 0
    }
    let m = x % 10;
    m + sum_dights((x - m) / 10)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a, b, C, S, L, h;
  cin >> a >> b >> C;
  C = C / 180.0 * 3.1415926535;
  S = a * b * sin(C) * 0.5;
  h = b * sin(C);
  L = sqrt(a * a + b * b - 2 * a * b * cos(C)) + a + b;
  
  printf("%.8lf %.8lf %.8lf\n", S, L, h);
}


Measured memory_bytes: 3472
#include<stdio.h>
#include<math.h>

int main(void){
	double x1,x2,y1,y2;
	double ans;
	
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	ans = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	printf("%lf\n",ans);
	return 0;
}

Measured memory_bytes: 652
#include<bits/stdc++.h>
#define LL long long
#define EXP 1000000007
using namespace std;
LL dp[2001][2001]={0};
int main(void){
	int n,k;
	int i,j;
	LL ans;
	cin>>n>>k;
	for(i=0;i<=n;i++){
		dp[i][0]=1;
	}
	for(i=0;i<n;i++){
		for(j=0;j<=i;j++){
			dp[i+1][j+1]=(dp[i][j]+dp[i][j+1])%EXP;
		}
	}
	for(i=1;i<=k;i++){
		ans=(dp[n-k+1][i]*dp[k-1][i-1])%EXP;
		cout<<ans<<endl;
	}
	return 0;
}
	

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

using namespace std;

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

Measured memory_bytes: 256
// ARC095
// C - Many Medians

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 200000;

int N;
int x[MAX_N], y[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        y[i] = x[i];
    }
    sort(y, y + N);

    for (int i = 0; i < N; i++) {
        int idx = (lower_bound(y, y + N, x[i]) - y < N / 2) ? N / 2 : N / 2 - 1;
        cout << y[idx] << endl;
    }

    return 0;
}


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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  if (a+W<b && a<b) {
    cout << b-(a+W) << endl;
  } else if (a+W>=b && a<=b) {
    cout << 0 << endl;
  } else if (b+W<a && b<a) {
    cout << a-(b+W) << endl;
  } else if (b+W>=a && b<=a) {
    cout << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def gumoji(s):
    l=len(s)
    if s[:l//2]==s[l//2:]:
        return True
    return False
s=input()
n=len(s)

for i in range(n-2):
    check=s[:n-i-1]
    if gumoji(check):
        print(len(check))
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
int L,R;
ll sum[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	
	
	FOR(i,N) {
		cin>>L>>R;
		
		if(R<=1000) {
			for(j=1;j<=R;j++) {
				if(R/j!=(L-1)/j) sum[j]++, sum[j+1]--;
			}
		}
		else {
			for(j=1;j<=400;j++) {
				if(R/j!=(L-1)/j) sum[j]++, sum[j+1]--;
			}
			int preL=101010;
			for(x=1;x<=400;x++) {
				if(x*401>R) break;
				int TL=(L+(x-1))/x;
				int TR=R/x;
				TL=max(TL,401);
				TR=min(TR,preL-1);
				
				if(TL>TR) continue;
				sum[TL]++;
				sum[TR+1]--;
				preL=TL;
			}
			
		}
	}
	
	ll tot=0;
	for(i=1;i<=M;i++) {
		tot += sum[i];
		cout<<tot<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back

#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto item : (x))
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    char c; cin>>c; c++;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,ans=0; cin>>n; 
    vi  a(n+1);
    for (int i=1;i<=n;i++)
        cin >> a[i];
    for (int i=1;i<=n;i++) // 2 3 1 4
        if (a[a[i]]==i) {
            ans++; a[i]=-1; 
        }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll n, k;
	cin >> n >> k;
	vi a(n);
	f(i, 0, n - 1) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll sum = 0;
	f (i, 0, k - 1) {
		sum += a[i];
	}
	cout << sum << endl;
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
*/





























Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int cntr[4005];
int cntg[4005];
int cntb[4005];
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int T;
    cin >> T;
    string S;
    cin >> S;
    LL res = 0;
    int r = 0, g = 0, b = 0;
    memset(cntr, 0, sizeof(cntr));
    memset(cntg, 0, sizeof(cntr));
    memset(cntb, 0, sizeof(cntr));
    for (int i = T - 1; i >= 0; i--) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
        cntr[i] = r;
        cntg[i] = g;
        cntb[i] = b;
    }

    for (int i = 0; i <= T; i++) {
        for (int j = i + 1; j <= T; j++) {
            if (S[i] == S[j]) continue;
            if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
                res += cntb[j + 1];
                if (2 * j - i < T && S[2 * j - i] == 'B') res--; 
            } else if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')) {
                res += cntg[j + 1];
                if (2 * j - i < T && S[2 * j - i] == 'G') res--; 
            } else if ((S[i] == 'B' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'B')) {
                res += cntr[j + 1];
                if (2 * j - i < T && S[2 * j - i] == 'R') res--; 
            }
        }
    }

    cout << res << '\n';

    return 0;
}


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

using namespace std;

int main() {
    
    int n;
    cin >> n;
    
    while (n--) {
        double x1, y1, x2, y2, x3, y3;
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

        auto ab = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        auto bc = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
        auto ca = sqrt((x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3));
        auto r = (ab * bc * ca) / sqrt((ab + bc + ca) * (-ab + bc + ca) * (ab - bc + ca) * (ab + bc - ca));

        auto a = 2 * (x2 - x1);
        auto b = 2 * (y2 - y1);
        auto c = (x2 - x1) * (x2 + x1) + (y2 - y1) * (y2 + y1);
        auto d = 2 * (x3 - x2);
        auto e = 2 * (y3 - y2);
        auto f = (x3 - x2) * (x3 + x2) + (y3 - y2) * (y3 + y2);
        
        auto px = (e * c - b * f) / (e * a - b * d);
        auto py = (d * c - a * f) / (d * b - a * e);

        printf("%.3f %.3f %.3f\n", floor(px * 1000 + 0.5) / 1000, floor(py * 1000 + 0.5) / 1000, floor(r * 1000 + 0.5) / 1000);
    }
    
    return 0;
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        s : chars,
    }
    let mut res = 0;
    for i in 0..s.len() {
        for j in i..s.len(){
            let is_acgt = s[i..j+1].iter().fold(true,|x, &v| x & (v=='A' || v=='C' || v=='G' || v=='T'));

            if is_acgt{
                res = std::cmp::max(res, j-i+1);
            }
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
while True:
    n,r = map(int, raw_input().split())
    if n==0 and r==0:
        break
    else:
        list = []
        for i in range(1,n+1):
            list.append(i)
        # print list
        for i in range(0,r):
            p, c = map(int, raw_input().split())
            hoge = list[len(list)-p+1:len(list)]
            del list[len(list)-p+1:len(list)]
            # print hoge
            # print list
            # list.insert(len(list)-c, hoge)
            list[len(list)-c:len(list)-c] = hoge
            # print list
        print list[len(list)-1]

Measured memory_bytes: 6288
package main

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

func main() {
	s := ReadString()
	ans := 0
	for l, r := 0, len(s)-1; l < r; {
		if s[l] == s[r] {
			l++
			r--
			continue
		}
		if s[l] == 'x' {
			l++
			ans++
			continue
		}
		if s[r] == 'x' {
			r--
			ans++
			continue
		}
		fmt.Println(-1)
		return
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 2496
#include<stdio.h>

int main(void){

    long int A,B,K;

    scanf("%ld %ld %ld",&A,&B,&K);

    if(K <= A){
        A -= K;
    }else{
        B -= K-A;
        A = 0;
    }

    if(B < 0) B = 0;
    printf("%ld %ld\n",A,B);
    return 0;
}

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


int main(){
    int x, y;
    cin >> x >> y;

    string top(y + 2, '#');

    cout << top <<endl;

    while (x--) {
        string str;
        cin >> str;
        cout << "#" << str << "#" << endl;
    }

    cout << top <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=100005;
struct edge{int x,y,next;}a[2*MAXN];int len,last[MAXN];
void ins(int x,int y){len++;a[len].x=x;a[len].y=y;a[len].next=last[x];last[x]=len;}
int n,tag[MAXN],du[MAXN];
void dfs(int x,int fa)
{
	tag[x]=1;int down=0;
	for(int k=last[x];k;k=a[k].next)
	{
		int y=a[k].y;
		if(y!=fa)dfs(y,x),down+=tag[y];
	}
	if(down>1||x==1&&down==0){puts("First");exit(0);}
	if(down==1)tag[x]=0;
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		ins(x,y);ins(y,x);
		++du[x];++du[y];
	}dfs(1,0);puts("Second");
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,d=0;
  cin >> N;
  string S; 
  cin >> S;
  for(int i=1; i<N; i++){
    if(S[i]=='E'){
      d++;
    }
  }
  int m=d;
  
  for(int i=1; i<N; i++){
    if(S[i-1]=='W'){
      d++;
    }
    if(S[i]=='E'){
      d--;
    }
    m=min(m,d);
  }
  cout << m ;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

ll dp[1001000][2][2];

int main() {

	int n;
	cin >> n;
	dp[0][0][0] = 1;

	rep(i, n) {

		dp[i + 1][0][0] += 8 * dp[i][0][0];dp[i + 1][0][0] %= MOD;

		dp[i + 1][1][0] += dp[i][0][0];     dp[i + 1][1][0] %= MOD;
		dp[i + 1][1][0] += dp[i][1][0] * 9; dp[i + 1][1][0] %= MOD;

		dp[i + 1][0][1] += dp[i][0][0];     dp[i + 1][0][1] %= MOD;
		dp[i + 1][0][1] += dp[i][0][1] * 9; dp[i + 1][0][1] %= MOD;

		dp[i + 1][1][1] += dp[i][0][1];      dp[i + 1][1][1] %= MOD;
		dp[i + 1][1][1] += dp[i][1][0];      dp[i + 1][1][1] %= MOD;
		dp[i + 1][1][1] += dp[i][1][1] * 10; dp[i + 1][1][1] %= MOD;

	}

	cout << dp[n][1][1] << endl;

}

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

int main(void){

    string S;
    cin >> S;

    bool flag;
    char preC = S.at(0);
    if(preC == '<'){
        flag = true;
    }
    else{
        flag = false;
    }

    int preN = 0;

    long int ans = 0;
    long int n = 1;
    for(int i=1; i<S.size(); i++){
        if(S.at(i) == preC){
            n++;
        }
        else{
            if(flag){
                ans += n*(n-1) / 2;
                flag = false;
            }
            else{
                if(n > preN){
                    ans += n*(n+1) / 2;
                }
                else{
                    ans += preN + 1 + n*(n-1) / 2;
                }
                flag = true;
            }
            preC = S.at(i);
            preN = n-1;
            n = 1;
        }
    }

    if(flag){
        ans += n*(n+1) / 2;
    }
    else{
        if(n > preN){
            ans += n*(n+1) / 2;
        }
        else{
            ans += preN + 1 + n*(n-1) / 2;
        }
    }

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

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

int main() {
  int N;
  cin >> N;
  
  int sum = 0;
  int M = N;
  while(M){
    sum += M % 10;
    M /= 10;
  }
  
  if(N % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << (x) << endl
using namespace std;

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

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

Int solve(Int a, Int b){
    return max(a - b * 2, 0);
}

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    Int a, b;
    cin >> a >> b;
    cout << solve(a, b) << "\n";

    return 0;
}


Measured memory_bytes: 256
N=int(input())
abc=[list(map(int,input().split())) for i in range(N)]
x,y,z = 0,0,0
for a,b,c in abc:
    x,y,z = max(y,z)+a,max(x,z)+b,max(x,y)+c
print(max(x,y,z))

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

vector<int> prefix_function(vector<int> s) {
    int n = (int)s.size();
    vector<int> pi(n);
    for (int i = 1; i < n; i++) {
        int j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}

int main(){

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

	int n;
	cin>>n;

	vector<int> a(n) , b(n) , c;
	for(int i=0 ; i<n ; ++i)
		cin>>a[i];
	for(int i=0 ; i<n ; ++i)
		cin>>b[i];

	for(int i=0 ; i<n ; ++i)
		c.push_back( b[i]^b[(i+1)%n] );

	c.push_back(-1);
	for(int i=0 ; i<n ; ++i)
		c.push_back( a[i]^a[(i+1)%n] );
	
	for(int i=0 ; i<n-1 ; ++i)
		c.push_back( a[i]^a[(i+1)%n] );

	vector<int> k = prefix_function(c);
	for(int i=0 ; i<k.size() ; ++i){
		if( k[i] == n ){
			int x = i - 2*n;
			cout<<x<<" "<<(b[0]^a[x])<<'\n';
		}
	}
}



Measured memory_bytes: 10732
//In the name of Allah

#include <bits/stdc++.h>

using namespace std;

const int N = 100005;

int a[N];
long long ps[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (!i) {
      ps[0] = a[0];
    }
    else {
      ps[i] = ps[i - 1] + a[i];
    }
  }
  long long d1 = 0, d2 = 0, ans1 = 0, ans2 = 0;
  for (int i = 0; i < n; i++) {
    if (i % 2) {
      if (ps[i] + d1 >= 0) {
        ans1 += ps[i] + d1 + 1;
        d1 -= ps[i] + d1 + 1;
      }
      if (ps[i] + d2 <= 0) {
        ans2 += - ps[i] - d2 + 1;
        d2 += - ps[i] - d2 + 1;
      }
    }
    else {
      if (ps[i] + d1 <= 0) {
        ans1 += - ps[i] - d1 + 1;
        d1 += - ps[i] - d1 + 1;
      }
      if (ps[i] + d2 >= 0) {
        ans2 += ps[i] + d2 + 1;
        d2 -= ps[i] + d2 + 1;
      }
    }
  }
  printf("%lld\n", min(ans1, ans2));
  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

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

int n, m, a, b, k;
string s;

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

int main() {
    cin >> n;

    Vi a(n);
    REP(i, n) cin >> a[i];

    int g = a[0];
    REP2(i, 1, n) {
        g = gcd(g, a[i]);
    }
    std::cout << g << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int n, A, B, C, ans;
vector<int> length;
void calc(vector<int> v)
{
    int a, b, c, mp; a = b = c = mp = 0;
    for(int i = 0; i < v.size(); i++)
    {
        if(v[i] == 0) 
        {
            if(a != 0) mp += 10;
            a += length[i];
        }
        if(v[i] == 1)
        {
            if(b != 0) mp += 10;
            b += length[i];
        }
        if(v[i] == 2)
        {
            if(c != 0) mp += 10;
            c += length[i];
        }
    }
    if(a == 0 || b == 0 || c == 0) return;
    mp += abs(A - a) + abs(B - b) + abs(C - c);
    ans = min(ans, mp);
}
void dfs(int depth, vector<int> res)
{
    if(depth == n)
    {
        calc(res);
        return;
    }
    for(int i = 0; i < 4; i++)
    {
        res[depth] = i;
        dfs(depth + 1, res);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> A >> B >> C;
    ans = INF;
    length.resize(n);
    for(int i = 0; i < n; i++) cin >> length[i];
    vector<int> v(n, 0);
    dfs(0, v);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

using namespace std;

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

  if( A>B )
    swap(A,B);

  if( B>C )
    swap(B,C);

  cout << C*10+B+A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,W,w,v;
    array<long long,100001> dp;
    dp.fill(1e9+1);
    dp[0] = 0;
    cin >> N >> W;
    for (int i=0;i<N;i++){
        cin >> w >> v;
        for (int j=100000;j >= v; j--){
            if (dp[j-v] != 1e9+1){
                dp[j] = min(dp[j-v]+w,dp[j]);
            }
        }
    }
    v = -1;
    for(long long i=0;i<100001;i++){
        if (dp[i] <= W)
            v = max(v,i);
    }
    cout << v << endl;
}


Measured memory_bytes: 1024
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double

    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int hh,mm,hhh,mmm,cnt;
    void solve()
    {
        cin>>hh>>mm>>hhh>>mmm>>k;   
        if(hh<hhh)
        {
            cnt=(hhh-(hh+1))*60;
            cnt+=(60-mm);
            cnt+=mmm;
            cout<<max(0ll,cnt-k)<<endl;
        }
        else if(hh>hhh)
        {
            cnt=((24-(hh+1))+hhh)*60;
            cnt+=(60-mm);
            cnt+=mmm;
            cout<<max(0ll,cnt-k)<<endl;
        }
        else
        {
            cnt=mmm-mm;
            if(cnt>=k)
            cout<<max(0ll,cnt-k)<<endl;
            else
                cout<<max(0ll,1440+cnt-k);
        }

    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3640
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static void main (String[] args)  {
        Scanner in = new Scanner(System.in);
        char input = in.next().charAt(0);
        int integerInput = input;
        integerInput++;
        char output= (char) integerInput;
        System.out.print(output);

    }
}

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

int main() {
	int n, m, a[1000],c=0,all=0;
	cin >> n>> m;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		all+=a[i];
	}
	for (int i = 0; i < n; i++){
		if(a[i]>=all/(4.0*m))c++;
	}
	if (c >= m)cout << "Yes";
	else cout << "No";
} 

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def calc_rating(n):
    if 400 <= n <= 599:
        return 8
    elif 600 <= n <= 799:
        return 7
    elif 800 <= n <= 999:
        return 6
    elif 1000 <= n <= 1199:
        return 5
    elif 1200 <= n <= 1399:
        return 4
    elif 1400 <= n <= 1599:
        return 3
    elif 1600 <= n <= 1799:
        return 2
    elif 1800 <= n <= 1999:
        return 1

def main():
    x = II()
    print(calc_rating(x))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9212
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n;
    cin >> n;
    int x = n * 800;
    int y = n / 15 * 200;
    cout << x - y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int n;
	string s;
	cin>>n;
	cin>>s;
	int m[200001];
	int x=0,y=0;
	for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            x++;
        }
        else
        {
            y++;
        }
        m[i]=y;
    }
    if(x>=1)
    cout<<m[x-1]<<endl;
    else
    cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 4464
#include<iostream>
#include<set>
using namespace std;
#define int long long
set<long long> f(long long a){
  set<long long> ret;
  ret.insert(1);
  for (int i = 2; i * i <= a; i++) {
    while (a % i == 0) {
      ret.insert(i);
      a /= i;
    }
  }
  if (a) ret.insert(a);
  return ret;
}
signed main(){
  long long A, B;
  cin >> A >> B;
  auto a = f(A);
  auto b = f(B);
  int ans = 0;
  for (auto& x : a) {
    ans += (b.find(x) != b.end());
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n;
    int dp[31];
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    
    for(int i=3; i<=30; i++){
        dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    }
    while(cin>>n&&n){
        cout<<dp[n]/3650+(dp[n]%3650!=0)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h >> w;
    char g[h][w]; REP(i,h)REP(j,w) cin >> g[i][j];
    bool ok = 1;
    /*黒いマスは上下左右どれかも黒いマスじゃないとアウト*/REP(i,h)REP(j,w) if (g[i][j]=='#'&&g[i][j-1]!='#'&&g[i-1][j]!='#'&&g[i][j+1]!='#'&&g[i+1][j]!='#') ok = 0;
    Yn(ok);

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  char op;
  cin >> a >> op >> b;
  cout << (op == '+' ? a + b : a - b) << '\n';
  return 0;
}


Measured memory_bytes: 256
r, d, x2000 = map(int, input().split())

x = []

for i in range(10+1):
    x.append(0)

x[0] = x2000
# print(x[0])

for i in range(10):
    x[i+1] = r * x[i] - d
    print(x[i+1])


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() { 
   string s; cin >> s;
   ll dp0 = 0, dp1 = 1;
   for(char c: s){
       if(c == '0'){
           dp0 = dp0 * 3 % MOD;
       }else{
           dp0 = (dp0 * 3) % MOD + dp1  % MOD;
           dp1 = dp1 * 2 % MOD;
       }
   }
   cout << (dp0 + dp1) % MOD << ln;
}




Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <string>
#include <deque>
#include <stack>
#include <cmath>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (LL i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<LL> VI;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF*INF;
const int MAX = 400040	;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = 1000LL * 1000 * 1000 + 7;

int n,w;
int arr[2][MAX/4];
LL dpT[103][MAX/4];
LL dp(int pos,int type)
{
	if(pos<0)
		return 0;
	if(dpT[pos][type]!=-1)
		return dpT[pos][type];

	dpT[pos][type] = dp(pos-1,type);
	if(type>=arr[0][pos])
		dpT[pos][type]=max(dpT[pos][type],dp(pos-1,type-arr[0][pos])+(LL)arr[1][pos]);
	return dpT[pos][type];
}



int main()
{
	//freopen("input.tXXt", "r", stdin);
	ios_base::sync_with_stdio(0);
	FILL(dpT,-1);
	cin >> n >> w;
	FOR(i,0,n)
		FOR(j,0,2)
			cin >> arr[j][i];
	cout<<dp(n,w);




	return 0;
}


Measured memory_bytes: 80768
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define INF 1000000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

//https://kyopro-friends.hatenablog.com/entry/2019/01/12/231000
int dp[3100][3100];

int main(){
    string s,t;
    cin>>s>>t;
    int slen=(int)s.size(),tlen=(int)t.size();
    for(int i=0;i<slen;i++){
        for(int j=0;j<tlen;j++){
            if(i==0 || j==0){
                if(s[i]==t[j]) dp[i][j]=1;
                else dp[i][j]=max(dp[max(i-1,0)][j],dp[i][max(j-1,0)]);
            }else{
                if(s[i]==t[j]) dp[i][j]=dp[i-1][j-1]+1;
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int len=dp[slen-1][tlen-1];
    //cout<<len<<endl;
    int i=slen-1,j=tlen-1;
    vector<char> V;
    while(len>0){
        if(s[i]==t[j]){
            V.push_back(s[i]);
           
            i--;
            j--;
            len--;
        }else if(i>0 && dp[i][j]==dp[i-1][j]){
            i--;
        }else j--;
    }
    for(int i=(int)V.size()-1;i>=0;i--){
        cout<<V[i];
    }
    cout<<endl;
}



Measured memory_bytes: 37120
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353
import numpy

A, B = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

c = math.gcd(A, B)
d = factorization(c)

if c > 1:
    print(len(d)+1)
else:
    print(1)

Measured memory_bytes: 27304
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, T = map(int, input().split())

i = 0

num = 0
minCost = 1001

for i in range(N):
    c, t = map(int, input().split())
    
    if t <= T:
        if c < minCost :
           num = i + 1
           minCost = c;

if num > 0:
    print(minCost)
else:
    print('TLE')

Measured memory_bytes: 3060