akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 2e5 + 100;
const LL INF = 1e9;

int p[MX], r[MX];

int findset(int i)
{
    if(i==p[i]) return i;
    else return p[i]=findset(p[i]);
}

void unionset(int a,int b)
{
    if(r[a] >= r[b])
    {
        p[b] = a; r[a] += r[b];
    }
    else
    {
        p[a] = b; r[b] += r[a];
    }
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n,m;
    cin>>n>>m;
    loop(i,1,n+1) {p[i] = i; r[i] = 1;}
    int u,v;

    loop(i,0,m)
    {
        cin>>u>>v;
        u = findset(u);
        v = findset(v);
        if(u != v) unionset(u,v);
    }

    int ans = 0;
    loop(i,1,n+1) ans = max(ans,r[i]);

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 5212
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

int main(){
  ios_base::sync_with_stdio(false);

  int x;
  int cnt = 0;  
  int now = 0;
 
  cin >> x;
  
  while(cnt <= x){
    if(x<=now){
      x = cnt;
      break;
    }
    cnt++;
    now += cnt;
  }
    
  cout << x << endl; 

  return 0;
}

Measured memory_bytes: 256
from collections import Counter

# print('input >>')
N, K = map(int, (input().split()))

A = [0] * N
for i in range(N):
    A[i] = (i + 1) % K

Acount = Counter(A)
# print('ACount %s' % Acount)
ans = 0
for mod, times in Acount.items():
    mod_anti = K - mod
    if (K - mod) * 2 % K == 0:
        ans += Acount[mod] ** 3

# print('----------output----------')
print(ans)

Measured memory_bytes: 16620
program main
    implicit none
    integer x
    read(*,*) x
    if(x <= 599) then
        write(*,*) 8
    else if(x <= 799) then
        write(*,*) 7
    else if(x <= 999) then
        write(*,*) 6
    else if(x <= 1199) then
        write(*,*) 5
    else if(x <= 1399) then
        write(*,*) 4
    else if(x <= 1599) then
        write(*,*) 3
    else if(x <= 1799) then
        write(*,*) 2
    else if(x <= 1999) then
        write(*,*) 1
    end if
end program


Measured memory_bytes: 2796
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mmax(a,b,c) max(a,max(b,c))
#define mmin(a,b,c) min(a,min(b,c))
#define M 1000000007
#define V vector
#define F(a,b,c) for (a=b;a<=c;++a)
#define I cin
#define O cout
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define umap unordered_map

bool isPowerOfTwo (ll x) {
    return x && (!(x&(x-1)));
}

ll binpow(ll a, ll b) {
    a %= M;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return res;
}

int main() {
    I.sync_with_stdio(false);
    I.tie(0);
    ll t,n,q,i,j,k;
    char ch;
    I >> ch;
    if (65 <= ch && ch <= 91)
        O << "A\n";
    else
        O << "a\n";
    return 0;
}

Measured memory_bytes: 3552
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        final double eps = 1e-10;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            Point a = new Point(sc.nextDouble(), sc.nextDouble());
            Point b = new Point(sc.nextDouble(), sc.nextDouble());
            Point c = new Point(sc.nextDouble(), sc.nextDouble());
            Point d = new Point(sc.nextDouble(), sc.nextDouble());
            System.out.println(Math.abs(cross(sub(a, b), sub(c, d))) < eps ? "YES" : "NO");
        }
    }

    static Point sub(Point a, Point b) {
        return new Point(b.x - a.x, b.y - a.y);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }
}

class Point {
    double x;
    double y;

    Point(double x, double y) {
        this.x = x;
        this.y = y;
    }
}



Measured memory_bytes: 30640
#include <stdio.h>

int main(){
  int a,b,x,y,r=1,gcd;

  scanf("%d%d",&x,&y);

  if(x-y >= 0){
    a=x;
    b=y;
  }
  else {
    b=x;
    a=y;
  }

  while(r!=0){
    r=a%b;
    a=b;
    b=r;
  }
  gcd=a;
  printf("%d\n",gcd);
  return 0;
}

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

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<int> r(M + 1, 0);

    for (int i = 0; i < N; ++i) {
        int K; cin >> K;
        for (int j = 0; j < K; ++j) {
            int tmp; 
            cin >> tmp;
            r[tmp]++;
        }
    }
    int res = 0;
    for (int i = 1; i <= M; ++i) {
        if (r[i]==N) ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
	for i in range(4):
		t = list(last4)
		if i >= 1:
			t[i-1], t[i] = t[i], t[i-1]
		if ''.join(t).count('AGC') >= 1:
			 return False
	return True

def dfs(cur, last3):
	if last3 in memo[cur]:
		 return memo[cur][last3]
	if cur == N:
		 return 1
	ret = 0
	for c in 'ACGT':
		 if ok(last3 + c):
			 ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
	memo[cur][last3] = ret
	return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define ll signed long long int
#define MAXX 1000005
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
 


signed main()
{
	FAST;
	ll n, t;
	cin >> n >> t;
	if(10-n <= 0){
		cout << t;
	}
	else{
		cout <<t+ 100*(10-n);
	}
	
	
	
}
		
		
	
	


Measured memory_bytes: 256
H,N=map(int,input().split())

A=[]
B=[]

for i in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

DP=[1000000000]*(H+max(A)+1)
DP[0]=0


for i in range(N):
    DP[A[i]]=B[i]

for i in range(N):
    for h in range(A[i],H+max(A)+1):
        DP[h]=min(DP[h-A[i]]+B[i],DP[h])

print(min(DP[H:]))

Measured memory_bytes: 41580
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back

using namespace std;
using ll = long long;


int main()
{
    Phuong_;
    ll n;
    cin >> n;
    if (n&1)
    {
        cout << 0;
        return 0;
    }
    n>>=1;
    ll sum=0;
    for(ll i=5; i<=n; i*=5)
        sum += (n/i);
    cout << sum;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
signed main() {
	int n, m, a[1234], b[1234];
	cin >> n; for (int i = 0; i < n; i++)cin >> a[i]; a[n] = -1;
	cin >> m; for (int i = 0; i < m; i++)cin >> b[i]; b[m] = -1;
	for (int i = 0; i <= n; i++) {
		if (a[i] != b[i]) {
			cout << (a[i] < b[i]) << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  char a;
  cin >> a;
  if ('a' <= a && a <= 'z')
    cout << 'a' << endl;
  else
    cout << 'A' << endl;

  return 0;
}


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

#ifdef local
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	long long a, b, x; scanf("%lld %lld %lld", &a, &b, &x);
	long long ans = b/x-a/x;
	if (a%x == 0) ++ans;
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200001];
long long ans;
int main()
{
	int n,i,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	m=(n-1)/2;
	for(i=n-2;i>=n-m-1;i--)
	ans+=a[i];
	ans=ans*2;
	ans+=a[n-1];
	if(n%2)
	printf("%lld",ans-a[n-m-1]);
	else
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 4500
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define lb lower_bound 
	#define ub upper_bound
	#define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define mi          map<int,int>
	#define mii         map<pi,int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define bs   binary_search
	#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 all(c) (c).begin(),(c).end()
	#define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
	
	 const int N =5e5+5;
	
	 int mod= 1e9+7;
	 int dx[4]={0,0,+1,-1};
	 int dy[4]={+1,-1,0,0};  
	 
	 
	int po(int a, int b) {
		a %= mod;
		int res = 1;
		while (b > 0) {
			if (b & 1)
				res = (res * a) % mod;
			a =(a*a) % mod;
			b >>= 1;
		}
		 return res;	
	   }
	   
	  set<int> st[26];

	 void solve() {	    
			int n,q;
			cin>>n;
			string s;
			cin>>s;
			
			rep(i,0,n) st[s[i]-'a'].insert(i);
			cin>>q;
			
			while(q--) {
				    int x,cnt=0;
				    char ch;
				    cin>>x;
				    if(x==1) {
						  int l;
						  cin>>l>>ch;
						  --l;
						  st[s[l]-'a'].erase(l);
						  s[l]=ch;
						  st[ch-'a'].insert(l);						  					  					   
						}
					else  {
						   int l,r;
						   cin>>l>>r;
						   --l;--r;
						   rep(i,0,26) {
							     if(*st[i].lb(l)<=r && st[i].lb(l)!=st[i].end())
							        cnt++;   
							 }
							 cout<<cnt<<endl;					   
						}	
				}			    	 
	        
	 }
	
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	   solve();
	   
	   
	   return 0;	   
}


Measured memory_bytes: 24220
#include <stdio.h>

int main () {
	int x, y;
	int sum, sub, mult;
	scanf("%d %d", &x, &y);
	sum = x + y;
	sub = x - y;
	mult = x * y;
	if (sum > sub && sum > mult) {
		printf("%d\n", sum);
	}
	else if (mult > sub && mult > sum) {
		printf("%d\n", mult);
	}
	else{
		printf("%d\n", sub);
	}
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;

ULL M = 1000000007;

ULL GCD(ULL a, ULL b) { return (b == 0) ? a : GCD(b, a % b); }

ULL powi(ULL b, ULL i) {
	if (i == 1) return b;
	ULL buf1 = powi(b, i / 2);
	buf1 = buf1 * buf1 % M;
	ULL buf2 = (i % 2) ? b : 1;
	return buf1 * buf2 % M;
}

void solve() {

	ULL h, w, t; cin >> h >> w >> t;
	ULL ty = GCD(h, t), th = h / ty;
	ULL tx = GCD(w, t), tw = w / tx;
	ULL tt = tx * ty;

	ULL per_e = 0;
	per_e += powi(2, th); per_e %= M;
	per_e += powi(2, tw) - 1; per_e %= M;
	ULL g = GCD(th, tw);
	per_e += powi(2, g) + (M - 2); per_e %= M;

	ULL ans = powi(per_e, tt);

	cout << ans << endl;
}

int main() {

	solve();

	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    map<ll, ll> m;
    m[a];
    m[b];
    m[c];
    cout << m.size() << endl;
}

Measured memory_bytes: 3608
unittest
{
	assert( [ "ABA" ].parse.expand.solve == "Yes" );
	assert( [ "BBA" ].parse.expand.solve == "Yes" );
	assert( [ "BBB" ].parse.expand.solve == "No" );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	return tuple( s );
}

auto solve( dchar[] s )
{
	s.sort();
	return ( s.front != s.back ) ? "Yes" : "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef vector<int> lnum;
const int base = 1000*1000*1000;
#define pb push_back
#define mp make_pair


const int mod = 1000 * 1000 * 1000 + 7;
const int INF = 1000 * 1000 * 1000;
const ll LINF = (ll)INF * INF;
int a[200001];
int main()
{
	//memset(dpT , -1 , sizeof dpT);
	ios_base::sync_with_stdio(0);
	//freopen("input.txt" , "r"  , stdin);
	int n;
	cin >> n;
	int Ans = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	if(a[0])
	{
		cout << -1;
		return 0;
	}
	for(int i = 1; i < n; i++)
	{
		if(a[i] - a[i - 1] > 1)
		{
			cout << -1;
			return 0;
		}
	}
	ll ans = 0;
	for(int i = n - 1; i > 0; i--)
	{
		if(a[i] - 1 != a[i - 1])
		{
			ans += a[i];
		}
		else
		{
			ans++;
		}
	}
	cout << ans;


}




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

int main() {
    int i, n, x;

    cin >> n;
    for(i=1; i<=n; ++i) {
        x = i;
        if(x % 3 == 0) {
            cout << ' ' << i;
            continue;
        }
        do {
            if(x % 10 == 3) {
                cout << ' ' << i;
                break;
            }
            x /= 10;
        } while(x);
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIII pair<int,pii>
#define PLL pair<ll,ll>
#define PLII pair<ll,pii>
#define VI vector<int>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define MX 100101
#define EPS 0.00000000001
#define MOD 1000000007
#define PI acos(-1)
#define INF 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

int p[MX],r[MX];

int findset(int i)
{
    if(i==p[i]) return i;
    else return p[i]=findset(p[i]);
}

void unionset(int a,int b)
{
    if(r[a]>r[b])
    {
        p[b]=a;
        r[a]+=r[b];
    }
    else
    {
        p[a]=b;
        r[b]+=r[a];
    }
}

int main()
{
    int n,m,k,a,b;
    cin>>n>>m>>k;

    int nf[n+1]={0};
    loop(i,1,n+1) {p[i] = i; r[i] = 1;}

    int u,v;
    loop(i,0,m)
    {
        cin>>u>>v;
        ++nf[u];
        ++nf[v];
        a = findset(u), b = findset(v);
        if(a != b) unionset(a,b);
    }

    int ans[n+1];

    loop(i,1,n+1)
    {
        a = findset(i);
        ans[i] = r[a]-nf[i]-1;
    }

    loop(i,0,k)
    {
        cin>>u>>v;
        a = findset(u), b = findset(v);
        if(a == b) --ans[u], --ans[v];
    }

    cout<<ans[1];
    loop(i,2,n+1) cout<<' '<<ans[i];
    cout<<'\n';

    return 0;
}


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

using vec = complex<double>;
using line = pair<vec,vec>;

double inner_product(vec u,vec v){
    return real(u*conj(v));
}
double cross_product(vec u,vec v){
    return imag(conj(u)*v);
}

double norm(vec& u){
    return abs(u);
}

vec projection(line l,vec p){//p???l???????°???±
    vec s=l.first, t=l.second;
    double k = inner_product(t-s,p-s)/inner_product(t-s,t-s);
    return (1.0-k)*s+k*t;
}

vec reflection(line l,vec p){
    return 2.0*projection(l,p)-p;
}


int main(void){
    int xp1,yp1,xp2,yp2;
    cin>>xp1>>yp1>>xp2>>yp2;
    line l(vec(xp1,yp1),vec(xp2,yp2));
    int q;
    cin>>q;
    cout<<fixed;
    cout.precision(10);
    for(int i=0;i<q;i++){
        int xp,yp;
        cin>>xp>>yp;
        vec X=reflection(l,vec(xp,yp));
        cout<<X.real()<<' '<<X.imag()<<endl;
    }

    return 0;
}

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

using namespace std;
using ll = long long int;

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

  while (true) {
    int n, k;
    cin >> n >> k;
    if (n == 0 && k == 0)
      break;
    vector<int> as(n);
    for (auto &a : as)
      cin >> a;

    vector<int> sums(n + 1, 0);
    for (int i = 0; i < n; i++) {
      sums[i + 1] = sums[i] + as[i];
    }

    int ans = -1e9;
    for (int i = 0; i + k <= n; i++) {
      ans = max(ans, sums[i + k] - sums[i]);
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3560
def main(n)
  cnt = 0
  for i in 1..n do
    d1, d2 = gets.split.map(&:to_i)
    if d1 != d2
      cnt = 0
      next
    end
    cnt += 1
    if cnt == 3
      return 'Yes'
    end
  end
  return 'No'
 end

if __FILE__ == $0
  n = gets.to_i
  ans = main(n)
  puts ans
end

Measured memory_bytes: 14364
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <stdio.h>
#include <math.h>
#include <utility>
#include <algorithm>
#include <sstream>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	if (a <= 5) {
		cout << 0;
	}
	else if (a <= 12) {
		cout << b / 2;
	}
	else {
		cout << b;
	}

	return 0;
}


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

using namespace std;

#define int long long

void solve()
{
    int n;cin>>n;
    int a[n];
    for(int i = 0 ; i < n ; i++)
        cin>>a[i];

    int dp[n];

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);


    for(int i = 2 ; i < n ; i++)
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]) , dp[i-2] + abs(a[i] - a[i-2]));

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



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


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

#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int main() {
    ll n, r, res;
    cin >> n >> r;
    if (n < 10) {
        res = 100 * (10 - n) + r;
    } else res = r;
    cout << res << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int count=0;
  for (int i=0; i<N ; i++) {
    if (i<N-1 && vec.at(i)>vec.at(i+1))
      count++;
  }
  cout << count+1 << endl;
}


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


int main(){
    int N ;
    cin >> N ;
    string S;
    cin >> S;
    int counter;
    counter =0;
    for(int i=2;i<N;i++){
        if (S.at(i) =='C' && S.at(i-1) =='B' && S.at(i-2) =='A'){
            counter++;
        }
    }
    
    cout << counter <<endl;
}


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

ll choose2(ll n) {
  return n*(n-1)/2;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> cnt(n);
  rep(i,n) cnt[a[i]]++;
  ll tot = 0;
  rep(i,n) {
    tot += choose2(cnt[i]);
  }
  rep(i,n) {
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

const ll INF = 1LL<<60;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, W;
    cin >> n >> W;
    vi w(n), v(n);
    rep(i, n) cin >> w[i] >> v[i];
    vvll dp(n+1, vll(100005, INF));
    rep(i, n+1) dp[i][0] = 0;
    rep(i, n) {
        rep(j, 100005) {
            chmin(dp[i+1][j], dp[i][j]);
            if (j - v[i] >= 0) chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
        }
    }
    int ans = 0;
    rep(j, 100005) if (dp[n][j] <= W) chmax(ans, j);
    cout << ans << endl;
}

Measured memory_bytes: 80256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner src = new Scanner(System.in);

		int n=Integer.parseInt(src.next());

		List<PointXY> list = new ArrayList<>();

		for (int i=0; i<n; i++) {
			list.add(new PointXY(Integer.parseInt(src.next()), Integer.parseInt(src.next())));
		}

		list.sort(Comparator.comparingInt(PointXY :: getX).thenComparingInt(PointXY :: getY));

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

			System.out.println(list.get(i).x + " " + list.get(i).y);

		}

	}
}


class PointXY{

	int x, y;

	PointXY(int a, int b){

		x = a;
		y = b;

	}

	int getX() {
		return x;
	}

	int getY() {
		return y;
	}
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

template <typename T>
void debug(vector<T> &vec) {
    for (auto x : vec) {
        cout << x << " ";
    }
    cout << endl;
    return;
}

template <typename T>
int getFormer(const vector<T> &vec, T x) {
    return upper_bound(vec.begin(), vec.end(), x) - vec.begin() - 1;
}

template <typename T>
int getLatter(const vector<T> &vec, T x) {
    return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}

int n;
vector<string> vec, ans;

void solve() {
    vec = vector<string> (n);
    REP(i, n) { cin >> vec[i]; }
    for (int i = 0; i < n; i++) {
        int j = 0;
        while (j < (int)vec[i].size() && vec[i][j] == '.') {
            vec[i][j] = ' ';
            j += 1;
        }
        if (j == 0) continue;
        j -= 1;
        vec[i][j] = '+';
        int tmp = i - 1;
        while (tmp >= 0 && j < (int)vec[i].size() && vec[tmp][j] == ' ') {
            vec[tmp][j] = '|';
            tmp -= 1;
        }
    }

    for (auto x : vec) {
        cout << x << endl;
    }
}

int main() {
    while (cin >> n && n) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3852
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef struct Edge{
    int to, cost;
} Edge;


typedef pair<int, int> P;
int n;
vector<string> in;
vector<P> nums;
vector<vector<Edge>> g;

void print(vector<Edge> &x) {
    int n = x.size();
    cout << "{";
    REP(i,n) {
        if (i != n-1) cout << x[i].to << " ";
        else cout << x[i].to;
    }
    cout<< "}" << endl;
}

int calc(int id, int sign) {
    // cout << "id = " << id << endl;
    // print(g[id]);
    if (g[id].size() == 0) {
        return (int)(in[id].back()-'0');
    }
    int ret = 0;
    if (sign == 11) ret = 1;
    for (auto &&e: g[id]) {
        if (sign == 10) {
            ret += calc(e.to, e.cost);
        }
        else if (sign == 11) {
            ret *= calc(e.to, e.cost);
        }
    }
    return ret;
}

// + = 10, * = 11

int main(int argc, char const *argv[]) {
    vector<int> ans;
    while (cin >> n, n) {
        in.resize(n);
        g.resize(n);
        REP(i,n) cin >> in[i];
        REP(i,n) {
            int cnt = in[i].size();
            if (in[i].back() != '+' && in[i].back() != '*') continue;
            for (int j = i+1; j < n; ++j) {
                if (in[j].size()-cnt == 1) {
                    Edge e;
                    e.to = j;
                    if (in[j].back() == '+') e.cost = 10;
                    else if (in[j].back() == '*') e.cost = 11;
                    else e.cost = in[j].back()-'0';
                    g[i].push_back(e);
                }
                else if (in[j].size() == cnt) break;
            }
        }
        int x;
        if (in[0][0] == '+') x = 10;
        else if (in[0][0] == '*') x = 11;
        else x = (int)in[0][0]-'0';
        cout << (calc(0, x)) << endl;
        in.clear();
        g.clear();
    }
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

vector<long> dic(100010);

void Initdic(){
  long tmp = 1;
  rep(i,100010){
    dic.at(i) = tmp;
    tmp = min(tmp*2, (long)1e14);
  }
}

int main(){
  Initdic();
  int n;
  cin >> n;
  vector<long> a(n+1);
  rep(i,n+1) cin >> a.at(i);
  if(n == 0){
    if(a.at(0) == 1) cout << 1 << endl;
    else cout << -1 << endl;
    return 0;
  }
  if(a.at(0) != 0){
    cout << -1 << endl;
    return 0;
  }
  vector<long> s(n+1);
  vector<long> t(n+1);
  vector<long> mini(n+1);
  vector<long> maxi(n+1);
  s.at(n) = a.at(n);
  t.at(n) = a.at(n);
  for(int i=n-1;i>=0;i--){
    s.at(i) = (s.at(i+1)+1)/2 + a.at(i);
    t.at(i) = t.at(i+1) + a.at(i);
  }
  mini.at(n) = a.at(n);
  rep(i,n){
    mini.at(i) = s.at(i) - a.at(i);
  }

  maxi.at(n) = a.at(n);
  for(int i=n-1;i>=0;i--){
    maxi.at(i) = min(dic.at(i)-a.at(i), t.at(i) - a.at(i));
  }

  for(int i=1;i<n;i++){
    maxi.at(i) = min(maxi.at(i), maxi.at(i-1)*2-a.at(i));
  }

  long sum = a.at(n);



  rep(i,n){
    sum += maxi.at(i) + a.at(i);
    //cout << maxi.at(i) << " " << t.at(i) << " " << a.at(i) << endl;
    if(maxi.at(i) < mini.at(i)){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 8008
from collections import deque

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

graph = [[] for _ in range(N + 1)]
for a, b in X:
    graph[a].append(b)
    graph[b].append(a)

# BFS
dist = [-1] * (N + 1)
dist[1] = 0
ans = [-1] * (N + 1)
q = deque([1])
while q:
    u = q.popleft()
    for v in graph[u]:
        if dist[v] >= 0:
            continue
            
        dist[v] = dist[u] + 1
        ans[v] = u
        q.append(v)

print("Yes")
print(*ans[2:], sep="\n")


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

using namespace std;

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  double diff = numeric_limits<double>::max();
  int answer = -1;
  for (int i = 1; i <= N; i++) {
    int H;
    cin >> H;
    double t = T - 0.006 * H;
    if (diff > abs(A - t)) {
      diff = abs(A - t);
      answer = i;
    }
  }
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a,b,c,n,i;

  n = 0;


        scanf("%d %d %d",&a,&b,&c);
  for(i=a; i<=b; i++)
        if(c % i == 0)
          n++;
           
  printf("%d\n",n);



return 0;
}


Measured memory_bytes: 2000
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int q[N],ans;
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&q[i]);
		ans+=abs(q[i]-q[i-1]);
	}
	ans+=abs(q[n]);
	for(int i=1;i<=n;i++){
		bool f1=(q[i]-q[i-1])<0,f2=(q[i+1]-q[i])<0;
		if(f1==f2)
			printf("%d\n",ans);
		else {
			int p1=abs(q[i+1]-q[i-1]),p2=abs(q[i]-q[i-1])+abs(q[i+1]-q[i]);
			printf("%d\n",ans-abs(p1-p2));
		}
		
	}
	return 0;
}

Measured memory_bytes: 1664
def find(x):
  if P[x] < 0:
    return x
  else:
    P[x] = find(P[x])
    return P[x]

N, M, *X = map(int,open(0).read().split())
P = [-1] * (N + 1)
S = N * (N - 1) // 2
r = [S]

while X:
  b, a = find(X.pop()), find(X.pop())
  if a != b:
    S -= P[a] * P[b]
    if P[a] > P[b]:
      a, b = b, a
    P[a] += P[b]
    P[b] = a
  r.append(S)

for a in r[-2::-1]:
  print(a)

Measured memory_bytes: 25332
#include <bits/stdc++.h>
using namespace std;
vector<int> v(3);

int main(void){
	cin >> v[0] >> v[1] >> v[2];
	int ret = 0;
	do{
		for(auto i: v){
			ret = max(ret, v[0] * 10 + v[1] + v[2]);
			ret = max(ret, v[0] + v[1] * 10 + v[2]);
		}
	}while(next_permutation(v.begin(), v.end()));
	cout << ret << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        r = n % k
        if abs(r-k) < r:
            r = abs(r-k)

    print(r)
    
__main__()

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

string S;

int check(string first) {
    int ret = 1;
    string tmp = first;
    for (int i = first.length(); i < S.length(); i++) {
        if (tmp == S.substr(i, 1)) {
            if (i >= S.length() - 1) {
                ret = -1;
            }
            else {
                tmp = S.substr(i, 2);
                i++;
                ret++;
            }
        }
        else {
            if (i == S.length() - 2 && S[i] == S[i+1]) {
                tmp = S.substr(i, 2);
                i++;
                ret++;
            }
            else {
                tmp = S.substr(i, 1);
                ret++;
            }
        }
    }
    return ret;
}

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

    int ans1 = check(S.substr(0, 1));
    int ans2 = -1;
    if (S.length() > 1) {
        ans2 = check(S.substr(0, 2));
    }

    cout << max(ans1, ans2) << endl;

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
char s[1010][20];
int l[1010],r[1010];
int main()
{
    int n,m;
    while (scanf("%d%d",&n,&m)==2)
    {
        if (n==0&&m==0) break;
        for (int i=0;i<n;i++)
        {
            scanf("%s",s[i]);
            scanf("%d%d",&l[i],&r[i]);
            l[i]=r[i]-l[i]+1;
        }
        while (m--)
        {
            bool sol=false;
            int x,id=0,cnt=0;
            scanf("%d",&x);
            for (int i=0;i<n;i++)
            {
                if (l[i]<=x&&r[i]>=x)
                {
                    id=i;
                    cnt++;
                    sol=true;
                }
            }
            if (!sol||cnt>1) puts("Unknown");
            else
                printf("%s %d\n",s[id],x-l[id]+1);
        }
    }
    return 0;
}

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

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s ;
    cin >> s;

    int a = 0 , b = 0 , c = 0 ;
    for(char x : s){
        if (x == 'a'){
            ++a; 
        }
        else if (x == 'b'){
            ++b;
        }
        else {
            ++c; 
        }
    }

    if (max({a,b,c}) - min({a,b,c}) <= 1){
        cout << "YES" << "\n";
    }
    else {
        cout << "NO" <<"\n";
    }

    
  
    return 0;
}



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

#define rep(i,a,b) for(long long i = a; i < b; i++)
#define dump(a) for(auto x : a) cout << x << " "; cout << "\n"
#define print(a) cout << a << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr << #x << ": " << x << ", " << #y << ": " << y << "\n"
#define debug3(x,y,z) std::cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << "\n"

typedef long long ll;
using vi   = vector<int>;
using vll  = vector<long long>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vvs  = vector<vector<string>>;

ll ttl = 0;
int n,m,q;

void dfs(vi a, vvi abcd, int now) {
  if (now < 0) {
    ll tmp_ttl = 0;
    rep(i,0,q) {
      if (a[abcd[i][1] - 1] - a[abcd[i][0] - 1] == abcd[i][2]) {
        tmp_ttl += abcd[i][3];
      }
    }
    ttl = max(ttl,tmp_ttl);
  } else {
    rep(i,a[now],m + 1) {
      a[now] = i;
      if (a[now] > a[now + 1]) break;
      dfs (a,abcd,now - 1);
    }
  }
}

int main() {
  cin >> n >> m >> q;
  vvi abcd(q,vi(4));
  
  rep(i,0,q) rep(j,0,4) {
    int tmp;
    cin >> tmp;
    abcd[i][j] = tmp;
  }
  vi a(n + 1,1); 
  a[n] = m; // 末尾に番兵
  
  dfs(a,abcd,n - 1);
  print(ttl);
  return 0;
}

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

int main()
{

	int N = 0, T = 0;
	const int imax = 1000;
	int A[2][imax] = {};
	
	cin >> N >> T;

	for (int i = 0; i < N; i++) {
		cin >> A[0][i] >> A[1][i];
	}

	int best=-1;
	int c = 0;
	while (best==-1){
		if (A[1][c] <= T) {
			best = A[0][c];

		}
		c++;
	
		if (c > N) {
			cout << "TLE\n";
			best = -2;
		}
	}
	 

	
	if (best != -2) {
		while (c < N) {
			if (A[0][c] < best && A[1][c]<=T) {
				best = A[0][c];
			}
			c++;
		}

		cout << best <<"\n";
	}	
	
	
	return 0;
}

Measured memory_bytes: 256
from math import factorial

n, m = map(int, input().split())

if n > 2 and m > 2:
    print(
        factorial(n) // (factorial(n - 2) * factorial(2))
        + factorial(m) // (factorial(m - 2) * factorial(2))
    )
elif n < 2 and m < 2:
    print(0)
elif n < 2:
    print(factorial(m) // (factorial(m - 2) * factorial(2)))
elif m < 2:
    print(factorial(n) // (factorial(n - 2) * factorial(2)))


Measured memory_bytes: 3060
use std::cmp::min;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.chars();
    let zero = s.iter().filter(|&&c| c == '0').count();
    let ans = min(s.len() - zero, zero);

    println!("{}", ans * 2);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2736
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000000ll
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;
    cin>>n;
    vll a(n);
    rep(i,n)cin>>a[i];
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
    }
    ll ans=0;
    rep(i,n){
        sum-=a[i];
        sum%=1000000007;
        ans+=sum*a[i];
        sum+=1000000007;
        ans%=1000000007;
    }

    cout<<ans<<endl;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  int n;
  cin >> n;
  cout << 800*n-n/15*200 << endl;
  return 0;
}


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

int main() {
  string s,t;
  cin >> s >> t;
  int S = s.size();
  int T = t.size();
  int mx = 0;
  for (int i=0;i<T;i++){
    for (int a=i;a<S-T+i+1;a++){
      if (t.at(i)==s.at(a)){
        int count = 0;
        for (int b=0;b<T-i;b++){
          if (t.at(i+b)==s.at(a+b)){
            count++;
          }
        }
        if (count > mx) mx = count;
      }
    }
  }
  cout << T-mx <<endl;
 
}


Measured memory_bytes: 3632
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            double[] input = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            double T = input[0];
            double X = input[1];
            Console.WriteLine(T / X);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int x,y,z,ans;
int main()
{
	scanf("%d%d%d",&x,&y,&z);
	ans = floor((x-z)/(y+z));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
qs = gets.split(' ').map(&:to_i)
x = []
s = gets.to_s.chomp.split("")
qs[1].times { |q| x << gets.split(' ').map(&:to_i) }
num = []
count = 0
s.each_with_index do |string, i|
    if i == 0
        num << 0
        next
    end
    if s[i-1] == 'A' and s[i] == 'C'
        count += 1
    end
    num << count
end
x.each do |q|
    ans = num[q[1]-1] - num[q[0]-1]
    puts ans
end


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

typedef long long int ll;

ll absl(ll n)
{
	if(n<0)
	{
		return -1*n;
	}
	return n;
}
int main()
{
	ll n,i,h;
	cin>>n;
	ll dp1,dp2,f,s;
	cin>>f;
	cin>>s;
	ll mini=absl(f-s);
	dp1=0;
	dp2=mini;
	for(i=2;i<n;i++)
	{
		cin>>h;
		ll t=dp1;
		dp1=dp2;
		dp2=min(t+absl(h-f),dp2+absl(h-s));
		f=s;
		s=h;
	}
	cout<<dp2<<'\n';
}


Measured memory_bytes: 256
size = list(map(int,raw_input().split()))

large_pic=[]
small_pic=[]
for i in range (size[0]):
    large_pic.append (list(raw_input().strip()))
for i in range (size[1]):
    small_pic.append (list(raw_input().strip()))


flag = False
cut_pic = []
for i in range (size[0]-size[1]+1):
    for j in range (size[0]-size[1]+1):
        for k in range (size[1]):
            cut_pic.append(large_pic[i+k][j:j+size[1]])
        if cut_pic == small_pic:
            flag = True
        else:
            cut_pic =[]
print "Yes" if flag == True else "No"


Measured memory_bytes: 2692
n = int(input())

mod = 10**9+7

sosu = [1] * 1001

for j in range(2,n+1):
    tmp = j
    i = 2
    while tmp > 1:
        if tmp % i == 0:
            sosu[i] += 1
            tmp = tmp // i
        else:
            i += 1
        
#print(sosu)
sosu.sort(reverse=True)

ans = 1

for i in range(len(sosu)):
    if sosu[i] > 1:
        ans = ans*sosu[i] % mod
        
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>

using namespace std;

struct Island {
    bool fr, to;
};

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

    vector<Island> island(N);
    for (int i = 0; i < N; i++) {
        island[i].fr = false;
        island[i].to = false;
    }

    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b; a--; b--;
        if (a == 0) island[b].fr = true;
        if (b == 0) island[a].fr = true;
        if (a == N - 1) island[b].to = true;
        if (b == N - 1) island[a].to = true;
    }

    bool ans = false;
    for (int i = 0; i < N; i++) {
        if (island[i].fr && island[i].to) ans = true;
    }

    if (ans) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 640
import bisect

N = int(input())
nums = list(map(int, input().split()))
nums.sort()
ans = 0
for a in range(N - 2):
    for b in range(a + 1, N - 1):
        ind = bisect.bisect_left(nums, nums[a] + nums[b])
        ans += ind - 1 - b
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }

  sort(A.begin(), A.end(), greater<int>());
  double L = double(sum) / 4.0 / double(M);
  if (double(A.at(M - 1)) >= L) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int main(){
  int n,d;
  int cnt=0;
  double sum=0;
  cin >> n >> d;
  vector<vector<int>> a(n,vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> a[i][j];
    }
  }
  for(int k=0;k<n-1;k++){
    for(int i=k+1;i<n;i++){
      sum=0;
      for(int j=0;j<d;j++){
      sum += (a[k][j]-a[i][j])*(a[k][j]-a[i][j]);
        }
      if(floor(sqrt(sum))==sqrt(sum)){
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int main() {
	int N, K;
	scanf("%d %d", &N, &K);
	return !printf("%d\n", !!(N%K));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

////////////////////////////////////////////////////////////////////i

int n,l,a[110000];
signed main(){
  cin>>n>>l;rep(i,n)cin>>a[i];
  rep(i,n-1){
    if(a[i]+a[i+1] < l)continue;
    cout << "Possible" << endl;
    repd(j,1,i+1){
      cout << j << endl;
    }
    rep(j, n-i-1){
      cout << n-j-1 << endl;
    }
    return 0;
  }

  cout << "Impossible" << endl;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ll N,x; cin >> N >> x;
    ll eat=0;
    vector<ll> a(N);
    for (int i=0;i<N;i++) 
    {
        cin >> a[i];
        if (a[i]>x)
        {
            eat+=a[i]-x;
            a[i]=x;
        }
    }
    ll over=0;
    for (int i=0;i<N-1;i++)
    {
        over=0;
        if (a[i]+a[i+1]>x)
        {
            over=a[i]+a[i+1]-x;
            a[i+1]-=over;
            eat+=over;
        }
    }
cout << eat << endl;
return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
long i,n,n2,f;
while(cin>>n){
i=2;
while(n==0){cin>>n;i++;}
if(i==9)f=2;
else{
cin>>n2;
if(n2==0)f=2;
else if(n2==n){if(n%11==0)f=0;else f=1;}
else if(n2==n*11)f=3;
else if(n2==n/10)f=4;
else if(n2==n*10)f=6;
else f=5;
for(;i<8;i++)cin>>n;
}
cout<<"ABCDEFG"[f]<<endl;
}
return 0;
}

Measured memory_bytes: 1152