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

const int N = 55;
const int K = 110;

int dp[N][N][K];

int n,k;
int arr[N];

int get(int l, int r, int moves){
	if( moves < 0 ){ return -1e9; }
	if( moves == 0 or ( l > r ) ){ return 0; }
	int &ans = dp[l][r][moves];
	if( ans != -1 ){ return ans; }

	int c1 = get(l+1,r,moves-1) + arr[l];
	int c2 = get(l,r-1,moves-1) + arr[r];
	int c3 = get(l+1,r,moves-2);
	int c4 = get(l,r-1,moves-2);
	int c5 = 0;
	ans = max(c1,c2);
	ans = max(ans,c3);
	ans = max(ans, c4);
	ans = max(ans, c5);
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(int i=0; i<n; ++i){
		cin>>arr[i];
	}
	cout<<get(0,n-1,k)<<'\n';
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  FOR(i, n, 1000)
  {
    int a = i / 100;
    int b = (i - a * 100) / 10;
    int c = i % 10;
    if (a == b && b == c)
    {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
from collections import defaultdict

s = input()

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

else:
    exist = False
    for start in range(len(s)-2):
        dic = defaultdict(int)
        for item in range(start, start+3):
            dic[s[item]] += 1
            
        if any([i > 1 for i in list(dic.values())]):
            print(start+1, start+3)
            exist = True
            break
        
    if not exist:
        print(-1, -1)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int n,b,ans=0;
int a[105],f[105][105];
int x[2][105],cnt[2],c;
int p[10000005],prime[3000005],tot=0;
int vis[105],link[105];

int dfs(int x){
	for(int i=1;i<=cnt[1];i++){
		if(vis[i]==0&&f[x][i]==1){
			vis[i]=1;
			if(link[i]==0||dfs(link[i])){
				link[i]=x;
				return 1;
			}
		}
	}
	return 0;
}

int main(){
	scanf("%d",&n);
	a[0]=-1;
	for(int i=2;i<=10000000;i++){
		if(p[i]==0) prime[++tot]=i;
		for(int j=1;j<=tot&&i*prime[j]<=10000000;j++){
			p[i*prime[j]]=1;
			if(i%prime[j]==0) break;
		}
	}
	p[1]=p[2]=1;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++){
		if(a[i]==a[i-1]+1) continue;
		if(a[i-1]!=-1) x[c=(a[i-1]+1)&1][++cnt[c]]=a[i-1]+1;
		x[c=a[i]&1][++cnt[c]]=a[i];
	}
	x[c=(a[n]+1)&1][++cnt[c]]=a[n]+1;
	for(int i=1;i<=cnt[0];i++){
		for(int j=1;j<=cnt[1];j++){
			if(p[abs(x[0][i]-x[1][j])]==0) f[i][j]=1;
		}
	}
	for(int i=1;i<=cnt[0];i++){
		memset(vis,0,sizeof(vis));
		if(dfs(i)) ans++;
	}
	cnt[1]-=ans,cnt[0]-=ans;
	ans+=2*(cnt[1]/2+cnt[0]/2);
	if(cnt[1]&1) ans+=3;
	printf("%d\n",ans);
	
	return 0;
}

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

int n;
int ans = 0;

bool check(ll x) {
  if (x > n) return false;

  bool c3 = false, c5 = false, c7 = false;
  string str = to_string(x);
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '3') c3 = true;
    if (str.at(i) == '5') c5 = true;
    if (str.at(i) == '7') c7 = true;
  }

  if (c3 && c5 && c7) {
    return true;
  } else {
    return false;
  }
}

void dfs(ll x) {
  if (check(x)) ans++;
  if (x <= n) {
    dfs(10 * x + 3);
    dfs(10 * x + 5);
    dfs(10 * x + 7);
  }
}

int main() {
  cin >> n;
  dfs(0);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

const int maxn = 100005;

int n,da[maxn];

map<int,int> mp;
map<int,int>::iterator it;

int odd(int x)
{
    return (x&1?1:0);
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",da+i);
        mp[da[i]];
    }
    int tot = 0;
    for(it=mp.begin();it!=mp.end();it++)
        it->second = tot++;
    int l = 0,r = 0;
    for(int i=0;i<n;i++)
    {
        if(odd(i)&&!odd(mp[da[i]]))
            l++;
        else if(!odd(i)&&odd(mp[da[i]]))
            r++;
    }
    printf("%d\n",max(l,r));
}


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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

template<class T>
inline bool chmax(T& a, T b){if(a<b){a=b;return true;} return false;}

template<class T>
inline bool chmin(T& a, T b){if(a>b){a=b;return true;} return false;}

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

void out(){cout << "\n";}
template<class T,class... Args>
void out(const T &x,const Args &... args){
	cout << x << " ";
	out(args...);
}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,k,x;
	map<ll,ll> m;
	cin >> n >> k;
	rep(i,k){
		ll d;
		cin >> d;
		rep(j,d){
			cin >> x;
			m[x]++;
		}
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if((m[i])==0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    string s;
    cin>>s;
    char prv = s[0];
    ll cnt = 1;
    for(ll i = 1; i<n; i++){
        if(s[i] != prv){
            cnt++;
            prv = s[i];
        }
    }
    cout<< cnt <<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int arr[4][3][10];
  rep(i, 0, 4) rep(j, 0, 3) rep(k, 0, 10) arr[i][j][k] = 0;

  rep(i, 0, n) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    arr[b - 1][f - 1][r - 1] += v;
  }

  rep(i, 0, 4) {
    rep(j, 0, 3) {
      rep(k, 0, 10) { cout << " " << arr[i][j][k]; }
      cout << endl;
    }
    if (i != 3)
      cout << "####################" << endl;
  }
}



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

using namespace std;

int main()
{
    int n; cin >> n;
    int T = 0, X = 0, Y = 0;
    for (int i = 0; i < n; i ++) {
        int t, x, y; cin >> t >> x >> y;
        int dis = abs(x - X) + abs(y - Y), deltaT = t - T;
        if (dis <= deltaT && (deltaT - dis) % 2 == 0) {
            X = x;
            Y = y;
            T = t;
        }
        else return cout << "No\n", 0;
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    //int t;
    //cin>>t;
    //while(t--){
        char a;
        cin>>a;
        if(a>=97 && a<=122)
        cout<<"a"<<endl;
        else
        cout<<"A"<<endl;
    return 0;
}

Measured memory_bytes: 3644
n,m = map(int,input().split())
py = []
p_y = [[] for i in range(n)]
for _ in range(m):
    p,y = map(int,input().split())
    py.append((p,y))
    p_y[p-1].append(y)
ans = {}
for i, tmp in enumerate(p_y):
    cnt = 1
    p_y[i] = tmp.sort()
    for j, jj in enumerate(tmp):

        ans[(i+1, jj)] = str(i+1).zfill(6) + str(j+1).zfill(6)


for i, tmp in enumerate(py):
    print(ans[tmp])


Measured memory_bytes: 98464
#include <stdio.h>

int main(){
    int i,n;
    int a[10001];
    int max = -1000001, min = 1000001;
    double sum = 0;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++){
        if(a[i]>=max) max = a[i];
        if(a[i]<=min) min = a[i];
        sum += a[i];
    }
    printf("%d %d %.0lf\n", min, max, sum);
}


Measured memory_bytes: 2748
#区間ごとの面積を計算する
def calc_area(v_end, v_start, v_max, dt):
    kouten_v = (v_end + v_start + dt) / 2
    kouten_t = kouten_v - v_start
    if 0 < kouten_t < dt:
        area = (v_start + kouten_v) * kouten_t / 2 #左側
        area +=  (v_end + kouten_v) * (dt - kouten_t) / 2 #右側
        area -=  max(0, (kouten_v - v_max))** 2 #上の三角形
    else:
        area = (v_start + v_end) *  dt / 2
    return area

def main():
    #与えられた入力を受け取る
    n=int(input())
    t=[int(i) for i in input().split()]
    v=[int(i) for i in input().split()]

    #各区間の許容最大速度を計算する
    #（この段階では傾きが-1未満になる可能性がある）
    max_velocity = [0]
    for i in range(1, n):
        max_velocity_ = min(v[i-1], v[i], max_velocity[i-1] + t[i-1])
        max_velocity.append(max_velocity_)
    max_velocity.append(0)

    #後ろから走査して、傾きが-1未満を満たすように許容速度をfittingする
    for i in range(n-1):
        if  max_velocity[-(i+1)] - max_velocity[-(i+2)] < -t[-(i+1)]:
            max_velocity[-(i+2)] = max_velocity[-(i+1)] + t[-(i+1)]

    #各区間の面積を計算して足し合わせる
    ans = 0
    for i in range(n):
        ans += calc_area(max_velocity[i+1], max_velocity[i], v[i], t[i])
    print(ans)

main()

Measured memory_bytes: 3064
#include <cstdio>
#include <set>

std::set<int> e[100000];
int num;

bool path(int a, int b, int p){
  if(a==b) return true;

  for(auto c: e[a]){
    if(c == p) continue;
    if(path(c, b, a)){
      e[a].erase(c);
      e[c].erase(a);
      num--;
      return true;
    }
  }
  return false;
}

int main(){
  int n, m;
  scanf("%d%d", &n, &m);
  int r = 0;
  for(int i=0;i<m;i++){
    int a, b;
    scanf("%d%d", &a, &b);
    if(!path(a-1, b-1, -1)){
      e[a-1].insert(b-1);
      e[b-1].insert(a-1);
      num++;
    }
  }
  if(num) puts("NO"); else puts("YES");
  return 0;
}


Measured memory_bytes: 13312
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(j==0||j==W-1||i==0||i==H-1){
					printf("#");
				}
				else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}
			

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
int a[5];
int main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n,m,c,s;
    cin >> n >> m;
    memset(a,-1,sizeof a);
    if(n == 1 and m == 0) {
        cout << 0;
        return 0;
    }
    for(int i = 0;i < m; ++i) {
        cin >> c >> s;
        if(a[c] == -1) {
            a[c] = s;
        }
        else if(a[c] != s) {
            cout << "-1";
            return 0;
        }
    }
    if(a[1] == 0 and n > 1) {
        cout << -1;
        return 0;
    }
    if(a[1] == -1) a[1] = 1;
    for(int i = 1;i <= n; ++i) {
        if(a[i] == -1) cout << 0;
        else cout << a[i]; 
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;


int main(){
    int A,B,C; cin >> A >> B >> C;
    bool ok = false;
    repr(i,1,B+1){
        int sum = A * i;
        if(sum % B == C) ok = true;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 256
import java.util.*;
class Main{
	Scanner sc=new Scanner(System.in);
	void aa(){
		int S=sc.nextInt();
		int h=S/3600;
		int m=(S%3600)/60;
		int s=S%60;
		System.out.println(h+":"+m+":"+s);
	}
	public static void main(String[]arg){
		new Main().aa();
	}
}

Measured memory_bytes: 17168
my ($n,$m) = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));
my @A = map { $_ - 0 } split(/\s+/,scalar(<STDIN>));

my $tot = 0;
for(my $i=0;$i<$m;$i++){
  $tot += $A[$i];
}
my $r = $n - $tot;
$r = -1 if $r < 0;
print "$r\n";


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

map<ll, ll> fmap;

void pressU(ll x){
  REP(i, x)
    cout << "U";
}
void pressD(ll x){
  REP(i, x)
    cout << "D";
}
void pressR(ll x){
  REP(i, x)
    cout << "R";
}
void pressL(ll x){
  REP(i, x)
    cout << "L";
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  pressU(ty-sy);
  pressR(tx-sx);
  pressD(ty-sy);
  pressL(tx-sx);
  
  pressL(1);
  pressU(ty-sy+1);
  pressR(tx-sx+1);
  pressD(1);
  
  pressR(1);
  pressD(ty-sy+1);
  pressL(tx-sx+1);
  pressU(1);
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Here your code !
    int max,min,n;
    scanf("%d",&n);
    max = 0; min = 1000;
    int i;
    for(i =0;i<n;i++){
        int a;
        scanf("%d",&a);
        if(a>max){max = a;}
        if(a<min){min = a;}
    }
    printf("%d\n",(max-min));
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#define N 15
#define M 1005
using namespace std;

int n, m, a[M], b[M], c[M][N], d[1 << N];

int f(int p, int q) {
	int i, j, ne, re = 1e9;
	if (p == 0) return 0;
	if (q == m) return 1e9;
	if (d[p]) return d[p];
	for (i = q; i < m; i++) {
		ne = p;
		for (j = 0; j < b[i]; j++) {
			ne &= (1 << n) - 1 - (1 << c[i][j] - 1);
		}
		if (ne != p) re = min(re, f(ne, i + 1) + a[i]);
	}
	return d[p] = re;
}

int main()
{
	int i, j, t;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf("%d %d", &a[i], &b[i]);
		for (j = 0; j < b[i]; j++) {
			scanf("%d", &c[i][j]);
		}
	}
	t = f((1 << n) - 1, 0);
    if (t == 1e9) puts("-1");
    else cout << t;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(f) (f).begin(),(f).end()
#define allr(f) (f).rbegin(),(f).rend()
const int mod = 1e9+7, A = 1e2+5;
using namespace std;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int k, x;
  	cin >> k >> x;
  	cout << (k * 500 >= x ? "Yes" :" No");
	
	return 0;
}

Measured memory_bytes: 256
/*	Don’t Quit
	
	When things go wrong as they sometimes will;
		When the road you’re trudging seems all uphill;
			When the funds are low, and the debts are high;
				And you want to smile, but you have to sigh;
					When care is pressing you down a bit
						Rest if you must, but don’t you quit.
*/
#pragma gcc optimize ("unroll-loop")
#pragma gcc optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
const int N=3e5+10;
int gcd(int n,int m)
{
	if(n==0)
		return m;
	else
		return gcd(m%n,n);
}
int32_t main()
{
	IOS;
	string s;
	cin>>s;
	stack<int>st;
	int ans=0;
	for(int i=0;i<s.size();i++)
	{
		int k=s[i]-'0';
		if(st.size()==0)
		{
			st.push(k);
		}
		else if(k==1)
		{
			if(st.top()==0)
			{
				st.pop();
				ans+=2;
			}
			else
			{
				st.push(1);
			}
		}
		else
		{
			if(st.top()==1)
			{
				st.pop();
				ans+=2;
			}
			else
			{
				st.push(0);
			}
		}
	}
	cout<<ans<<endl;



}

Measured memory_bytes: 1232
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int r, c;
	cin >> r >> c;
	int map[150][150];
	for (int i = 1; i < 105; i++) {
		for (int j = 1; j < 105; j++) {
			map[i][j] = 0;
		}
	}
	int a;
	for (int i = 1; i <= r; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> a;
			map[i][j] = a;
		}
	}
	for (int i = 1; i <= r; i++) {
		int sum = 0;
		for (int j = 1; j <= c; j++) {
			sum += map[i][j];
		}
		map[i][c + 1] = sum;
	}
	for (int j = 1; j <= c; j++) {
		int sum = 0;
		for (int i = 1; i <= r; i++) {
			sum += map[i][j];
		}
		map[r + 1][j] = sum;
	}
	for (int i = 1; i <= c; i++) {
		map[r + 1][c + 1] += map[r + 1][i];
	}
	for (int i = 1; i <= r + 1; i++) {
		for (int j = 1; j <= c + 1; j++) {
			if (j == c + 1) {
				cout << map[i][j] << endl;
			}
			else {
				cout << map[i][j] << " ";
			}
		}
	}
}

Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main(void){
    
    int A, B;
    cin >> A >> B;
    
    // 判定：最強が 1 により 1 を 14 に変えることで数字で見ても最強に変える
    if(A == 1) A = 14;
    if(B == 1) B = 14;
    
    if(A == B)
        cout << "Draw" << endl;
    else if(A > B)
        cout << "Alice" << endl;
    else
        cout << "Bob" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  string S; cin>>S;
  set<char> M;
  rep(i,0,S.size()){
    M.insert(S[i]);
  }
  string ans="Yes";
  if((M.count('N')^M.count('S'))) ans="No";
  if((M.count('W')^M.count('E'))) ans="No";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
stairs = [1] * (N+1)
for m in range(M):
    a = int(input())
    stairs[a] = 0
for n in range(2, N+1):
    stairs[n] = (stairs[n-1] + stairs[n-2])*stairs[n]
print(stairs[N]%1000000007)

Measured memory_bytes: 462708
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i%2==0) continue;
        int cnt = 0;
        for (int j = 1; j <= i; ++j) {
            if (i%j==0) cnt++;
        }
        if (cnt==8) ans++;
    }
    cout << ans << ln;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define add(x,y)(x=((ll)y+x)%mo)
#define ll long long
using namespace std;
const int N=(1<<16)+5,mo=1e9+7;
int n,m,o,ans,v;
int a[N],jc[N],ny[N],f[2][N];
int ksm(int x,int y){
	int t=1;
	for(;y;y>>=1,x=(ll)x*x%mo)if(y&1)t=(ll)t*x%mo;
	return t;
}
inline int c(int n,int m){
	return n>=m?(ll)jc[n]*ny[m]%mo*ny[n-m]%mo:0;
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	fo(i,1,m)cin>>a[i];
	jc[0]=1;
	fo(i,1,1<<n)jc[i]=(ll)jc[i-1]*i%mo;
	ny[1<<n]=ksm(jc[1<<n],mo-2);
	fd(i,0,(1<<n)-1)ny[i]=(ll)ny[i+1]*(i+1)%mo;
	f[0][0]=1;
	fd(i,1,m){
		o^=1;
		memcpy(f[o],f[!o],sizeof f[o]);
		int g=(1<<n)-a[i]+1;
		fo(j,0,1<<n)if(v=f[!o][j])
			for(int k=0;(1<<k)<=g-j;++k)if(~j&(1<<k))
				add(f[o][j+(1<<k)],-v*c(g-j-1,(1<<k)-1)%mo*jc[1<<k]);
	}
	fo(j,0,(1<<n))if(v=f[o][j]){
		int all=(1<<n)-1-j;
		v=(ll)v*jc[all]%mo;
//		fo(k,0,n-1)if(all&(1<<k))v=(ll)v*ny[1<<k]%mo;
		ans=(ans+v)%mo;
	}
	cout<<((ll)(ans+mo)<<n)%mo;
}

Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    string s; cin>>s;
    ll n = s.size();

    ll res = n;

    for(ll i = 0; i < n-1; ++i) {
        if(s[i] == s[i+1]) {
            continue;
        }
        res = min(res, max(i+1, n-i-1));
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=1000005;
const int mod=924844033;

struct E{
	int to,next;
}mem[N];
int n,num,x,y,l,il;
int head[N],b[N],a[N],f[N],sz[N],g[N],fac[N],inv[N];

void add(int x,int y){
	num++;
	mem[num].to=y; mem[num].next=head[x];
	head[x]=num;
}

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(){
	int i;
	fac[0]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

void dfs(int k,int pre){
	int j,u;
	sz[k]=1;
	for (j=head[k];j;j=mem[j].next){
		u=mem[j].to;
		if (u==pre) continue;
		dfs(u,k);
		sz[k]+=sz[u]; g[sz[u]]--;
	}
	if (k!=1) g[n-sz[k]]--;
}

void ntt(int z[],int b){
	int s,x,y,w,wd,i,j,k;
	for (i=0;i<l;i++){
		s=0;
		for (j=1,k=l>>1;j<l;j<<=1,k>>=1) if (i&j) s+=k;
		if (i<s) swap(z[i],z[s]);
	}
	for (i=1;i<l;i<<=1){
		wd=quickpow(5,(mod-1)/(i<<1))%mod; 
		if (b==-1) wd=quickpow(wd,mod-2);
		for (int j=0;j<l;j+=(i<<1)){
			w=1;
			for (int k=0;k<i;k++){
				x=z[j+k]; y=1ll*z[j+k+i]*w%mod;
				z[j+k]=(x+y)%mod;
				z[j+k+i]=(x-y+mod)%mod;
				w=1ll*w*wd%mod;
			}
		}
	} 
}

int main(){
	int i;
	scanf("%d",&n);
	for (i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	init();
	dfs(1,0);
	for (l=1;l<n+n+2;l<<=1);
	g[n]=n;
	for (i=0;i<=n;i++) a[i]=1ll*(g[n-i]+mod)*fac[n-i]%mod;
	for (i=0;i<=n;i++) b[i]=inv[i];
	ntt(a,1);
	ntt(b,1);
	for (i=0;i<l;i++) f[i]=1ll*a[i]*b[i]%mod;
	ntt(f,-1);
	il=quickpow(l,mod-2);
	for (i=0;i<l;i++) f[i]=(1ll*f[i]*il%mod+mod)%mod;
	for (i=1;i<=n;i++) printf("%d\n",1ll*inv[i]*f[n-i]%mod);
	return 0;
}

Measured memory_bytes: 41600
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;


int main(void) {

    ll a,b;
    cin>>a>>b;
    vector<ll> ans;
    rep(i,0,max(a,b)) ans.push_back(min(a,b));
    for (auto el:ans) cout<<el;
    cout<<endl;





   return 0;
}

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

#define int long long
signed main(){
    int N;cin>>N;
    vector<int>v(N);
    for(auto& x:v){
        cin>>x;
    }
    vector<int>dp(N);
    dp[0]=1000;
    for(int i=1;i<N;i++){
        dp[i]=dp[i-1];
        for(int j=0;j<i;j++){
            int x = dp[j]/v[j];
            int y = dp[j]%v[j];
            int z = v[i];
            dp[i] = max(dp[i], y+x*z);
        }
    }
    cout<<dp[N-1]<<endl;



    return 0;
}

Measured memory_bytes: 3140
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scanf("%d\n%d\n%d\n%d\n", &a, &b, &c, &x)
	ans := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					// fmt.Println("i=", i)
					// fmt.Println("j=", j)
					// fmt.Println("k=", k)
					ans++
				}
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
Scanf.scanf "%d" (fun n ->
    let a = Array.make (n + 1) 0 in
    for i = 2 to n do
        Scanf.scanf " %d" (fun j -> a.(j) <- a.(j) + 1)
    done;
    for i = 1 to n do
        Printf.printf "%d\n" a.(i)
    done
)

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    vector<pair<int, pair<int, int>>> towns(N, make_pair(0, make_pair(0, 0)));
    for (int i = 0; i < N; ++i) {
        towns[i].first = i;
        cin >> towns[i].second.first >> towns[i].second.second;
    }

    double sum = 0;
    do {
        for (int i = 1; i < N; ++i) {
            int x0 = towns[i - 1].second.first;
            int y0 = towns[i - 1].second.second;
            int x1 = towns[i].second.first;
            int y1 = towns[i].second.second;
            sum += sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
        }
    } while (next_permutation(towns.begin(), towns.end()));
    for (int i = 2; i <= N; ++i) {
        sum /= i;
    }
    cout << sum << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3792
/// kAAzuki Hoshino
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int n,m,x[2020],y[2222],p2[22222],val[22222],w[2222],xx,c1,c2;

void make(int id){
        int res = w[id];
        UnionFindTree t(n+2);
        t.unite(x[id],y[id]);
        vpi v;
        for(int i=1;i<=m;i++)if(i!=id)v.pb( { w[i],i } );
        sort(all(v));
        for(int i=0;i<v.size();i++){
                int k = v[i].sc;
                if(t.areSame( x[k],y[k] ))continue;
                else res+= w[k];
                t.unite( x[k],y[k] );
        }
        val[id] = res;
}

signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        cin >> n >> m >> xx;
        p2[0]=1;
        for(int i=1;i<=m;i++){
                p2[i] = p2[i-1]*2%mod;
                cin >> x[i] >> y[i] >> w[i];
        }
        for(int i=1;i<=m;i++){
                make( i );
               // cout << val[i] << endl;
        }
        for(int i=1;i<=m;i++){
                if(val[i]<xx)c1++;
                else if(val[i]==xx)c2++;
        }

        if(!c2){
                cout << 0 ;
                return 0;
        }
        int ans = 1;
        if(c1){
                ans = 2*(p2[c2]-1+mod)%mod;
        }
        else ans = (p2[c2]-2+mod)%mod;

        ans = ans*p2[m-c1-c2]%mod;

        cout << ans%mod << endl;


return 0;
}
///....


Measured memory_bytes: 384
#include <stdio.h>

int
main(int argc, char *argv[])
{
        int a, b, c;
        int i;
        int cnt = 0;
        
        scanf("%d %d %d", &a, &b, &c);
        for (i = a; i <= b; i++) {
                if (c % i == 0)
                        cnt++;
        }
        printf("%d\n", cnt);

        return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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


int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };

const ll MOD = 1000000007;
const ll INF = 1000000000;

int func(ll n){
    ll dec = 1;
    ll m = n;

    while (m > 0){
        m /= 10;
        dec *= 10;
    }
    return dec;
}

int main(void){
    int match[9] = { 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    int n, m;
    char a[100010];
    string dp[100010];
    cin >> n >> m;
    for (int i = 0; i < m; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) dp[i] = "-";
    dp[0] = "";
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            int h = match[(a[j] - '0') - 1];
            if (i + 1 >= h && dp[i + 1 - h] != "-"){
                if (dp[i + 1].length()<(dp[i + 1 - h] + a[j]).length() ||
                    (dp[i + 1].length() == (dp[i + 1 - h] + a[j]).length() && dp[i + 1]<dp[i + 1 - h] + a[j])){
                    dp[i + 1] = dp[i + 1 - h] + a[j];
                }
            }


        }
    }

    cout << dp[n] << endl;

}



Measured memory_bytes: 45056
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

using namespace std;


int main(){
    
    string s;
    cin>>s;
    if(s[2]==s[3] and s[4] == s[5]){
        puts("Yes");
    }
    else
        puts("No");
    
    return 0;
}

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

int main() {
	long n,m,i,j,k,ans,cur,res,x,t;
	cin >> n >> k;
	vector<long> a(n),p(n,-1);
	for(i=0; i<n; i++){
		cin >> a[i]; a[i]--;
	}
	i=0; j=0;
	while(p[j]==-1){
		p[j]=i;
		i++;
		j=a[j];
		if(k==i){
			cout << j+1 << endl; return 0;
		}
	}
	k-=i;
	res=i-p[j];
	k%=res;
	t=0;
	while(t<k){
		j=a[j];
		t++;
	}
	cout << j+1 << endl;
	return 0;
}

Measured memory_bytes: 6428
#include <iostream>
#include <math.h>
#include <algorithm>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;
ll n;

int main()
{
    // ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i != 0)
            continue;
        if (i - 1 > n / i)
            ans += i - 1;
        if (n / i == i)
            continue;
        if (n / i - 1 > i)
            ans += n / i - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        int[] ans = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }
        //
        int val = 0;
        for(int i = 0; i < N; i++) {
            if(i % 2 == 0) val += A[i];
            else val -= A[i];
        }
        ans[0] = val / 2;
        for(int i = 1; i < N; i++) {
            ans[i] = A[i-1] - ans[i-1];
        }
        for(int i = 0; i < N; i++) {
            System.out.print(ans[i] * 2 + " ");
        }

    }
}

Measured memory_bytes: 63728
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
int a[100005];
int mt[100005];
int main ()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(i%2==0)
            mt[1]-=a[i];
        else
            mt[1]+=a[i];
    }
    for(int i=2;i<=n;i++)
        mt[i]=a[i-1]*2-mt[i-1];
    for(int i=1;i<=n;i++)
        printf("%d ",mt[i]);
    printf("\n");
    return 0;
}


Measured memory_bytes: 4492
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif
int solo = 0;
int bip=0,tri = 0;
const int maxn = 1e5+5;
vector<int> g[maxn];
int col[maxn];
bool seen[maxn];

int sz = 0;

bool bd(int v, bool x = 0) {
    col[v] = x;
    for (int u : g[v]){
        if (-1==col[u]) {
            if (!bd(u, x^1))return 0;
        }else{
            if (col[u] == x) {
                return 0;
            }
        }
    }
    return 1;
}

void fill(int v) {
    seen[v] = 1;
    sz ++;
    for( int u : g[v]) {
        if (!seen[u]) fill(u);
    }
}

int main(){
    ios::sync_with_stdio(cin.tie(0));
    memset(col,-1,sizeof col);
    int n,m; cin>>n>>m;
    for (int i = 0; i<m; ++i) {
        int a,b; cin>>a>>b;
        #define pb push_back
        g[a].pb(b); g[b].pb(a);
    }
    for (int i = 1; i<=n; ++i) {
        if (!seen[i]) {
            sz = 0;
            fill(i);
            if (sz == 1) {
                solo ++;
            }else{
                if (bd(i,0)) {
                    bip ++;
                }else{
                    tri++;
                }
            }
        }
    }
    bug(solo, bip, tri);
    cout<<solo * (ll) (n) + (n-solo) * (ll) solo + 2*bip * (ll) bip + bip * (ll) tri + tri * (ll) tri + tri * (ll) bip;
}


Measured memory_bytes: 12440
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

class era
{
	public:

		string name;
		int base,west;

		era(string n, int b, int w)
		{
			name = n;
			base = b;
			west = w;
		}

		bool operator<(const era& e) const
		{
			return (west < e.west);
		}
};

int main()
{
	int Q,N,n,b,w;
	string nm;
	//ifstream cin("A.txt");

	while(cin >> Q >> N, Q||N)
	{
		vector<era> data;
		while(Q--)
		{
			cin >> nm >> b >> w;
			data.push_back(era(nm,b,w));
		}
		sort(data.begin(), data.end());

		while(N--)
		{
			cin >> n;
			string anss;
			int ansn;
			bool ok=false;
			for(int i=0; i<data.size(); i++)
			{
				if(n-data[i].west+data[i].base>0 && n-data[i].west<=0)
				{
					ansn = n-data[i].west+data[i].base;
					anss = data[i].name;
					ok = true;
					break;
				}
			}

			if(ok)
			{
				cout << anss << " " << ansn << endl;
			}
			else
			{
				cout << "Unknown" << endl;
			}
		}
	}
}

Measured memory_bytes: 976
n, q = map(int, input().split())
s = input()
cnt = 0
acIdx = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt += 1
    acIdx.append(cnt)

for i in range(q):
    l, r = map(int, input().split())
    print(acIdx[r-1] - acIdx[l-1])


Measured memory_bytes: 53080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main{
	public static void main(String args[]){
		char key[][] = {
				null,
				{'.', ',', '!', '?', ' '},
				{'a', 'b', 'c'},
				{'d', 'e', 'f'},
				{'g', 'h', 'i'},
				{'j', 'k', 'l'},
				{'m', 'n', 'o'},
				{'p', 'q', 'r', 's'},
				{'t', 'u', 'v'},
				{'w', 'x', 'y', 'z'}
		};

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n = Integer.parseInt(br.readLine());
			for(int i = 0; i < n; i++){
				String str = br.readLine();
				// 最初のnを除去
				int index = 0;
				for(; index < str.length(); index++){
					if(str.charAt(index) != '0') break;
				}
				if(index == str.length()){
					System.out.println("");
					continue;
				}
				str = str.substring(index);
				//System.out.println(str);
				
				// 0 で分割
				String strs[] = str.split("0+");
				String result = "";
				for(String segment : strs){
					int button = segment.charAt(0) - '0';
					int count = segment.length() - 1;
					char chars[] = key[button];
					result += chars[count % chars.length];
				}
				
				System.out.println(result);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25724
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <utility>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n[3]; cin >> n[0] >> n[1] >> n[2];
  sort(n, n+3);
  int d1 = n[2] - n[0]; int d2 = n[2] - n[1];
  cout << d2 + (d1-d2)/2 + 2*((d1-d2)%2)<< endl;
}


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

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < (int)s.size() - 1; i++) {
        if (s.at(i) == 'A' && s.at(i + 1) == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}   

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			String s = scanner.nextLine();
			int k = scanner.nextInt();

			Set<String> result = new HashSet<>();
			for (char c = 'a'; c <= 'z'; c++) {
				int from = 0;
				while (s.indexOf(c, from) >= 0) {
					int index = s.indexOf(c, from);
					for (int i = 1; i <= k; i++) {
						if (s.length() < index + i) {
							break;
						}
						result.add(s.substring(index, index + i));
					}
					from = index + 1;
				}
				if (result.size() >= k) {
					break;
				}
			}

			List<String> sortResult = new ArrayList<>(result);
			Collections.sort(sortResult);

			System.out.println(sortResult.get(k - 1));
		}
	}
}


Measured memory_bytes: 24276
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 2e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
struct pt {
    int a, b;
};
bool comp(pt x, pt y)
{
    return x.b < y.b || (x.b == y.b && x.a > y.a);
}
pt w[N + 1];
main() {
    int n = readInt();
    for (int i = 1; i <= n; i++) {
        w[i].a = readInt();
        w[i].b = readInt();
    }
    sort(w + 1, w + n + 1, comp);
    int t = 0;
    for (int i = 1; i <= n; i++) {
        t += w[i].a;
        if (t > w[i].b) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define int long long
#define fori(j,n) for(int i=j;i<n;i++)
#define forb(n,j) for(int i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define PI 3.141592653589793
#define M 1000000007
using namespace std;
int fast(int a,int b)
{
    int ans=1;
    a=a%M;
    if(a==0)
        return 0;
    while(b>0)
    {
        if(b&1)
        {
            ans=(ans*a)%M;
        }
        b>>=1;
        a=(a*a)%M;
    }
}
int h[100010];
int n,k;
int dp[100010];
int fun(int i)
{
    if(i==n)
        return 0;
    if(i>n)
        return INT_MAX;
    if(dp[i]!=-1)
        return dp[i];
    int mn=1e10;
    for(int j=1;j<=k;j++)
    {
         mn=min(mn,abs(h[i]-h[i+j])+fun(i+j));
    }
    return dp[i]=mn;
}
int32_t main()
{
    IOS;
    cin>>n>>k;
    memset(dp,-1,sizeof(dp));
    fori(1,n+1)
        cin>>h[i];
    cout<<fun(1);
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll arr[(int)1e6+5];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	
	sort(arr,arr+n);
	ll ans=1;
	for(int i=1;i<n;i++){
		if(arr[i]!=arr[i-1]) ans++;
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();

    stdin.read_to_string(&mut buf).unwrap();
    
    let mut buf = buf.split_whitespace();

    let (a, b) = {
        let a: i32 = buf.next().unwrap().parse().unwrap();
        let b: i32 = buf.next().unwrap().parse().unwrap();
        (a, b)
    };
    
    if a + b < 10 {
        println!("{}", a + b);
    } else {
        println!("error");
    }

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    long n = 0 , maxWeight = 0 ; 
    cin >> n >> maxWeight ; 
    long weight[n+1] , value[n+1] , maxValue[n+1][maxWeight+1] ;
    for(long i = 0 ; i <= n ; i++){
        weight[i] = value[i] = 0 ;
        for(long wt = 0 ; wt <= maxWeight ; wt++){
            maxValue[i][wt] = 0 ;
        }
    }
    for(long i = 1 ; i <= n ; i++)
        cin >> weight[i] >> value[i] ;
    for(long i = 1 ; i <= n ; i++){
        for(long wt = 1 ; wt <= maxWeight ; wt++){
            maxValue[i][wt] = maxValue[i-1][wt] ;
            if(weight[i] <= wt)
                maxValue[i][wt] = max(maxValue[i-1][wt], value[i] + maxValue[i-1][wt-weight[i]]) ;
        }
    }
    cout << maxValue[n][maxWeight] ;
}


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

int main(){
  int N;
  cin>>N;
  cout<<N%2+(N-N%2)/2;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC179
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int n = int.Parse(Console.ReadLine());
            int sum = 0;
            bool flg = false;
            for(int i = 0; i < n; i++)
            {
                int[] d = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if (d[0] == d[1])
                {
                    sum++;
                    if (sum == 3)
                        flg = true;
                }
                else
                    sum = 0;
            }
            if (flg)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 28324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<ll> A(M);
  rep(i, M) cin >> A[i];
  ll sum = accumulate(all(A), 0LL);
  if(N-sum < 0) cout << -1 << endl;
  else cout << N-sum << endl;
  return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <iomanip>
#include <string>
#include <bits/stdc++.h>

using namespace std;

int main()
{
     int n;cin>>n;long ans=0;
     for(int i=1;i<n;i++)
     {
         ans+=(n-1)/i;
         
     }
     cout<<ans;
     
}



 

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(long long i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for(long long i = 0; i < N-1; i++){
        if(A[i]==A[i+1]){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 1792