akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    ll a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+') {
        cout << a + b << endl;
    }
    else {
        cout << a - b << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep0(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
#define re return
#define mp map<int,int>
#define N 200005
#define pql priority_queue<ll>
#define all(v) (v).begin(),(v).end()
using namespace std;
int k,a[N],n,ans;
int main() {
	cin>>n>>k;
	while(n!=0) {
		n/=k;
		ans++;
	}
	cout<<ans;
	re 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)

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

Measured memory_bytes: 3132
input_list = input().split()
a, b, c = map(int, input_list)
if a <= b and b <= c:
    print(str(a) + " " + str(b) + " " + str(c))
elif a <= c and c <= b:
    print(str(a) + " " + str(c) + " " + str(b))
elif b <= a and a <= c:
    print(str(b) + " " + str(a) + " " + str(c))
elif b <= c and c <= a:
    print(str(b) + " " + str(c) + " " + str(a))
elif c <= a and a <= b:
    print(str(c) + " " + str(a) + " " + str(b))
else:
    print(str(c) + " " + str(b) + " " + str(a))


Measured memory_bytes: 5604
N = int(input())
*X, = map(int, input().split())

mn = min(X)
mx = max(X)

ans = []
hps = []
for i in range(mx + 1):
    for x in X:
        hps.append((x - i) ** 2)
    ans.append(sum(hps))
    hps = []

print(min(ans))


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c, d;
  cin >> a;
  cin >> b;
  cin >> c;
  cin >> d;
  cout << min(a, b) + min(c, d) << endl;

  return 0;
}

Measured memory_bytes: 256
import collections

ORD_A = ord("a")


def count_chars(s):
    counter = [0 for _ in range(26)]
    for c in s:
        counter[ord(c) - ORD_A] += 1

    return counter


def main():
    n = int(input())

    anagram_counter = collections.Counter(tuple(count_chars(input())) for _ in range(n))

    s = 0
    for v in anagram_counter.values():
        s += v * (v - 1) // 2

    print(s)


if __name__ == "__main__":
    main()


Measured memory_bytes: 36184
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    struct Point {
        double x, y, rad;
    };

    const double PI = acos(-1);
    vector<Point> points(N);
    for (Point &p : points) {
        cin >> p.x >> p.y;
        p.rad = atan2(p.y, p.x);
    }

    sort(points.begin(), points.end(), [](Point &lhs, Point &rhs) {
        return lhs.rad < rhs.rad;
    });

    double ans = 0;
    for (ll i = 0; i < N; i++) {
        for (ll j = 1; j <= N; j++) {
            //iからj個使う
            double x = 0, y = 0;

            for (ll k = 0; k < j; k++) {
                x += points[(i + k) % N].x;
                y += points[(i + k) % N].y;
            }

            double curr = sqrt(pow(x, 2) + pow(y, 2));
            ans = max(ans, curr);
        }
 }

    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 384
#include<stdio.h>
#define M 100000

int parent(int i){
  return i/2;
}
int right(int i){
  return i*2+1;
}
int left(int i){
  return i*2;
}
int main(){
  int H,i;
  int A[M+1];
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }

  for(i= 1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i)  <= H)printf("left key = %d, ",A[left(i)]);
    if(right(i)  <= H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



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

int main(void){
  string s;
  int i, j, k, max = 0;

  cin >> s;

  for(i=0;i<s.size();i++){
    for(j=i;j<s.size();j++){
      for(k=i;k<=j;k++){
        if(s[k]!='A'&&s[k]!='T'&&s[k]!='C'&&s[k]!='G'){
          break;
        }
      }
      if(k==j+1&&max<(j-i+1))max = j - i + 1;
    }
  }

  cout << max << endl;

  return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

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

  rep(i, n) {
    if(i + 2 < n && s[i] == s[i + 2]) {
      cout << i + 1 << " " << i + 3 << endl;
      exit(0);
    }
    if(i + 1 < n && s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      exit(0);
    }
  }

  cout << "-1 -1" << endl;
  
  return 0;
}

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

using namespace std;

int main(void) {
	int N,x;
	cin >> N >> x;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	long long res = 0;
	for (int i = 0; i < N-1; ++i) {
		if (a[i]+a[i+1] > x) {
			int temp = (a[i] + a[i+1]) - x;
			res += temp;
			if (a[i+1] > temp) {
				a[i+1] -= temp;
			}
			else {
				a[i+1] = 0;
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#define MOD 1000000007LL
using namespace std;

int main(){
	int n, k;
    cin >> n >> k;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin >> x;
		ans += (2 * min(x, k-x));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> 

using namespace std;


int main() {
    int n;
    int r;
    char a[52];
    int b[52];
    int S[13] = {0};
    int H[13] = {0};
    int C[13] = {0};
    int D[13] = {0};

    cin >> n;
    for (int x = 0; x < n; x++){
        cin >> a[x] >> b[x];
        r = b[x] - 1;
        switch(a[x]){
            case 'S':
                S[r] = 1;
            break;
            case 'H':
                H[r] = 1;
            break;
            case 'C':
                C[r] = 1;
            break;
            case 'D':
                D[r] = 1;
            break;
        }
    }

    for (int x = 0; x < 4; ++x){
        for (int y = 0; y < 13; ++y){
        switch(x){
            case 0:
               if (S[y] == 0){
                   cout << "S " << y+1 << endl;
               }
            break;
            case 1:
               if (H[y] == 0){
                   cout << "H " << y+1 << endl;
               }
            break;
            case 2:
               if (C[y] == 0){
                   cout << "C " << y+1 << endl;
               }
            break;
            case 3:
               if (D[y] == 0){
                   cout << "D " << y+1 << endl;
               }
            break;
        }

        }
    }
    return 0;
}



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

bool isOK(int n) {
	bool res = true;
	int k = n % 10;
	n /= 10;
	while (n) {
		if (n % 10 != k - 1) {
			res = false;
			break;
		}
		k--;
		n /= 10;
	}
	return res;
}

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int res = -1;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			if (isOK(a[i] * a[j])) {
				res = max(res, a[i] * a[j]);
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3076
/*****************************************************

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

#include<bits/stdc++.h>
#define MAX 9223372036854775807
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ppf pop_front
#define mp make_pair
#define ip pair<int, int>

#define loop(i,n) for(int i=0;i<n;i++)
#define fast ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
using namespace std;

const ll MOD = 1e9+7;
const ll SZ = 107;
const ll N = 1e6+1;
const ll inf = 1e8;

int pwr(int x, int y)
{
    ll r = 1LL;
    while(y)
    {
        if(y&1)
            r = (r * x) % MOD;
        y >>= 1;
        x = (x * x) % MOD;
    }
    return r % MOD;
}

int inv(int x)
{
    return pwr(x, MOD-2);
}

void solve()
{
    int n; cin>>n;
    int d[n];
    for(int i=0;i<n;i++)
        cin>>d[i];
    int cur= 0;
    for(int i=0;i<n;i++)
    {
        cur = d[i]-cur;
    }
    int a[n];
    a[0] = cur;
    for(int i=1;i<n;i++)
        a[i] = 2*d[i-1]-a[i-1];
    for(int i=0;i<n;i++)
        cout<<a[i]<<" ";

}

signed main()
{
// #ifndef ONLINE_JUDGE
//     freopen("ladders_and_snakes_sample_input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    
    int t=1;
    // cin >>t;
    for(int tt=1;tt<=t;tt++){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }
    return 0;
}

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


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

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << (a < 6 ? 0 : a < 13 ? b / 2 : b) << endl;

    return 0;
}

Measured memory_bytes: 256
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n,m,q = ma()
L_rs=[[] for i in range(n)]
for i in range(m):
    l,r=ma()
    L_rs[l-1].append(r-1)
for i in range(n):
    L_rs[i].sort()
# print(L_rs)
def isok(num,val):##適宜変更
    return num<=val
def bisect(ls,val): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1,Trueならlen(ls)-1
    ok = -1
    ng = len(ls)
    x = (ok+ng)//2
    while ng-ok>1:
        num = ls[x]
        if isok(num,val):
            ok = x
        else:
            ng = x
        x = (ok+ng)//2
    return ok ##一番右のTrueのindex  Trueの個数はok+1こ

ans = [[0]*(n+1) for i in range(n+1)]
for r in range(n):
    for l in range(r,-1,-1):
        ans[l][r]=ans[l+1][r] + bisect(L_rs[l],r)+1

for i in range(q):
    l,r=ma()
    print(ans[l-1][r-1])


Measured memory_bytes: 91912
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int INF = 1 << 30;
const double EPS = 1e-9;

int n, m, p, a, b;
int t[8];
double dp[1 << 8][30];
int dis[30][30];

int main(){
	while(cin >> n >> m >> p >> a >> b && (n || m || p || a || b)){
		a--, b--;
		fill(&dis[0][0], &dis[29][29]+1, INF);
		fill(&dp[0][0], &dp[(1 << 8)-1][29] + 1, 1e10);
		for(int i = 0; i < n; i++) cin >> t[i];
		for(int i = 0; i < p; i++){
			int x, y, z;
			cin >> x >> y >> z;
			x--, y--;
			dis[x][y] = dis[y][x] = z;
		}

		dp[(1 << n)-1][a] = 0;
		for(int S = (1 << n) - 1; S >= 0; S--){
			for(int v = 0; v < m; v++){
				if(dp[S][v] != 1e10){
					for(int j = 0; j < n; j++){
						if(S >> j & 1){
							int s2 = S & ~(1 << j);
							for(int u = 0; u < m; u++){
								if(dis[u][v] == INF) continue;
								if(dp[s2][u] > dp[S][v] + (double)dis[u][v] / t[j]){
									dp[s2][u] = dp[S][v] + (double)dis[u][v] / t[j];
								}
							}
						}
					}
				}
			}
		}
		double res = 1e10;
		for(int i = 0; i < (1 << n); i++){
			res = min(res, dp[i][b]);
		}
		if(res == 1e10) cout << "Impossible" << endl;
		else cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 992
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, i, j, k;
	char ch;
	bool valid = false;
	cin >> n;
	while (n--) {
		cin >> ch;
		if (ch == 'Y') valid = true;
	}
	if (valid) cout << "Four\n";
	else cout << "Three\n";

	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
H=[]
for i in range(n-1):
    if h[i+1] <= h[i]:
        H.append('a')
    else:
        H.append('b')
s=''.join(H)
t=s.split('b')
ans=max(len(u) for u in t)
print(ans)

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

int main() {
    int N ,K;
    cin >> N >> K;
    long long int x[N];
    for (int i=0; i<N; i++) cin >> x[i];
    long long int cnt=1000000000;
    for (int i=0; i<N-K+1; i++){
        if (x[i+K-1]<=0) cnt=min (cnt, -x[i]);
        else if (x[i]<=0 && x[i+K-1]>0) cnt =min(cnt, min(-x[i], x[i+K-1])+x[i+K-1]-x[i]);
        else cnt=min (cnt, x[i+K-1]);
    }
    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	int a,b;
	scanf("%d%d",&a,&b);
	int max = a;
	int min = b;
	if ( max < b){
		max = b;
		min = a;
	}
	int ans = max + (max-1);
	if(ans<(max+min)){
		ans = max+min;
	}
	printf("%d",ans);
	return 0;
}

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

int top,S[1000];

void push(int x){
	top++;
	S[top] = x;
}

int pop(){


	top--;
	
	return S[top+1];

}


int main(){

char s[100];
int a,b,top=0;


while(scanf("%s",s) != -1){
	if(s[0] == '+'){
		a = pop();
		b = pop();
		push(a+b);
	}

	else if(s[0] == '-'){
		a = pop();
		b = pop();
		push(b-a);
	}

	else if(s[0] == '*'){
		a = pop();
		b = pop();
		push(a*b);
	}
	else push(atoi(s));
}
printf("%d\n",pop());

return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9+7;
const int MOD2 = 1e9 + 9;
const int INF = 5e18;
 
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
 
 
inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}
 
int exp(int a, int b){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = result*a;
 
        b >>= 1;
        a = a*a;
    }
    return result;
}

void solve(){
    int n = 100;
    int x; cin>>x;
    int anos = 0;
    while(n<x){
        n*=1.01;
        anos++;
    }
    cout<<anos<<endl;
}
 
main(){
    fastio; 
    int x=0;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll N; cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans += N/i * (N/i + 1) /2 * i;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }


int main() {
	int H, i, A[MAX+1]; //1-オリジンのため +1 する
	
	cin >> H;
	for ( i = 1; i <= H; i++ ) cin >> A[i];
	
	for ( i = 1; i <= H; i++ ) {
		cout << "node " << i << ": key = " << A[i] << ", ";
		if ( parent(i) >= 1 ) cout << "parent key = " << A[parent(i)] << ", ";
		if ( left(i) <= H ) cout << "left key = " << A[left(i)] << ", ";
		if ( right(i) <= H ) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
// Choose unvisited x and visited y as minimum vertex cover
// Also, Maximum Independent Set is the complement set of minimum vertex cover
template<int SZX,int SZY> struct BIPARTITE_MATCHING{
	int mx[SZX+1],my[SZY+1],lev[SZX+1],visx[SZX+1],visy[SZY+1];
	vector<int> e[SZX+1];
	bool dfs(int x){
		for(int y:e[x]){
			int w=my[y];
			if(w==-1||(lev[w]==lev[x]+1&&dfs(w)))
				return mx[x]=y,my[y]=x,true;
		}
		return lev[x]=-1,false;
	}
	void clear(int m){for(int i=0;i<=m;i++)	vector<int>().swap(e[i]);}
	void addedge(int x,int y){e[x].emplace_back(y);}
	int matching(int m,int n){
		fill(mx,mx+m+1,-1),fill(my,my+n+1,-1);
		for(int res=0;;){
			queue<int> q;
			for(int i=0;i<m;i++)
				if(mx[i]==-1)	q.emplace(i),lev[i]=0;
				else	lev[i]=-1;
			while(!q.empty()){
				int x=q.front();q.pop();
				for(int y:e[x]){
					int w=my[y];
					if(w!=-1&&lev[w]==-1)
						q.emplace(w),lev[w]=lev[x]+1;
				}
			}
			int delta=0;
			for(int i=0;i<m;i++)
				if(mx[i]==-1&&dfs(i))
					delta++;
			if(delta)	res+=delta;
			else	return res;
		}
		return 0;
	}
	int cover(int m,int n){
		int res=matching(m,n);
		fill(visx+1,visx+m+1,0), fill(visy+1,visy+n+1,0);
		queue<int> q;
		for(int i=1;i<=m;i++)	if(mx[i]==-1)	q.emplace(i),visx[i]=true;
		while(!q.empty()){
			int x=q.front();q.pop();
			for(int y:e[x]){
				visy[y]=true;
				int w=my[y];
				if(!visx[w])	q.emplace(w),visx[w]=true;
			}
		}
		return res;
	}
};
BIPARTITE_MATCHING<100,100> DS;

int a[100][100];
int used[100][100];
int mat[100][100];
int ans[100][100];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++){
			cin>>a[i][j],a[i][j]--;
		}
	memset(used,-1,sizeof used);
	for(int c=0;c<m;c++){
		DS.clear(n);
		memset(mat,-1,sizeof mat);
		for(int i=0;i<n;i++)
			for(int j=0;j<m;j++){
				int color = a[i][j]/m;
				if(used[i][j]==-1&&mat[i][color]==-1)
					DS.addedge(i,color),mat[i][color]=j;
			}
		DS.matching(n,n);
		for(int i=0;i<n;i++)
			used[i][mat[i][DS.mx[i]]]=c;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			ans[i][used[i][j]]=a[i][j];
	for(int i=0;i<n;i++,cout<<'\n')
		for(int j=0;j<m;j++)
			cout<<' '<<ans[i][j]+1;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			a[ans[i][j]/m][j]=ans[i][j];
	for(int i=0;i<n;i++,cout<<'\n')
		for(int j=0;j<m;j++)
			cout<<' '<<a[i][j]+1;
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int n ,i,DP[101][101],num,p,k;
        cin>>n;
    for(i=0;i<n;i++){
    for(int j=0;j<n;j++){
        DP[i+1][j+1]=0;
    }
    }

    for(i=0;i<n;i++){
    cin>>p;
    cin>>num;
    for(int j=0;j<num;j++){
        cin>>k;
        DP[p][k]=1;
    }
    }
for(i=0;i<n;i++){
    for(int j=0;j<n;j++){
        
        if(j==n-1){
         cout<<DP[i+1][j+1]<<endl;  
        }
        else cout<<DP[i+1][j+1]<<" ";
    }
}
}



Measured memory_bytes: 3116
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()

ans = 0
k = 1
for i in range(60):
    s = 0
    t = 0
    for j in range(n):
        if a[j] % 2 == 0:
            s += 1
        else:
            t += 1
        a[j] //= 2
    ans = ( ans + s * t * k ) % ( 10**9 + 7 )
    k *= 2
print(ans)

Measured memory_bytes: 125656
N,K=map(int,input().split())
H=[]
a=10**9
for i in range(N):
    h=int(input())
    H.append(h)
H.sort()
for i in range(N-K+1):
    b=H[i+K-1]-H[i]
    if a>b:
        a=b
print(a)

Measured memory_bytes: 7384
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define vl vector<ll>
#define pll pair<ll,ll>

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  ll MOD = 1e9+7;
  ll n;
  cin >> n;
  vl a(n);
  REP(i,n) cin >> a[i];
  vl ac(n);
  ac[n-1] = a[n-1];
  FOR(i,1,n) ac[n-1-i] = ac[n-i]+a[n-1-i];
  REP(i,n) ac[i] %= MOD;
  ll ans = 0;
  REP(i,n-1){
    ll tmp = a[i] * ac[i+1] % MOD;
    ans += tmp;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6420
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    _ = readint()
    c = readstr()
    '''
    WRWR -> RRWW
    RWRR -> RRRR
    WWWRR -> RRWWW
    WRWWR -> RRWWW
    WWRRWRRR -> RRRRRWWW
    WRRRWRRR

    c[:rc]までをすべてRにすればよい

    '''
    rc = c.count('R')
    print(c[:rc].count('W'))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9420
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

constexpr int MOD = 1000000007;

// + - * / ^
int mod(int a)
{
    int res = a % MOD;
    if(res < 0) {
        return res + MOD;
    }
    return res;
}
int mul_mod(int a, int b)
{
    ll res = ((ll)a * (ll)b) % MOD;
    return mod((int)res);
}
int pow_mod(int a, int b)
{
    ll res = 1;
    while (b > 0) {
        if(b & 1) {
            res = res * (ll)a % (ll)MOD;
        }
        a = mul_mod(a, a);
        b >>= 1;
    }
    return (int)res;
}
int inv_mod(int a)
{
    return pow_mod(a, MOD - 2);
}
int div_mod(int a, int b)
{
    return mul_mod(a, inv_mod(b));
}

// ! C
constexpr int FAC_MAX = 200001;
ll fac[FAC_MAX], finv[FAC_MAX], inv[FAC_MAX];
void com_init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < FAC_MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll com_mod(int a, int b){
    if (a < b) return 0;
    if (a < 0 || b < 0) return 0;
    return fac[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    rep (i, n) cin >> x[i];
    com_init();
    int k = fac[n - 1], l = 1, ans = 0;
    rep (i, n - 1) {
        ans = mod(ans + mul_mod(k, (x[i + 1] - x[i])));
        eprintf("%d ", k);
        l++;
        k = mod(k + div_mod(fac[n - 1], l));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5376
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
S = input()
score = 0
for i in range(N - 1):
    if S[i + 1] == S[i]:
        score += 1
score = min(score + 2 * K, N - 1)

print(score)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(ll i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
struct UnionFind {
    vector<ll> par;
 
    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }
 
    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
 
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
 
    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
 
    ll size(ll x) {
        return -par[root(x)];
    }
};
 
int main() {
    int N; cin >> N;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    vector<ll> s(N+1, 0);
    rep(i,N) s[i+1] = s[i] + a[i];
  	map<ll, ll> nums;
  	rep(i,N+1){
      ++nums[s[i]];
    }
  	ll ans = 0;
  	for (auto it = nums.begin(); it != nums.end(); ++it) {
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
  	
}

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

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



Measured memory_bytes: 3084
import sys

n = input()
a = [] 
flag = {}
for j in range(1, 14):
    flag[('S',j)] = 0
    flag[('H',j)] = 0
    flag[('C',j)] = 0
    flag[('D',j)] = 0

for i in range(n):
    temp = map(str, raw_input().split())
    a.append((temp[0],temp[1]))
    #print a[i][0]
    #print a[i][1]

card = ['S', 'H', 'C', 'D']
#print card

for egara in card:
    for i in range(n):
        if(a[i][0] == egara):
            for j in range(1,14):
                if(int(a[i][1]) == j):
                    flag[(egara, j)] = 1

for egara in card:
    for j in range(1,14):
        if(flag[(egara, j)] == 0):
            sys.stdout.write(egara)
            sys.stdout.write(' ')
            sys.stdout.write(str(j))
            print

exit(0)

Measured memory_bytes: 4272
/*
██╗  ██╗ █████╗ ██████╗ ███████╗███████╗███╗   ███╗        ██╗  ██╗██╗  ██╗ █████╗ ██╗     ███████╗██████╗
██║ ██╔╝██╔══██╗██╔══██╗██╔════╝██╔════╝████╗ ████║        ██║ ██╔╝██║  ██║██╔══██╗██║     ██╔════╝██╔══██╗
█████╔╝ ███████║██████╔╝█████╗  █████╗  ██╔████╔██║        █████╔╝ ███████║███████║██║     █████╗  ██║  ██║
██╔═██╗ ██╔══██║██╔══██╗██╔══╝  ██╔══╝  ██║╚██╔╝██║        ██╔═██╗ ██╔══██║██╔══██║██║     ██╔══╝  ██║  ██║
██║  ██╗██║  ██║██║  ██║███████╗███████╗██║ ╚═╝ ██║███████╗██║  ██╗██║  ██║██║  ██║███████╗███████╗██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═╝     ╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚══════╝╚═════╝
Believe in yourself ,( try and try and then try ), You can do it 💗
*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#define endl "\n"
#define Ceil(x,y) ((x+y-1)/y)
#define clr(arr, x) memset(arr, x, sizeof arr)
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define rt(s) return cout<<s,0
#define watch(x) cout<<(#x)<<" = "<<x<<endl
#define sz(s)	(int)(s.size())
#define OO 0x3f3f3f3f3f3f3f3fLL
const int oo = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//x = xDegrees*3.14159265 / 180;
//ef1tn=(( (n / 2)*( (n / 2) + 1) / 2) * 2);
//of1tn=(n * (n + 1) / 2 - 2 * ((n / 2) * (n / 2 + 1) / 2));
int dx[] { 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[] { 0, 0, 1, -1, 1, -1, 1, -1 };
void K_K(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll gcd(ll a, ll b) {
	return b == 0 ? abs(a) : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main(){
	K_K();
	int arr[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << arr[k - 1];
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int keta(long long n);

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

	int mn = 1010101010;
	for (int i = 1; i <= sqrtl(n) + 1; i++) {
		if (n % i == 0) {
			mn = min(mn, max(keta(i), keta(n / i)));
		}
	}
	cout << mn << endl;

	return 0;
}

int keta(long long n)
{
	int ans = 0;
	while (n != 0) {
		n /= 10;
		ans++;
	}

	return ans;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

def main():
    num = list(map(int, list(readline().rstrip())))
    for op1 in ['+', '-']:
        for op2 in ['+', '-']:
            for op3 in ['+', '-']:
                v = num[0]
                if op1 == '+':
                    v += num[1]
                else:
                    v -= num[1]
                if op2 == '+':
                    v += num[2]
                else:
                    v -= num[2]
                if op3 == '+':
                    v += num[3]
                else:
                    v -= num[3]
                if v == 7:
                    print(str(num[0])+op1+str(num[1])+op2+str(num[2])+op3+str(num[3])+'=7')
                    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;

class FastReader 
{ 
    BufferedReader br; 
    StringTokenizer st; 
    
    public FastReader() 
    { 
        br = new BufferedReader(new InputStreamReader(System.in)); 
    } 
    
    String next() 
    { 
        while (st == null || !st.hasMoreElements()) 
        { 
            try
            { 
                st = new StringTokenizer(br.readLine()); 
            } 
            catch (IOException  e) 
            { 
                e.printStackTrace(); 
            } 
        } 
        return st.nextToken(); 
    } 
    
    int nextInt() 
    { 
        return Integer.parseInt(next()); 
    } 
    
    long nextLong() 
    { 
        return Long.parseLong(next()); 
    } 
    
    double nextDouble() 
    { 
        return Double.parseDouble(next()); 
    } 
    
    String nextLine() 
    { 
          String str = ""; 
        try
        { 
            str = br.readLine(); 
        } 
        catch (IOException e) 
        { 
            e.printStackTrace(); 
        } 
        return str; 
    } 
} 

class Solution
{
    void solve()
    {
        FastReader sc = new FastReader();

        int N = sc.nextInt();

        double sum = 0;

        for(int i = 0; i < N; i++)
        {
            double inp = sc.nextDouble();

            sum += (1/inp);
        }

        double res = 1/sum;

        System.out.println(res);
    }
}
  
public class Main 
{ 
    public static void main(String[] args) 
    { 
        Solution ob = new Solution();

        ob.solve();
    } 
} 

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


int main() {
    string S;
    cin >> S;
    int n = S.length();
    int ans;
    bool flag=false;
    for(int i=n-2; i>=0; i-=2){
        if(S.substr(0,i/2)==S.substr(i/2,i/2)){
            ans=i;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int n,a,b,c;
	cin>> n;
	for(;n>0;n--){
	cin>> a>> b>> c;
	if(a*a+b*b==c*c){
		cout<< "YES"<<endl;
	}
	else if(b*b+c*c==a*a){
		cout<< "YES"<<endl;
	}
	else if(c*c+a*a==b*b){
		cout<< "YES"<<endl;
	}
	else{
		cout<< "NO"<<endl;
	}
	}
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,j) for(int i=0;i<j;i++)
#define REP(i,j,z) for(int i=j;i<z;i++)
int main()
{
	ll N;
	ll ans=0;
	cin>>N;
	vector<ll> A(N);
	vector<ll> B(N);
	vector<ll> C(N);
	rep(i,N) cin>>A[i];
	rep(i,N) cin>>B[i];
	rep(i,N-1) cin>>C[i];
	rep(i,N) ans+=B[i];
	REP(i,1,N) if(A[i]-1==A[i-1])ans+=C[A[i-1]-1];
	
	cout<<ans<<endl;
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

//{{{ Graph
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
//}}}

int N,K;
Graph g;

pair<int,int> dfs(int u,int level,int prev){//num,max_level(updated)
	pair<int,int> ret(0,level);
	FOR(e,g[u]){
		if(e->dst == prev)continue;
		pair<int,int> p = dfs(e->dst,level+1,u);
		ret.first+=p.first;
		ret.second = max(ret.second,p.second);
	}
	if(level > 1 and ret.second-level>=K-1){
		ret.first++;
		ret.second = level - 1;
	}
	return ret;
}

int a[100010];

int main(){
	scanf("%d%d",&N,&K);
	g.assign(N,Edges());
	REP(i,N){
		scanf("%d",&a[i]);
		a[i]--;
		if(i!=0)g[a[i]].push_back(Edge(a[i],i,1));
	}
	pair<int,int> p = dfs(0,0,-1);
	if(a[0]!=0)p.first++;

	printf("%d\n",p.first);
	return 0;
}

Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
int n,k,cnt,ans;
char s[100005];
int main()
{
	scanf("%d%d%s",&n,&k,s+1);
	s[0]='R';s[n+1]='L';
	for(int i=0;i<=n;i++)
		if(s[i]=='R'&&s[i+1]=='L')
			cnt++;
	cnt-=k,ans=n-cnt*2;
	if(s[1]=='L')ans++;
	if(s[n]=='R')ans++;
	cout<<min(ans,n-1)<<endl;
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            while(true) {
                var H = cin.ReadInt;
                var W = cin.ReadInt;
                if(W == 0 && H == 0) break;
                var Edge = new string('#', W);
                for(int i = 0; i < H; i++) {
                    Console.WriteLine(Edge);
                }
                Console.WriteLine("");
            }
        }
    }

    static class ExtendClass {
        public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }

}



Measured memory_bytes: 18412
#include <stdio.h>
typedef long long ll;

int main(){
    int l,r;
    scanf("%d %d",&l,&r);
    ll answer=2018;
    // r=r-l<2019?r:l+2019;
    if(r-l>2019*2) r=l+2019*2;
    for(ll i=l;i<=r;i++){
        for(ll j=i+1;j<=r;j++){
            ll a=(i*j)%2019;
            // answer=a<answer?a:answer;
            if(a<answer) answer=a; 
        }
    }
    printf("%d\n",answer);
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){


    int i, len;
    char s[4096], p[4096], s2[4096];  
    scanf("%s", s);
    scanf("%s", p);
    //例 s="vanceknowledgetoad"
    //例 p="advance"
    // s2 = "vanceknowledgetoad" + "vanceknowledgetoad"

    sprintf(s2, "%s%s", s, s);  // 文字列を連結する
  

    // strstr という関数で部分文字列を探す
    if(strstr(s2, p) == NULL) {


    printf("No\n");
}
    else {
    printf("Yes\n");
}
return 0;
}



Measured memory_bytes: 2104
import sys
input = sys.stdin.buffer.readline
import heapq

def dijkstra(n, start, edge):
    dist = [float("inf")]*n
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, v = heapq.heappop(que)
        if dist[v] < d:
            continue
        for nv, nd in edge[v]:
            if dist[nv] > d + nd:
                dist[nv] = d + nd
                heapq.heappush(que, (dist[nv], nv))
    return dist
    
n, m, s, t = map(int, input().split())
G_yen = [[] for _ in range(n+1)]
G_snuuk = [[] for _ in range(n+1)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    G_yen[u].append((v, a))
    G_yen[v].append((u, a))
    G_snuuk[u].append((v, b))
    G_snuuk[v].append((u, b))
dijk_yen = dijkstra(n+1, s, G_yen)
dijk_snuuk = dijkstra(n+1, t, G_snuuk)
L = []
U = 10**15
now = U
for i in range(n, 0, -1):
    now = min(now, dijk_yen[i]+dijk_snuuk[i])
    L.append(U-now)
print(*L[::-1], sep="\n")

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

namespace CADDi2018D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] A = new long[N];

            bool Has1 = false;
            for (int i = 0; i < N; i++)
            {
                A[i] = long.Parse(Console.ReadLine());
                if (A[i] == 1)
                {
                    Has1 = true;
                }
            }

            if (Has1)
            {
                Console.WriteLine("first");
                return;
            }

            for (int i = 0; i < N; i++)
            {
                if (A[i] % 2 == 1)
                {
                    Console.WriteLine("first");
                    return;
                }
            }
            Console.WriteLine("second");
        }
    }
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<((a+min(b,c)<max(b,c))?(max(b,c)-a-min(b,c)):0)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

using namespace std;
typedef long long ll;
// typedef pair<int, int> P;

#define PI 3.141592653589793
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)

string s[27][27];

void solve() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			cin >> s[i][j];

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++)
			if (s[i][j] == "snuke") {
				char a = 'A' + j; int n = 1 + i;
				cout << a << n << endl;
			}
}

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

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

ll dp[100005][14] = {0};

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

    int N    = S.size();
    dp[0][0] = 1;
    rep(n, N) {
        char sn = S[n];
        if (sn == '?') {
            rep(i2, 13) rep(i, 10) {
                dp[n + 1][(i + i2 * 10) % 13] += dp[n][i2];
                dp[n + 1][(i + i2 * 10) % 13] %= (ll)1e9 + 7;
            }
        } else {
            int sni = sn - '0';
            rep(i2, 13) {
                dp[n + 1][(sni + i2 * 10) % 13] += dp[n][i2];
                dp[n + 1][(sni + i2 * 10) % 13] %= (ll)1e9 + 7;
            }
        }
    }
    cout << dp[N][5] << endl;
}

Measured memory_bytes: 11392
from itertools import chain

H, W, D = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
exam = [list(map(int, input().split())) for _ in range(Q)]

x_a = [0] * (H*W)
y_a = [0] * (H*W)

for i, ax in enumerate(A):
    for j, ay in enumerate(ax):
        x_a[ay-1] = i
        y_a[ay-1] = j

S = [0] * (H*W)
for i in reversed(range(H*W-D)):
    S[i] = abs(x_a[i] - x_a[i+D]) + abs(y_a[i] - y_a[i+D]) + S[i + D]

for L, R in exam:
    print(S[L-1] - S[R-1])



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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	for(int i = 0; i < n; i++) {
		int t;
		cin >> t;
		mp[t]++;
	}
	vector<int> a;
	for(auto i : mp) {
		a.push_back(i.second);
	}
	sort(a.begin(), a.end());
	int ans = 0;
	if(a.size() <= k) {
		cout << 0 << endl;
		return 0;
	}
	for(int i = 0; i < a.size() - k; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;	
}


Measured memory_bytes: 10744
chomp (my ($n, $k) = split / /, <STDIN>);
my (@d, %h);
for my $i (1..$k) {
  chomp ($d[$i] = <STDIN>);
  chomp (my $in = <STDIN>);
  my @c = split ' ', $in;
  $h{$_}++ for @c
}
print ($n - scalar(%h));

Measured memory_bytes: 4808
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<61;
const double eps=1e-5;
const ll MOD=1e9+7;
ll dp[110][100010];
ll sum[100010];
int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n+10);
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=k+1;i++)sum[i]=1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k+1;j++){
            dp[i][j]+=sum[j]-sum[max(0,j-a[i]-1)]+MOD;
            dp[i][j]%=MOD;
        }
        for(int j=0;j<=k+1;j++)sum[j]=0;
        for(int j=1;j<=k+1;j++){
            sum[j]+=sum[j-1]+dp[i][j];
            sum[j]%=MOD;
        }
    }
    cout<<dp[n][k+1]%MOD<<endl;
}   


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int count = 0, maxCount = 0, i = 0;
    cin >> str;
    for(i = 0; i < str.length(); i++){
        if(str[i] == 'A' || str[i] == 'C' || str[i] == 'G' || str[i] == 'T'){
            count++;
            if(maxCount <= count){
                maxCount = count;
            }
        }
        else{
            if(maxCount <= count){
                maxCount = maxCount;
            }
            count = 0;
        }
    }
    cout << maxCount << endl;
}

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

using namespace std;

int main() {
    int k = 0;
    int a = 0;
    int b = 0;
    cin >> k >> a >> b;

    bool flag = false;

    for(int i = a; i <= b ; i++){
        if(i % k == 0){
            flag = true;
            break;
        }
    }

    if(flag){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3636
using System;

namespace AtCoderABC131A
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] c = Console.ReadLine().ToCharArray();

            for (int i = 1; i < c.Length; i++)
            {
                if(c[i] == c[i-1])
                {
                    Console.WriteLine("Bad");
                    return;
                }
            }

            Console.WriteLine("Good");
        }
    }
}


Measured memory_bytes: 11092