akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int n, a[100005], b[100005], c[100005];
int dp[100005][3];

int main() {
	scanf("%d", &n);
	for(int i = 1;i <= n; i++) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		for(int j = 0;j < 3; j++) dp[i][j] = 0;
	}
	
	dp[1][0] = a[1]; dp[1][1] = b[1]; dp[1][2] = c[1];
	for(int i = 2;i <= n; i++) {
		for(int j = 0;j < 3; j++) {
			if(j == 0) dp[i][j] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
			if(j == 1) dp[i][j] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
			if(j == 2) dp[i][j] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
		}
	}
	
	printf("%d\n", max(max(dp[n][0], dp[n][1]), dp[n][2]));
}

Measured memory_bytes: 6144
use utf8;
use strict;
use warnings;
use feature qw/say/;

chomp(my $n = <>);
chomp(my $raw = <>);
my @a = split(/ /, $raw);

my %exists;
my $ret = 'YES';
for (@a) {
    if (exists $exists{$_}) {
        $ret = 'NO';
        last;
    } else {
        $exists{$_} = 1;
    }
}
say $ret;

Measured memory_bytes: 50668
#include <iostream>
#include <cmath>
#include <utility>
#define EPS 1e-10
using namespace std;

int main(void){

    pair<double, double> p0, p1, p2, p3;
    int n;
    cin >> n;

    while(n--){

        cin >> p0.first >> p0.second;
        cin >> p1.first >> p1.second;
        cin >> p2.first >> p2.second;
        cin >> p3.first >> p3.second;

        double innerProduct = (p1.first - p0.first)*(p3.first - p2.first)
            + (p1.second - p0.second)*(p3.second - p2.second);
        double crossProduct = (p1.first - p0.first)*(p3.second - p2.second)
            - (p1.second - p0.second)*(p3.first - p2.first);

        if(crossProduct == 0){
            cout << "2" << endl;
        }else if(innerProduct == 0 ){
            cout << "1" << endl;
        }else{
            cout << "0" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<algorithm>
using namespace std;
struct f{
	long long int x;
	long long int y;
	
}ff[100005];
bool cmp(f a,f b)
{
	return a.x<b.x;
}
int main()
{
	long long int a,b;
	long long int s=0;
	cin>>a>>b;
	for(int i =0;i<a;i++)
		cin>>ff[i].x>>ff[i].y;
	sort(ff,ff+a,cmp);
	for(int i =0;i<a;i++)
	{
		s+=ff[i].y;
		if(s>=b)
		{
			cout<<ff[i].x<<endl;
			break;
		}
	}
	return 0;
 } 

Measured memory_bytes: 1792
from collections import defaultdict

def main():
    num = int(input())
    data = [int(input()) for i in range(num)]

    dic = defaultdict(int)
    mod = 10 ** 9 + 7
    dp = [1 for i in range(num + 1)]

    for i in range(num):
        if i != 0:
            if data[i] == data[i - 1]:
                dp[i + 1] = dp[i]
                continue

        now_num = data[i]
        dp[i + 1] = (dp[i] + dic[now_num]) % mod
        dic[now_num] += dp[i]
        dic[now_num] %= mod

    print(dp[num])

if __name__ == '__main__':
    main()


Measured memory_bytes: 85796
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

W,H,x,y=MAP()

ans1=W*H/2
if x==W/2 and y==H/2:
    ans2=1
else:
    ans2=0

print(ans1, ans2)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    LL t=1;//cin>>t;
    while(t--){
      LL n,i;cin>>n;
      LL a[n],b[n],c[n];
      fo(i,0,n){
        LL x,y;cin>>x>>y;
        a[i]=x+y;
        b[i]=x-y;
        c[i]=y-x;
      }
      sort(a,a+n);
      sort(b,b+n);
      sort(c,c+n);
      cout<<max(a[n-1]-a[0],max(b[n-1]-b[0],c[n-1]-c[0]));
    }
    return 0;
}

Measured memory_bytes: 8300
#include<bits/stdc++.h>
using namespace std;
int n,dp[100005][3],a[100005][3];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
	for(int i=1;i<=n;i++)
	{
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+a[i][2];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
	return 0;
} 

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

int main(){
    string s;
    cin >> s;
    vector<int> v;
    int i = 0;
    while(i < s.length()){
        if(s[i] == 'e'){
            v.push_back(0);
            i += 3;
        }else if(s[i] == 'c'){
            v.push_back(1);
            i += 7;
        }
    }
    int dep = 0, tmp = 0, ans = -1, bef = -1;
    for(int i = 0; i < v.size(); i++){
        if(bef == v[i]){
            tmp = 1;
        }else{
            tmp++;
        }
        if(tmp > dep){
            dep = tmp;
            ans = v[i];
        }
        bef = v[i];
    }
    cout << (ans==0 ? "egg" : "chicken") << endl;
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    sort(ALL(s));
    sort(RALL(t));
    if( s < t) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

if (N%2==1):
    print("No")
else:
    flag = True
    for i in range(N//2):
        if S[i] != S[i+N//2]:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

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

using namespace std;

set<long long> pf(long long n) {
    set<long long> pf = {1};
    for (int i = 2 ;i * 1ll * i <= n ;i++) {
        while (n % i == 0) {
            pf.insert(i);
            n /= i;
        }
    }
    pf.insert(n);
    return pf;
}

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

    long long a , b;
    cin >> a >> b;

    set<long long> aa = pf(a) ;
    set<long long> bb = pf(b);

    int res = 0;
    for (long long f : aa)
        if (bb.count(f))
            res++;

    cout << res;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 55, maxm = 550;
int n, id[maxn], t[maxn], c[maxn], top[maxn], ans[maxn][maxm];

bool cmp(const int &a, const int &b)
{
    return t[a] > t[b];
}

int main()
{
    while (scanf("%d", &n), n)
    {
        for (int i = 0; i < n; i++)
        {
            scanf("%d%d", &t[i], &c[i]);
            c[i] <<= 1;
            id[i] = i;
        }
        sort(id, id + n, cmp);
        int last = 0;
        for (int k = 0; k < n; k++)
        {
            int i = id[k];
            memset(top, 0, sizeof top);
            ans[i][0] = 0;
            for (int j = 1; j <= c[i]; j++)
            {
                ans[i][j] = ans[i][j - 1] + t[i];
                for (int h = 0; h < k; h++)
                {
                    int pre = id[h];
                    if (ans[pre][top[pre] + 1] < ans[i][j - 1]) 
                        top[pre]++;
                    //if (top[pre] % 2 != j % 2)
                    //    top[pre]++;
                    if (top[pre] % 2 == (j + 1) % 2 && top[pre] + 1 <= c[pre] && ans[pre][top[pre]] < ans[i][j - 1] && ans[pre][top[pre] + 1] > ans[i][j])
                        ans[i][j] = ans[pre][top[pre] + 1];
                }
		//printf("%d %d %d\n", i, j, ans[i][j]);
            }
            last = max(last, ans[i][c[i]]);
        }
        printf("%d\n", last);
    }
    
    return 0;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
struct Edge {
    int to, cost;
    Edge(int to, int cost): to(to), cost(cost) {}
};

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<Edge>> AdjList;
AdjList graph;

const int INF = 100000000;


// 1-indexed

bool cmp(const pii& a, const pii&b){
    if(a.first == b.first){
        return a.second < b.second;
    }

    return a.first < b.first;
}
int a, b, c, d, e,f;

string s;
int main() {
    //cout << fixed << setprecision(15);

    cin >> s;
    int m=0, e=0, w=0;

    int f = true;
    for(int i=0; i<s.size(); ++i){
        if(s[i]=='m') m++;
        else if(s[i]=='e') e++;
        else if(s[i]=='w') w++;

        if(m==w){
            if(i!=s.size()-1) f = false;
            break;
        }
        if(m < e) f = false;
        if(e < w) f = false;
    }

    if(m==w && w == e){}
    else f = false;
    if(f) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
    return 0;
}


Measured memory_bytes: 3208
<?php
$s = trim(fgets(STDIN));
$n = strlen($s);
$p = $s[0];
$ans = 0;
$i = 1;
while($i < $n){
if($s[$i] != $p){
++$ans;
$p = $s[$i];
}
++$i;
}

echo $ans;

Measured memory_bytes: 3980
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)

signed main(){
    int n, x;
    cin >> n >> x;
    vi a(n);
    rep(i, n){
        cin >> a[i];
        a[i] -= x;
    }

    int g = abs(a[0]);
    rep(i, n) g = __gcd(g, abs(a[i]));
    
    cout << g << endl;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

ll dp[110][5][5][5];
// 1:A, 2:C, 3:G, 4:T
int main() {
    int n; cin >> n;
    dp[0][0][0][0] = 1;
    rep(i, n) rep(a, 5) rep(b, 5) rep(c, 5) {
        if (dp[i][a][b][c]==0) continue;
        for (int d = 1; d < 5; d++) {
            if (b == 1 && c == 3 && d == 2) continue;
            if (a == 1 && b == 3 && d == 2) continue;
            if (a == 1 && c == 3 && d == 2) continue;
            if (b == 3 && c == 1 && d == 2) continue;
            if (b == 1 && c == 2 && d == 3) continue;
            dp[i+1][b][c][d] = (dp[i+1][b][c][d] + dp[i][a][b][c]) % MOD;
        }
    }

    ll ans = 0;
    FOR(a,1,5) FOR(b,1,5) FOR(c,1,5) {
        ans = (ans + dp[n][a][b][c]) % MOD;
    }
    cout << ans << endl;


    return 0;
}


    


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class b{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        int[] num = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int ans = 0;
        for(int i=0; i<n; i++){
            if(i%2 == 0){
                if(num[i]%2 == 1){
                    ans++;
                }
            }
        }
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 19104
#include<stdio.h>
#include<string.h>
int main()
{			
	char s[101];
	int indc=-1,indf=-1,i;
	scanf("%s",s);
	for(i=0;i<strlen(s);i++){
		if(s[i]=='C'&&indc==-1)indc=i;
		if(s[i]=='F')indf=i;
	}
	if(indf!=-1&&indc!=-1&&indc<indf)printf("Yes");
	else printf("No");
	return 0;
}   

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int n;
vector<int> x{111,222,333,444,555,666,777,888,999,1111};
void input(){
    cin>>n;
}
void src(){
    cout<<*upper_bound(x.begin(),x.end(),n-1);
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

using namespace std;

int h,w;
char mat[1001][1001];
int dp[1001][1001];
const int mod = 1e9 + 7;


long long calc(int x,  int y){
    if (x < 0 || x > h - 1 || y < 0 || y > w - 1){
        return 0;
    }
    if (mat[x][y] == '#'){
        return 0;
    }

    if (x == h - 1 && y == w - 1){
        return 1;
    }

    if (dp[x][y] != -1){
        return dp[x][y];
    }


    dp[x][y] = ((calc(x + 1 , y)%mod) + (calc(x , y + 1)%mod)) % mod;

    return dp[x][y];

}





int main()
{
    cin >> h >> w;

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

    memset(dp , -1 , sizeof dp);

    cout << calc(0 , 0) << endl;


    return 0;
}


Measured memory_bytes: 8552
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
using namespace std;

int main(){
    string S;
    cin >> S;
    int res = 0;
    if(S == "SSS"){
        res = 0;
    }else if(S == "SSR"){
        res = 1;
    }else if(S == "SRR"){
        res = 2;
    }else if(S == "RRR"){
        res = 3;
    }else if(S == "RSS"){
        res = 1;
    }else if(S == "RRS"){
        res = 2;
    }else if(S == "RSR"){
        res = 1;
    }else if(S == "SRS"){
        res = 1;
    }
    
    cout << res << endl;
}

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

int main() {
  int n, ans;
  string s;
  cin >> n >> s;
  ans = 0;
  for(int i = 0; i < (n-2); i++) {
    if(s.at(i) == 'A') {
      if(s.at(i+1) == 'B') {
        if(s.at(i+2) == 'C') {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, a, b = gets.split.map(&:to_i)
all_sum = 0
for i in 1..n do
  m = i
  digit_sum = 0
  while m > 0 do
    digit_sum += m % 10
    m /= 10
  end
  all_sum += i if (a..b).include?(digit_sum)
end
puts all_sum


Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> x(n);
        for(int i=0; i<n; ++i)
            cin >> x[i];
        int y;
        cin >> y;

        int ret = 0;
        int a = 0;
        int b = n-1;
        while(a <= b){
            int c = (a + b) / 2;
            ++ ret;
            if(x[c] == y)
                break;
            if(x[c] < y)
                a = c + 1;
            else
                b = c - 1;
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}

using namespace std;


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

   map<string,int>m;
   
   rep(i,n){
      string s;
      cin>>s;

      sort(s.begin(),s.end());

      m[s]++;
   }
   ll ans=0;
   for(auto itr=begin(m);itr!=end(m);itr++){
      ll v=itr->second;
      ans+=(v*(v-1)/2);
   }

   cout<<ans;





return 0;
}



Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>



#define rep(i,p,q) for(int i = p;i < q;i++)
#define ll long long

ll CONS = 1e9 + 7;

using namespace std;

//66D

vector<vector<ll>> edge;
vector<vector<ll>> edgeCopy;
vector<ll> dist1,distN;

int main(void) {
	ll n;
	cin >> n;
	edge = vector<vector<ll>>(n);
	rep(i, 0, n-1) {
		ll a, b;
		cin >> a >> b;
		edge[a - 1].push_back(b - 1);
		edge[b - 1].push_back(a - 1);
	}
	queue<ll> q = queue<ll>();
	dist1 = vector<ll>(n, -1);
	dist1[0] = 0;
	rep(i, 0, edge[0].size()) {
		q.push(edge[0][i]);
		dist1[edge[0][i]] = 1;
	}
	while (q.size() > 0) {
		ll v = q.front();
		q.pop();
		rep(i, 0, edge[v].size()) {
			ll nv = edge[v][i];
			if (dist1[nv] == -1) {
				dist1[nv] = dist1[v] + 1;
				q.push(nv);
			}
		}
	}

	q = queue<ll>();
	distN = vector<ll>(n, -1);
	distN[n-1] = 0;
	rep(i, 0, edge[n-1].size()) {
		q.push(edge[n-1][i]);
		distN[edge[n-1][i]] = 1;
	}
	while (q.size() > 0) {
		ll v = q.front();
		q.pop();
		rep(i, 0, edge[v].size()) {
			ll nv = edge[v][i];
			if (distN[nv] == -1) {
				distN[nv] = distN[v] + 1;
				q.push(nv);
			}
		}
	}

	ll fCount = 0;
	ll sCount = 0;
	rep(i, 0, n) {
		if (dist1[i] <= distN[i])fCount++;
		else sCount++;
	}
	if (fCount > sCount) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
}


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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,ans; string str;

int solve(){
    cin>>n;
    vc<pii> v;
    rep(i,0,n-1){
        int a; cin>>a;
        v.pb({a,i+1});
    }
    sort(all(v));
    rep(i,0,n-1) cout<<v[i].sc<<" ";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 2544
N = gets.to_i

TA = Array.new(N) 
T = Array.new(N)
A = Array.new(N)
sum = Array.new(N)
r = Array.new(N)

peaple = 0
m_idx = 0

a, b = 1, 1
# p a
# p b

N.times do |i|
  
  x, y = gets.split.map(&:to_i)
  
  n = [ (a+x-1)/x, (b+y-1)/y ].max
  a, b = x * n, y * n

end

p a + b

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        if(s[i]=='7'){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    return 0;
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    unsigned long long a, b, c;
    cin >> a >> b >> c;
    if(c <= a + b) {
        cout << "No" << endl;
        return 0;
    }
    unsigned long long x = c - a - b;
    if(4*a*b < x*x) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  cout << (s == t ? "Yes" : "No") << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ff first
#define mp make_pair
#define dd second
#define pp pair<int,int>
#define N 100005
using namespace std;


main() {
    ios_base::sync_with_stdio(false);
    //freopen("test2", "r", stdin);
   int n; cin >> n;
    int sum = 0;
    int maxi = 1e9+7;
    bool same = true;
    for(int i = 0; i < n; ++i) {
        int a,b; cin >> a >> b;
        if(a != b) same = false;
        sum += a;
        if(a > b) {
            maxi = min(maxi, b);
        }
    }

    if(same) {
        cout << 0 << "\n"; exit(0);
    }

    if(maxi != 1e9+7) {
        cout << sum-maxi << "\n"; exit(0);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    s = input()
    n = len(s)

    if n == 2:
        if s[0] == s[1]:
            print(1, 2)
        else:
            print(-1, -1)

        return

    for i in range(n - 2):
        if s[i] == s[i + 1]:
            print(i + 1, i + 2)
            return
        elif s[i + 1] == s[i + 2]:
            print(i + 2, i + 3)
            return
        elif s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
        else:
            pass

    print(-1, -1)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 3188
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int N, M;
list<long long int>edge[1001];
long long int dis[1001];
int used[1001];
queue<long long int>Q;

int main() {
	ios::sync_with_stdio(false);
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		long long int a, b, c;
		cin >> a >> b >> c;
		if (c < 0)	edge[a].push_back((b*MOD - c) * 10);
		else edge[a].push_back((b*MOD + c) * 10 + 1);
	}
	for (int i = 1; i <= N; i++)dis[i] = MOD*(-1) * N;
	dis[1] = 0;
	used[1] = 1;
	Q.push(1);
	while (!Q.empty()) {
		long long int current = Q.front();
		//cout << current << endl;
		for (auto i : edge[current]) {
			//cout << (i / 10) % MOD << endl;
			if (i % 10) {
			//	cout << (i / 10) % MOD << endl;
				if (dis[i / MOD / 10] < dis[current] + (i / 10) % MOD) {
					dis[i / MOD / 10] = dis[current] + (i / 10) % MOD;
					used[i / MOD / 10]++;
					if (used[N] == 1000) {
						cout << "inf\n";
						return 0;
					}
					if (used[i / MOD / 10] == 100000) {
						cout << dis[N] << endl;
						return 0;
					}
					Q.push(i / MOD / 10);
				}
			}
			else {
			//	cout << (i / 10) % MOD << endl;
				if (dis[i / MOD / 10] < dis[current] - (i / 10) % MOD) {
					dis[i / MOD / 10] = dis[current] - (i / 10) % MOD;
					used[i / MOD / 10]++;
					if (used[N] == 1000) {
						cout << "inf\n";
						return 0;
					}
					if (used[i / MOD / 10] == 100000) {
						cout << dis[N] << endl;
						return 0;
					}
					Q.push(i / MOD / 10);
				}
			}
		}
		Q.pop();
	}
	cout << dis[N] << endl;
	return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cin >> n; 
	vector<ll> a(n);
	ll x0 = 0 ; 
	rep(i,n){
		cin >> a[i];
		if(i%2==0){
			x0 += a[i];
		}else{
			x0 -= a[i];
		}
	}
	vector<ll> ans(n);
	ans[0] = x0 ;
	for(int i = 1 ; i < n ; i ++ ){
		ans[i] = 2 * a[i-1] - ans[i-1] ;
		if( i == n -1 ){
			ans [i] = 2 * a[n-1] - ans[0] ;
		}
	}
	for(auto x : ans ){
		cout << x << endl;
	}

}


Measured memory_bytes: 2944
let bfs vs n =
  let d = Array.make n (-1) in
  let q = Queue.create () in
  d.(0) <- 0;
  Queue.add 0 q;
  let rec doit x = function
    | [] -> ()
    | v :: vs ->
      if d.(v-1) <> (-1) then doit x vs
      else begin
        d.(v-1) <- x;
        Queue.add (v-1) q;
        doit x vs
      end in
  while not (Queue.is_empty q) do
    let i = Queue.take q in
    doit (d.(i) + 1) vs.(i)
  done;
  d

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let vs = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> vs.(u-1) <- l
    | _ -> assert false
  done;
  bfs vs n |> Array.iteri (fun i e -> Printf.printf "%d %d\n" (i + 1) e)

Measured memory_bytes: 2280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC149B - Greedy Takahashi

        Scanner sc = new Scanner(System.in);

        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        long n = k - a;

        if (a >= k) {
            a -= k;
        } else {
            a = 0;
        }

        if (n > 0) {
            b -= n;
        }

        if (b < 0) {
            b = 0;
        }

        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21844
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            //Console.WriteLine(ret);
#endif
        }
    }

    public const int QN = 26;
    static int n;
    static int[][] ss;
    static int[] cc;

    static object process(TextReader input) {
        n = int.Parse(input.ReadLine());
        cc = ToIntArray(input.ReadLine(), QN);

        ss = new int[n][];
        for (int i = 0; i < ss.Length; i++) {
            ss[i] = ToIntArray(input.ReadLine(), QN);
        }

        List<int> ans = new List<int>();
        for (int i=0; i < n; i++) {
            var t = int.Parse(input.ReadLine());
            ans.Add(t-1);
            var x = Score(ans, i+1);
            Console.WriteLine(x);
        }

        //var lasts = new int[QN];
        //List<int> ans = new List<int>();

        //for(int day=1; day<=n; day++) {
        //    long max = long.MinValue;
        //    int maxJ = 0;

        //    for(int j=0; j<QN; j++) {
        //        var x = UpVal(day, lasts, j);
        //        if(x > max || (x==max && cc[j] > cc[maxJ])){
        //            max = x;
        //            maxJ = j;
        //        }
        //    }

        //    lasts[maxJ] = day;
        //    ans.Add(maxJ);
        //}

        //foreach(var x in ans) {
        //    Console.WriteLine(x+1);
        //}

        return null;
    }

    static long Score(List<int> ans, int day) {
        long y = 0;
        var lasts = new int[QN];

        for (int i=0; i<day; i++) {
            y += ss[i][ans[i]];
            lasts[ans[i]] = i+1;
            y -= DownVal(i+1, lasts);
        }
        return y;
    }

    static long UpVal(int day, int[] lasts, int si) {
        long up = ss[day-1][si];

        var prev = lasts[si];
        lasts[si] = day;
        var down = DownVal(day, lasts);
        lasts[si] = prev;
        
        return up - down;
    }

    static long DownVal(int day, int[] lasts) {
        long y = 0;
        for(int i=0; i < QN; i++) {
            y += cc[i] * (day - lasts[i]);
        }
        return y;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        if (n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 28160
# -*- coding: utf-8 -*-
"""
http://abc064.contest.atcoder.jp/tasks/abc064_d

"""
import sys
from sys import stdin
input = stdin.readline


def check_balance(S):
    st = 0
    for pos, c in enumerate(S):
        if c == '(':
            st += 1
        else:                   #  ')'
            st -= 1
            if st < 0:
                break
    return st


def main(args):
    N = int(input())
    S = input().strip()
    # S = '))))(((('

    result = check_balance(S)
    while result != 0:
        if result < 0:
            S = '(' + S
        elif result > 0:
            S = S + ')'
        result = check_balance(S)

    print(S)

if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
c=[0]
ci=0
for i in range(1,10**5+1):
  if is_prime(i) and is_prime((i+1)//2):
    ci+=1
  c.append(ci)
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
for lri in lr:
  print(c[lri[1]]-c[lri[0]-1])


Measured memory_bytes: 28992
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<unordered_map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<memory>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a)   a.begin(),a.end()
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;
template <int MOD>
struct ModInt {
    using lint = long long;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt inv() const { return this->pow(MOD - 2); }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt pow(lint n) const {
        auto x = ModInt(1);
        auto b = *this;
        while (n > 0) {
            if (n & 1) x *= b;
            n >>= 1;
            b *= b;
        }
        return x;
    }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= x.inv(); }
    //
    ModInt operator++(int) {
        auto t = *this;
        *this += 1;
        return t;
    }

    ModInt operator--(int) {
        auto t = *this;
        *this -= 1;
        return t;
    }
    ModInt operator<<(const int n){
        return ModInt(*this)*ModInt(2).pow(n);
    }
    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

void c(){
   ll K,A,B; cin >> K >> A >> B;
   ll ans=1;
   if(A>=B||K<=A||B-A<=2){
       cout << ans+K << endl;
       return;
   }

   K-=A;
   ans=B;
   K--;
   if(K>0){
        ans+=K/2*(B-A)+(K%2?1:0);
   }
    cout <<  ans;

}


int main(){
   c();
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,a,b,c,tot,ncnt,scnt;
int dfn[20000],low[20000],v[10000005],nxt[10000005],h[20000],col[20000];
bool ins[20000];
stack<int> s;

void addedge(int x,int y){v[++tot]=y; nxt[tot]=h[x]; h[x]=tot;}

void tarjan(int u){
	dfn[u]=low[u]=++ncnt;
	s.push(u); ins[u]=1;
	for(int p=h[u];p;p=nxt[p]){
		if(!dfn[v[p]]) tarjan(v[p]),chkmin(low[u],low[v[p]]);
		else if(ins[v[p]]) chkmin(low[u],dfn[v[p]]);
	}
	if(dfn[u]==low[u]){
		int tmp;
		scnt++;
		do{
			tmp=s.top(); s.pop();
			col[tmp]=scnt,ins[tmp]=0;	
		}while(tmp!=u);
	}
}

int main(){
	n=readint(); a=readint(); b=readint(); c=readint();
	if(a==0) return printf("No\n"),0;
	for(int i=0;i<(1<<(n+1));i++){
		if(((i&b)==b)||((i&c)==i))
			for(int j=i;j<(1<<(n+1));j++)
				if(((i&j)==b)||((i|j)==c))
					addedge(i,j^a),addedge(j,i^a);
	}
	for(int i=0;i<(1<<(n+1));i++) if(!dfn[i]) tarjan(i);
	for(int i=0;i<(1<<(n+1));i++) if(col[i]==col[i^a]) return printf("No\n"),0;
	printf("Yes\n");
	int num=0;
	for(int i=0;i<(1<<(n+1));i++){
		if(col[i]<col[i^a]){
			printf("%d",i);
			num++;
			if(num!=(1<<n)) printf(" ");
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 78300
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;


int main() {

	int N;
	cin >> N;

	//数列の値と一緒にインデックスも保持する
	vector<pair<int, int>> A(N);
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A[i].F = tmp; //value
		A[i].S = i;   //index
	}
	sort(A.begin(), A.end()); // 数列の値で昇順ソート


	for (int i = 0; i < N; i++) {
	    //iが一番大きい値のインデックスではないとき
		if (i != A[N-1].S) { //昇順でソートしているので、一番大きい値は一番最後の値
			cout << A[N-1].F << endl;
		}
		else { //iが一番大きい値のインデックスのとき
			cout << A[N - 2].F << endl; //iの数列の値を除外するので、最後から2番目の値を出力すればOK
		}
	}

	return 0;
}

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


int main(){
  int m,n;cin>>m>>n;
  int a,b;
  while(true){
    a=max(m,n);
    b=min(m,n);
    a%=b;
    m=a;
    n=b;
    if(m==0){
      cout<<n<<endl;
      break;
    }
  }
}



Measured memory_bytes: 3060
import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])

ans=0
for i in range(61):
  B = (A >> i) & 1
  x = np.count_nonzero(B == 0)
  y = N - x
  ans += (x*y*(2**i))%(10**9+7)
  
print(ans%(10**9+7))

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

int main() {
  int n, m; cin >> n >> m;
  
  int a[1005], count =0;
  double ans =0;
  for (int i=0; i<n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  double sum = ans/(4*m);
  
  for (int i=0; i<n; i++) {
    if (a[i] >= sum)	count++;
  }
  if (count >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program{
    public static void Main(){
        string filename = "";
        TextReader reader;
        if(filename.Count()==0) reader = Console.In;
        else reader = new StreamReader(filename);
        var s = reader.ReadLine();
        var t = reader.ReadLine();
        var dp = new int[s.Count()+1, t.Count()+1];
        for(int i=1; i<t.Count()+1; i++) dp[0, i] = i;
        for(int j=1; j<s.Count()+1; j++) dp[j, 0] = j;

        for(int i=1; i<dp.GetLength(0); i++){
            for(int j=1; j<dp.GetLength(1); j++){
                //?????????????????????????????¨
                if(s[i-1]==t[j-1]) dp[i, j] = dp[i-1, j-1];
                else{
                    //?????????????????????????????????????????????????????????????????????????°??????????
                    dp[i, j] = Math.Min(dp[i-1, j-1]+1, Math.Min(dp[i-1, j]+1, dp[i, j-1]+1));
                }
            }
        }

        Console.WriteLine(dp[s.Count(), t.Count()]);
    }
}

Measured memory_bytes: 13472
N, X, Y = map(int, input().split())
ans = [0]*(N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = min(j-i, abs(X-i)+abs(j-Y)+1)
        ans[d-1] += 1

print(*ans, sep='\n')


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

int main() {
  int a;
  int b;
  cin >> a >> b;
   if (a == b){
    cout << "a == b";
  } else if (a < b){
    cout << "a < b";
  } else if (a > b){
    cout << "a > b";
  } 
  cout << endl;
  return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

int main(){
    int N;
    cin >> N;
    vector<string> W(N);
    set<string> WC;
    bool flag = false;
    for (int i = 0; i < N; i++)
    {
        cin >> W[i];
        WC.insert(W[i]);
    }
    if(WC.size() != W.size()){
        cout << "No" << endl;
    }
    else{
        for (int i = 1; i < N;i++)
        {
            if (W[i - 1].at(W[i - 1].size()-1) != W[i].at(0))
            {
                flag = true;
            }
        }
        if(flag == false){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
using namespace std;
const constexpr int INF = 1e9;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;
const constexpr ll MOD = 1e9 + 7;
const int BITSIZE = 100010;

struct Less {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.second < y.second;
	}
};
struct More {
	bool operator()(const pair<int, int>& x, const pair<int, int>& y) const {
		return x.first > y.first;
	}
};
//1-indexed
int bit[100010];

int bit_query(int i) {
	int res = 0;
	for (; i >= 1; i -= i & -i) res = max(res, bit[i]);
	return res;
}

void bit_set(int x, int v) {
	for (; x <= BITSIZE; x += x & -x) {
		bit[x] = max(bit[x], v);
	}
}

int a[110];
int main() {
	ll N, x; cin >> N >> x;
    REP(i, N) cin >> a[i];
    
    sort(a, a+N);
    
    ll ans=0;
    for(int i=0; i<N; ++i){
        if(x-a[i]>=0){
            x-=a[i];
            ans++;
        }else{
            break;
        }
    }
    if(ans==N&&x!=0) ans--;
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

ll N = 100010;
ll bit[100010];
void add(ll a, ll w) {
	a++;
	for (ll x = a; x <= N; x += x & -x) bit[x] += w;
}
ll sum(ll a) {
	a++;
	ll ret = 0;
	for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
	return ret;
}
// return the sum of [a, b)
ll sum(ll a, ll b) {
	ll ret = 0;
	if(b == 0) return 0;
	ret += sum(b - 1);
	if(a) ret -= sum(a - 1);
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];
	REP(i, a[0] + 1) add(i, 1);
	FOR(i, 1, n) for(ll j = k; j >= 0; j--) {
		add(j, sum(max(0ll, j - a[i]), j) % MOD);
	}
	cout << (sum(k) - sum(k - 1)) % MOD << endl;
	return 0;
}

/* --------------------------------------- */


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

double func_y(double x,int q);
double func_z(double x);
double newton(double x,int q);

int main(void) {
	int q;
	double x;
	for (;;) {
		scanf("%d", &q);
		if (q == -1) break;
		x = q / 2.0;
		printf("%.6lf\n",newton(x, q));
	}

	return 0;
}

double func_y(double x,int q) {
	return (pow(x, 3.0)-q);
}

double func_z(double x) {
	return (3.0*pow(x, 2.0));
}

double newton(double x,int q) {
	if (fabs(func_y(x, q)) < 0.00001*q) {
		return x;
	}
	return newton(x - func_y(x, q) / func_z(x),q);
}


Measured memory_bytes: 2044
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int a, b;
		String op, str;
		str = "";

		while (true) {
			a = scan.nextInt();
			op = scan.next();
			// op?????????\??£?????´??????????????????????????????
			if (op.equals("?")) {
				break;
			}
			b = scan.nextInt();

			if (op.equals("-")) {
				str = str + Integer.toString(a - b) + "\n";
			}
			if (op.equals("+")) {
				str = str + Integer.toString(a + b) + "\n";
			}
			if (op.equals("*")) {
				str = str + Integer.toString(a * b) + "\n";
			}
			if (op.equals("/")) {
				str = str + Integer.toString(a / b) + "\n";
			}
		}
		
		System.out.print(str);
		
	}
}

Measured memory_bytes: 26480
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 1000000007LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (ll i=(a); i >= b; i--)

#define MN 100005
int n;
ll k;
int a[MN];

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

    cin >> n >> k;
    F0R(i, n){
        cin >> a[i];
    }
    ll res = 0;
    F0R(i, n){
        FOR(j, i+1, n-1){
            if(a[i] > a[j]){
                res += k*(k+1)/2;
            } else if(a[i] < a[j]){
                res += k*(k-1)/2;
            }
            res %= MOD;
        }
    }
    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256