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

int main(){
    string s;
    int n;
    cin >> n;
    int c = 0;
    cin >> s;
    
    
    for(int i = 0; i < s.size() - 2; i++){
        if(s[i] == 'A'){
            if(s[i + 1] == 'B'){
                if(s[i + 2] == 'C'){
                    c++;
                }
            } 
        }
    }
    
    cout << c;
    
    return 0;
}

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

namespace B___Counting_Roads
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var m = int.Parse (input[1]);
            var a = new List<int> ();
            var b = new List<int> ();
            for (var i = 0; i < m; i++)
            {
                input = Console.ReadLine ().Split (' ');
                a.Add (int.Parse (input[0]));
                a.Add (int.Parse (input[1]));
            }
            for (var i = 1; i <= n; i++)
            {
                var c = 0;
                foreach (var p in a)
                {
                    if (i == p)
                    {
                        c++;
                    }
                }
                b.Add (c);
            }
            foreach (var p in b)
            {
                Console.WriteLine (p);
            }
        }
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
#define F first
#define S second
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
int a[114], b[114], c[114], d[114];
P ab[114], cd[114];
bool B[114];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i] >> b[i];
	rep(i, n)cin >> c[i] >> d[i];
	rep(i, n)ab[i] = P(a[i], b[i]), cd[i] = P(c[i], d[i]);
	sort(cd, cd + n);
	fill(B, B + n, true);
	rep(i, n) {
		int my = -1, mn = -1;
		rep(j, n) {
			if (ab[j].first < cd[i].first&&ab[j].second < cd[i].second&&B[j] && my < ab[j].S) {
				my = ab[j].second;
				mn = j;
			}
		}

		if (~mn)B[mn] = false;
	}
	int ans = 0;
	rep(i, n)if (!B[i])ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int A,B,C,X,Y,Z,hako;
scanf("%d",&X);
scanf("%d",&Y);
scanf("%d",&Z);

A=Z; B=X; C=Y;
printf("%d ",A);
printf("%d ",B);
printf("%d ",C);

return 0;
}

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

int main() {
	int a, b, c; cin >> a >> b >> c;
	int maxN = 3 * max({ a,b,c });
	int rest = maxN - a - b - c;

	if (rest % 2 == 0)cout << rest / 2 << endl;
	else cout << (rest + 3) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
struct classroom {
    int students_num, class_num;
} c[100010];
bool cmp(classroom s1, classroom s2) { return s1.students_num >= s2.students_num; }
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> c[i].students_num; c[i].class_num = i + 1; }
    sort(c, c + n, cmp);
    for (int i = n - 1; i > -1; i--) cout << c[i].class_num << " ";
}

Measured memory_bytes: 1536
n,t=map(int, input().split())
v=[list(map(int,list(input().split()))) for i in range(n)]
x=[]
for i in range(n):
    if v[i][1]<=t:
        x.append(v[i][0])

if x==[]:
    print('TLE')
else:
    print(min(x))

Measured memory_bytes: 3060
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7

def factorial(N, mod=MOD):
    res = 1
    for i in range(2, N+1):
        res *= i
        res %= mod
    return res

def main():
    N, M = map(int, readline().rstrip().split())
    if abs(N-M) > 1:
        ans = 0
    elif N == M:
        ans = factorial(N) ** 2 * 2
    else:
        ans = factorial(min(N, M)) ** 2 * max(N, M)

    print(ans % MOD)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)
const double EPS = 1e-10;

struct Point {
    double x, y;
    Point(double x=0, double y=0): x(x), y(y) {}
};
inline Point operator+(const Point &p, const Point &q) {return Point(p.x+q.x, p.y+q.y);}
inline Point operator-(const Point &p, const Point &q) {return Point(p.x-q.x, p.y-q.y);}
inline Point operator*(const Point &p, double a) {return Point(p.x*a, p.y*a);}
inline Point operator/(const Point &p, double a) {return Point(p.x/a, p.y/a);}

inline Point rot90(const Point &p) {return Point(-p.y, p.x);}
inline double cross(const Point &p, const Point &q) {return p.x*q.y - p.y*q.x;}
inline double dot(const Point &p, const Point &q) {return p.x*q.x + p.y*q.y;}
inline double abs(const Point &p) {return sqrt(dot(p, p));}

struct Line: std::vector<Point> {
    Line(Point a=Point(0,0), Point b=Point(0,0)) {
        this->push_back(a);
        this->push_back(b);
    }
};

std::vector<Point> crosspoint(const Line &l, const Line &m) {
    std::vector<Point> res;
    double d = cross(m[1]-m[0], l[1]-l[0]);
    if(abs(d)<EPS) return std::vector<Point>();
    res.push_back(l[0]+(l[1]-l[0])*cross(m[1]-m[0], m[1]-l[0]) / d);
    return res;
}

Point gaisin(Point a, Point b, Point c) {
    Line ab((a+b)/2, (a+b)/2+rot90(a-b));
    Line bc((b+c)/2, (b+c)/2+rot90(b-c));
    std::vector<Point> cp = crosspoint(ab, bc);
    if(cp.size()) return cp[0];
    else return Point(EPS, EPS);
}


int main(){
	int n;
	scanf("%d", &n);
	std::vector<Point> ps(n);
	REP(i, 0, n) scanf("%lf %lf", &ps[i].x, &ps[i].y);

	double ans = 1000;
	REP(i, 0, ps.size()) REP(j, i+1, ps.size()) REP(k, j+1, ps.size()) {
	    Point gs = gaisin(ps[i], ps[j], ps[k]);
	    if(gs.x==EPS and gs.y==EPS) continue;
	    double R = abs(gs-ps[i]);
	    bool ok = true;
	    REP(l, 0, ps.size()){
		if(R<abs(gs-ps[l])) ok = false;
	    }
	    if(ok && ans>R) ans = R;
	}

	REP(i, 0, ps.size()) REP(j, i+1, ps.size()) {
	    Point o = (ps[i]+ps[j])/2;
	    double R = abs(o-ps[i]);
	    bool ok = true;
	    REP(k, 0, ps.size()){
		if(R<abs(o-ps[k])) ok = false;
	    }
	    if(ok && ans>R) ans = R;
	}
	printf("%.10lf\n", ans);
	return 0;
}



Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  bool flag=false,ans=false;
  cin >> a >> b >> c >> d;
  if(a>=b && a-b<=d) flag = true;
  else if(b>=a && b-a<=d) flag = true;
  if(flag && b>=c && b-c<=d) ans = true;
  else if(flag && c>=b && c-b<=d) ans = true;
  if(a>=c && a-c<=d) ans = true;
  else if(c>=a && c-a<=d) ans = true;
  cout << (ans? "Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
struct Node{
	int num;
	int v;
}a[100100];
bool cmp(Node a,Node b){
	return a.num<b.num;
}
int n;
using namespace std;
int main ( ) {
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>a[i].num;
		a[i].v=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) {
		printf("%d ",a[i].v);
	} 
	return 0;
} 

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long int
#define fori(a,b) for(i=a;i<b;i++)
using namespace std;
int main () {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll x=(c/b);
  ll y=(a/d);
  if(c%b!=0)
  x+=1;
  if(a%d!=0)
  y+=1;
  //cout<<x<<y<<endl;
  if(x<=y)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000001;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){return modpow(x,mod-2);}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,m;
string s;
vector<int>v[200010];
bool used[200010];
void dfs(int x){
    bool A=false,B=false;
    for(int i:v[x]){
        if(s[i]=='A'&&!used[i])A=true;
        if(s[i]=='B'&&!used[i])B=true;
    }
    if(A&&B)return;
    used[x]=true;
    for(int i:v[x]){
        if(!used[i])dfs(i);
    }
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>s;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    rep(i,n){
        if(!used[i])dfs(i);
    }
    bool ans=false;
    rep(i,n){
        if(!used[i])ans=true;
    }
    if(ans)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 19920
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=2000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

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

struct node{int col,pos;}p[N<<1];
int n,f[N][N],A[N<<1][N],B[N<<1][N],pos[2][N<<1];
char s[10];

int main()
{
    n=read();
    rep(i,1,n*2)
    {
        scanf("%s",s);
        if (s[0]=='W') p[i].col=0;else p[i].col=1;
        p[i].pos=read();
        pos[p[i].col][p[i].pos]=i;
    }
    rep(i,1,n*2) rep(j,1,i-1)
    {
        if (p[j].col==0) A[i][p[j].pos]++;
        else B[i][p[j].pos]++;
    }
    rep(i,1,n*2) per(j,n,1) 
    {
        A[i][j]+=A[i][j+1];
        B[i][j]+=B[i][j+1];
    }
    f[0][0]=0;
    rep(i,0,n) rep(j,0,n)
    {
        if ((!i) && (!j)) continue;
        f[i][j]=maxd;
        if (i) 
        {
            int nowp=pos[0][i],cost=A[nowp][i+1]+B[nowp][j+1];
            f[i][j]=min(f[i][j],f[i-1][j]+cost);
        }
        if (j) 
        {
            int nowp=pos[1][j],cost=A[nowp][i+1]+B[nowp][j+1];
            f[i][j]=min(f[i][j],f[i][j-1]+cost);
        }
    }
    printf("%d\n",f[n][n]);
    return 0;
}


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

int main() {
 int d; cin>>d;
  
 if(d==25) cout<<"Christmas"<<endl;
   if(d==24) cout<<"Christmas Eve"<<endl;
   if(d==23) cout<<"Christmas Eve Eve"<<endl;
   if(d==22) cout<<"Christmas Eve Eve Eve"<<endl;




}




Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  string S;
  cin >> S;
  bool f = 1;
  for (int i = 0; i < S.size(); ++i) {
    char c = S[i];
    if (i % 2 == 0) {
      if (c == 'R' || c == 'U' || c == 'D') {
      } else {
        f = 0;
      }
    } else {
      if (c == 'L' || c == 'U' || c == 'D') {
      } else {
        f = 0;
      }
    }
  }
  print(f ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, d;
	int start, end;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	if (a < c)
	{
		start = c;
	}
	else
	{
		start = a;
	}
	if (b < d)
	{
		end = b;
	}
	else
	{
		end = d;
	}
	if (start < end)
	{
		printf("%d", end - start);
	}
	else
	{
		printf("0");
	}
	return 0;
}

Measured memory_bytes: 128
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from math import gcd
def resolve():
    fixed = {}
    n, m = map(int, input().split())
    S = input()
    T = input()
    l = n // gcd(n, m) * m
    for i in range(n):
        fixed[i * l // n] = S[i]
    for j in range(m):
        if not j * l // m in fixed:
            continue
        if fixed[j * l // m] != T[j]:
            print(-1)
            return
    print(l)
resolve()

Measured memory_bytes: 92232
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int n, m;
    cin >> n >> m;
    VI x(m);
    for (Int i = 0; i < m; ++i) {
        cin >> x[i];
    }
    if (n >= m) {
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    VI diff(m - 1);
    for (Int i = 0;i < m - 1; ++i) {
        diff[i] = x[i + 1] - x[i];
    }
    sort(diff.begin(), diff.end());
    Int result = 0;
    for (Int i = 0; i < m - n; ++i) {
        result += diff[i];
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 4668
#include <bits/stdc++.h>
#define REP(i, n) for (int i{ 0 }; i < n; ++i)
#define REP2(i, s, n) for (int i{ s }; i < n; ++i)
#define DREP(i, n) for (int i{ n - 1 }; i <= 0; --i)
#define repa(arr) for (auto& e : arr)
#define DEB(x) (std::cerr << __LINE__ << ": x = " << x << std::endl)
#define DEBa(x) repa(x) DEB(e)

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for (auto& l : L) cin >> l;
    int cnt{ 0 };

    REP(i, N - 2) {
        REP2(j, i + 1, N - 1) {
            REP2(k, j + 1, N) {
                int a = L.at(i);
                int b = L.at(j);
                int c = L.at(k);

                if (a != b && b != c && c != a) {
                    if (a + b > c && b + c > a && c + a > b) cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    boolean[] base;
    int out, point, n;
    String event;

    void run(){
	n = sc.nextInt();
	out = 0;
	point = 0;
	base = new boolean[3];
	while(n>0){
	    if(out!=3) solve();
	    else {
		System.out.println(point);
		point = 0;
		out = 0;
		Arrays.fill(base, false);
		n--;
	    }
	}
    }

    void solve(){
	event = sc.next();
	if(event.equals("HIT")){
	    boolean next = true;
	    for(int i=0; i<base.length; i++){
		if(next){
		    next = base[i];
		    base[i] = true;
		}
		else{
		    next = base[i];
		    base[i] = false;
		}
	    }
	    if(next) point++;
	}
	else if(event.equals("HOMERUN")){
	    for(int i=0; i<base.length; i++){
		if(base[i]) point++;
		base[i] = false;
	    }
	    point++;
	}
	else out++;
    }
}

Measured memory_bytes: 17196
#include <stdio.h>
#include <string.h>

int max(int a, int b)
{
    return (a > b ? a : b);
}

int min(int a, int b)
{
    return (b > a ? a : b);
}

int main(void)
{
    char saki[12000], moto[12000], t[12000];
    int slen, mlen;
    int i, j, k, temp, res;
    
    while (scanf("%s", saki) != EOF){
        scanf("%s", moto);
        
        strcpy(t, moto);
        memset(moto, '\0', sizeof(moto));
        strcpy(&moto[3999], t);
        
        res = 0;
        for (i = 0; i <= 8000; i++){
            temp = k = 0;
            for (j = i; j <= i + 4000; j++){
                if (saki[k] != '\0' && moto[j] != '\0' && saki[k] == moto[j]){
                    temp++;
                }
                else {
                    res = max(temp, res);
                    temp = 0;
                }
                k++;
            }
            res = max(temp, res);
        }
        
        printf("%d\n", res);
    }
    
    return (0);
}

Measured memory_bytes: 444
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc162b
{
    class Program
    {
        static void Main(string[] args)
        {
            //==========================================================================================================================
            //1) input
            decimal input = decimal.Parse(Console.ReadLine());


            //==========================================================================================================================
            //2) output
            decimal output = 0;

            for (decimal index = 1; index <= input; index++)
            {
                if (index % 3 == 0 && index % 5 == 0)
                {
                    continue;
                }
                else if (index % 3 == 0)
                {
                    continue;
                }
                else if (index % 5 == 0)
                {
                    continue;
                }

                output += index;

            }








            Console.WriteLine(output);

            //==========================================================================================================================

        }
    }
}


Measured memory_bytes: 27452
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
int S(int n){
  if(n<10)return n;
  return S(n/10)+(n%10);
}
int nine(int n){
  if(n%10!=9)return 1;
  return nine(n/10)*10;
}
signed main(){
  int k;cin>>k;
  ivec bek(20);bek[0]=1;
  rep(i,17)bek[i+1]=bek[i]*10;
  
  int cnt=0;
  rep(i,15){
    int sa=1;
    if(i>=3)sa=bek[i-3];
    for(int n=bek[i]+sa-1;n<bek[i+1];n+=sa){
      if(cnt>=k)return 0;
      if(n<=S(n)*nine(n)){
        cout<<n<<endl;
        cnt++;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3624
import bisect
import numpy as np

def main():
    N = int(input())
    P = list(map(int, input().split()))


    ans = 1
    f = P[0]

    for i in range(1, N):
        f_o = P[i]
        if f >= f_o:
            ans+=1
            f = f_o
    print(ans)
    return 0


if __name__ == '__main__':
    main()

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    vector<int64_t> a(n);
    for (auto i : irange(0L, n)) {
        cin >> a[i];
    }

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

    vector<int64_t> s(n + 1);
    for (auto i : irange(0L, n)) {
        s[i + 1] = s[i] + a[i];
    }

    int64_t ans = 1;
    for (auto i : irange(0L, n - 1) | reversed) {
        if (2 * s[i + 1] < a[i + 1]) {
            break;
        }

        ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int n;
int i;
int j;
int x;

char c;
int hoge[4][13];

main(){
	scanf("%d",&n);
	for(i=0; i<2*n; i++){
		scanf("%c %d",&c,&x);
		switch(c){
			case 'S':hoge[0][x-1]=x;
			break;
			case 'H':hoge[1][x-1]=x;
			break;
			case 'C':hoge[2][x-1]=x;
			break;
			case 'D':hoge[3][x-1]=x;
			break;
		}
	}
	for(i=0; i<4; i++){
		for(j=0; j<13; j++){
			if(hoge[i][j]== 0){
					switch(i){
						case 0:printf("S %d\n",j+1);
						break;
						case 1:printf("H %d\n",j+1);
						break;
						case 2:printf("C %d\n",j+1);
						break;
						case 3:printf("D %d\n",j+1);
					}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>
#define ll long long

using namespace std;

int main() {

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

	int N;

	cin >> N;

	vector<int> a(N);


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

	set<int> s;

	bool poss = true;

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

		if (s.find(a[i]) == s.end()) {
			s.insert(a[i]);
		}
		else {
			poss = false;
			break;
		}
	}

	if (poss) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 13416
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

enum state {
  LEFT = -1,
  RIGHT = 1
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  string s;
  cin >> n >> s;
  vector<int> hasi(2*n);
  hasi[0] = LEFT;
  for (int i = 1; i < 2*n; ++i) {
    if (s[i] == s[i-1]) hasi[i] = -hasi[i-1]; 
    else hasi[i] = hasi[i-1];
  }
  if (hasi[2*n-1] == LEFT || s[0] == 'W' || s[2*n-1] == 'W') { //NG
    cout << 0 << endl;
    return 0;
  }
  ll leftcnt = 0;
  bool ok = true;
  mint ans = 1;
  rep(i,2*n) { //LEFTをRIGHTに割り当てる
    if (hasi[i] == LEFT) leftcnt++;
    else if (hasi[i] == RIGHT) {
      if (leftcnt <= 0) {
        ok = false; break; //NG
      }
      ans *= leftcnt;
      leftcnt--;
    }
    debug(i, state(hasi[i]), leftcnt, ans);
  }
  if (!ok || leftcnt > 0) {
    cout << 0 << endl;
    return 0;
  }
  for (ll i = n; i >= 2; --i) { // n!
    ans *= i;
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,d,x; cin>>r>>d>>x;
    rep(i,10){
        x = r*x-d;
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
ryoris = [int(input()) for i in range(5)]
ryoris.sort()

saigo = 199
for ryori in ryoris:
    if ryori % 10 > 0 and ryori % 10 <= saigo % 10:
        saigo = ryori

if saigo == 199:
    saigo = ryoris[0]
    
ryoris.remove(saigo)
# print(saigo,ryoris)
time = 0
for ryori in ryoris:
    time += ryori if ryori % 10 == 0 else 10 * (ryori //10) + 10
#     print(ryori,time)
    
time += saigo
    
print(time)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <random>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;
typedef long long 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 INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

void dfs(vector<int> e, int N, int M, int Q, int& ans, vector<int>& A, vector<int>& B, vector<int>& C, vector<int>& D){
  if(e.size()==N){
    int tmp=0;
    REP(i,Q){
      if(e[B[i]]-e[A[i]]==C[i]){
        tmp+=D[i];
      }
      chmax(ans,tmp);
    }
  }else{
    FOR(i,e[e.size()-1],M+1){
      vector<int> ee=e;
      ee.push_back(i);
      dfs(ee, N,M,Q, ans, A,B,C,D);
    }
    return;
  }
}

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N,M,Q;
  cin>>N>>M>>Q;
  vector<int>A(Q),B(Q),C(Q),D(Q);
  REP(i,Q){
    cin>>A[i]>>B[i]>>C[i]>>D[i];
    A[i]--;B[i]--;
  }
  int ans=0;
  vector<int> e(1);
  FOR(i,1,10){
    e[0]=i;
    dfs(e,N,M,Q,ans,A,B,C,D);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3664
D,G = list(map(int, input().split()))
P = []
C = []
for i in range(D):
    p,c = list(map(int, input().split()))
    P.append(p)
    C.append(c)
s = {i for i in range(D)}
flag = False
bit = 0
number = []

for bit in range(2**D):
    score = 0
    count = 0
    comp = []
    # print(bit)
    for j in range(D):
        if bit & (1<<j):
            score += P[j] * 100 * (j+1) + C[j]
            count += P[j]
            comp.append(j)
    if score >= G:
        number.append(count)
    else:
        n = max(s-set(comp))
        for k in range(P[n]):
            score += 100 * (n+1)
            count += 1
            if score >= G:
                number.append(count)
                break

print(min(number))

        
                


    



    


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

using namespace std;

int num_digits(int i) {
  int n = 0;
  while (i > 0) {
    i /= 2;
    n++;
  }
  return n;
}

int main() {
  int L;
  cin >> L;
  int N = num_digits(L);
  int M = 0;
  vector<vector<pair<int, int>>> E(N, vector<pair<int, int>>());
  for (int i = 0; i < N - 1; i++) {
    int d = pow(2, i);
    E[i].push_back({i + 1, 0});
    E[i].push_back({i + 1, d});
    M += 2;
  }
  for (int i = 0; i < N - 1; i++) {
    if (L & (1 << i)) {
      int d = (L >> (i + 1)) << (i + 1);
      E[i].push_back({N - 1, d});
      M++;
    }
  }
  cout << N << " " << M << endl;
  for (int i = 0; i < N; i++) {
    for (auto e : E[i]) {
      cout << i + 1 << " " << e.first + 1 << " " << e.second << endl;
    }
  }

  return 0;
}
/* vim:set fdm=marker: */


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

using namespace std;

int main() {
    map<long long int, int> mp;
    int N;
    cin >> N;
    bool flag=true;
    for(int n=0; n<N; n++) {
        long long int A;
        cin >> A;
        mp[A]++;
        
        if(flag && mp[A]>1) {
            flag=false;
        }
    }
    
    if(flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 12800
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		int fee = 0;
		rep(i, n){
			int x, y, h, w;
			scanf("%d%d%d%d", &x, &y, &h, &w);
			const int length[] = {60, 80, 100, 120, 140, 160};
			const int weights[] = {2, 5, 10, 15, 20, 25};
			const int fees[] = {600, 800, 1000, 1200, 1400, 1600, 0};
			fee += fees[max(lower_bound(length, length+6, x+y+h)-length, lower_bound(weights, weights+6, w)-weights)];
		}
		printf("%d\n", fee);
	}

	return 0;
}

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

int main(){
    cout << fixed << setprecision(15);

    int N, K;
    ll temp, ans;
    ll p[200001];
    cin >> N >> K;
    REP(int,i,0,N) cin >> p[i];

    temp = 0;
    REP(int,i,0,K) temp += p[i];

    ans = temp;
    REP(int,i,K,N){
        temp += p[i]-p[i-K];
        if(temp>ans) ans = temp;
    }
    
    ans += K;
    cout << (double)ans/2. << endl;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[n];

		Arrays.fill(a, -1);


		for (int i = 0; i < k; i++) {
			int count = sc.nextInt();
			for (int j = 0; j < count; j++) {
				a[sc.nextInt() - 1] = 1;
			}
		}

		int answer = 0;
		for (int i : a) {
			if (i == -1) answer++;
		}

		System.out.println(answer);

		sc.close();
	}

}


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

#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define pii pair<int, int>
#define pb push_back
#define vec vector
#define beg begin
#define dbg(x) cerr << #x << " = " << x << endl;

template<class T> ostream& operator<<(ostream &str, vector<T> &a) {
    for (auto &i : a) {
        str << i << " ";
    }
    return str;
}

template<class T> istream& operator>>(istream &str, vector<T> &a) {
    for (auto &i : a) {
        str >> i;
    }
    return str;
}

template<class T> ostream& operator<<(ostream &str, pair<T, T> &a) {
    str << a.first << " " << a.second;
    return str;
}

template<class T> istream& operator>>(istream &str, pair<T, T> &a) {
    str >> a.first >> a.second;
    return str;
}

void solve(); signed main() {
#ifdef LOCAL
    freopen("C:\\Users\\artma\\CLionProjects\\problems\\input.txt", "r", stdin);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(6);
    solve();
    return 0;
}

const int MOD = 1e9 + 7, MAXN = 1e6 + 10, INF = 1e18 + 10, BASE = 37;
int T = 0;
vec<int> comp;

void dfs(int v, vec<int> &used, vec<int> &group, vec<vec<int>> &g) {
    used[v] = 1;
    group[v] = T;
    comp.pb(v);
    for (auto u : g[v]) {
        if (!used[u]) {
            dfs(u, used, group, g);
        }
    }
}

void solve() {
    int n, k, l;
    cin >> n >> k >> l;
    vec<vec<int>> g1(n + 1), g2(n + 1);
    for (int i = 0; i < k; ++i) {
        int u, v;
        cin >> u >> v;
        g1[u].pb(v);
        g1[v].pb(u);
    }
    for (int i = 0; i < l; ++i) {
        int u, v;
        cin >> u >> v;
        g2[u].pb(v);
        g2[v].pb(u);
    }

    vec<int> group1(n + 1), group2(n + 1), used1(n + 1), used2(n + 1);
    vec<vec<int>> gs;

    T = 1;
    for (int v = 1; v <= n; ++v) {
        if (!used1[v]) {
            comp.clear();
            dfs(v, used1, group1, g1);
            T++;
            gs.pb(comp);
        }
    }
    T = 1;
    for (int v = 1; v <= n; ++v) {
        if (!used2[v]) {
            comp.clear();
            dfs(v, used2, group2, g2);
            T++;
        }
    }

    vec<int> ans(n + 1);
    for (auto it : gs) {
        map<int, vec<int>> mp;
        for (auto el : it) {
            mp[group2[el]].pb(el);
        }
        for (auto it : mp) {
            for (auto el : it.y) {
                ans[el] = sz(it.y);
            }
        }
    }

    for (int v = 1; v <= n; ++v) {
        cout << ans[v] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 41128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()

    point = 0
    p = {'r':P, 's':R, 'p':S}
    taka = [True] * K

    for i in range(K):
        point += p.get(T[i])
    
    for i in range(K, N):
        if T[i] == T[i-K]:
            if taka[i-K]:
                taka.append(False)
            else :
                point += p.get(T[i])
                taka.append(True)
        else:
            point += p.get(T[i])
            taka.append(True)

    print(point)

if __name__ == '__main__':
    main()

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

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

    for (char t : s)
    {
        int shift = t - 'A' + n;
        shift %= 26;
        t = 'A' + shift;
        cout << t;
    }
    cout << endl;
}

Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys
import math


def solve(H: int, A: int):
    print(math.ceil(H/A))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;

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

  
int main(){

  int n,k;cin>>n>>k;
  vector<int> cl(n,0);
  int l=0,cnt=0;
  rep(i,n){
    int a;cin>>a;a--;
    cl[a]++;
  }
  //rep(i,n)cout<<cl[i]<<endl;
  sort(cl.begin(),cl.end());
  reverse(cl.begin(),cl.end());
  rep(i,n){
    if(cl[i]==0)continue;
    else if(cnt<k){
      cnt++;
    }
    else{
      cnt++;
      l+=cl[i];
    }
  }
  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define inf 1e18
#define pll pair<ll,ll>
#define mod 1000000007
map<ll,ll> m;
int main(){
    /*ll n,m;
    vector<ll> v;
    for(i=0;i<n;i++){
        cin>>t;
        v.pb(t);
    }
    v.insert(v.begin(),0);
    ll pre[n];
    pre[0]=-1*v[0];
    for(i=0;i<n+1;i++){
        if(i%2==0){
            pre[i]=pre[i-1]-v[i];
        }
        else{
            pre[i]=pre[i-1]+v[i];
        }
    }
    ll suff[n];
    suff[n]=(n)%2==0?v[n]:-v[n];
    for(i=n-1;i>=0;i--){
        if(i%2==0){
            suff[i]=suff[i+1]+v[i];
        }
        else suff[i]=suff[i+1]-v[i];
    }
    for(i=0;i<n;i++){
        if((i+1)%2==0){
            ans=max(pre[i]-v[i]-1+suff[i+1],ans);
        }
        else{
            ans=max(pre[i]+v[i]+1+suff[i+1],ans);
        }
    }
    if((n-1)%2==0){
        cout<<ans-m;
    }
    else cout<<ans+m;*/
    ll n,i,t,sum=0;
    cin>>n;
    ll b[n-1];
    for(i=0;i<n-1;i++){
        cin>>b[i];
    }
    sum+=b[0];
    for(i=0;i<n-1;i++){
        if(i==n-1){
            t=b[i];
        }
        else t=b[i+1];
        sum+=min(b[i],t);
    }
    cout<<sum;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;
import std.container;
import std.range;
import core.stdc.stdlib;
import std.math;
import std.typecons;

void main() {
  auto N = readln.chomp.to!int;
  char[] S = cast(char[])readln.chomp;
  
  foreach(i; 0..S.length) {
    S[i] = 'A' + (S[i] - 'A' + N)%26;
  }

  S.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll a[200005],b[200005];
int main(){
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
	}
	sort(a,a+n);
	sort(b,b+n);
	ll low ,hi;
	if(n&1){
		low = a[(n-1)/2];
		hi = b[(n-1)/2];
	}else{
		low = a[(n-2)/2] + a[(n-2)/2+1] ;
		hi = b[(n-2)/2] + b[(n-2)/2+1];
	}
	cout<<hi-low+1<<endl;
	return 0;
}

Measured memory_bytes: 6852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

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

    if(n == 1){
        cout << "Hello World" << endl;
    }
    else{
        int a, b; cin >> a >> b;
        cout << a + b << endl;
    }
}

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

int main(){
	int N,T;
	cin >> N >> T;
	vector<int> t(N);
	for(int i=0;i<N;i++){
		cin >> t.at(i);
	}
	int ans = 0;
	for(int i=0;i<N-1;i++){
		int d = t[i+1] - t[i];
		if(T<d){
			ans += T;
		}else{
			ans += d;
		}
	}
	ans += T;
	cout << ans << endl;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	string S;
	cin >> S;

	if(S[0] != '7' && S[1] != '7' && S[2] != '7') cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3616
from collections import Counter,defaultdict,deque
import sys,bisect,math,itertools,string,queue,copy
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inpln(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])

def find(x): # 木の根を求める
    if par[x]==x:
        return x
    else:
        return find(par[x])

def unite(x,y): # xとyの属する集合を併合
    x=find(x)
    y=find(y)
    if x==y:return
    if rank[x]<rank[y]:
        par[x]=y
    else:
        par[y]=x
        if rank[x]==rank[y]:
            rank[x]+=1

def same(x,y): # xとyが同じ集合に属するか判定
    return find(x)==find(y)
 
def main():
    n,k,l = inpm()
 
    global par,rank
    par  = [i for i in range(2*n)]
    rank = [-1 for _ in range(2*n)] 
    for _ in range(k):
        p,q = inpm()
        p-=1
        q-=1
        unite(p,q)
    for _ in range(l):
        r,s = inpm()
        r-=1
        s-=1
        unite(r+n,s+n)

    root_s=defaultdict(int)
    root=[]
    for i in range(n):
        root.append(str(find(i))+' '+str(find(i+n)))
        root_s[root[i]]+=1
    
    ans=[0 for _ in range(n)]
    for i in range(n):
        ans[i] = root_s[root[i]]
    print(*ans) 


if __name__ == "__main__":
    main()


Measured memory_bytes: 143872
fn main() {
    let n: usize = read_line();
    let a: Vec<i64> = read_vec();

    let mut d: Vec<i64> = (0..n).map(|i| a[i]-1-i as i64)
                                .collect();
    d.sort();
    let b = if n%2==0 {(d[n/2-1] + d[n/2])/2} else {d[n/2]};

    let mut ans = 0;
    for i in 0..n {
        ans += (a[i]-b-1-i as i64).abs();
    }

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

fn read_line<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|e|
        e.parse().ok().unwrap()
    ).collect()
}


Measured memory_bytes: 10492
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong f(llong x) {
    return x * x * x * x * x;
}

int main() {
    llong x;
    cin >> x;

    for (int i = -1000; i <= 1000; i++) {
        llong y = x + f(i);

        for (int j = 0; j <= 1024; j++) {
            if (f(j) == y) {
                cout << j << ' ' << i << endl;
                return 0;
            }
        }
    }

    return 1;
}


Measured memory_bytes: 3612
#include<stdio.h>
#define ll long long
long double dpp[305][305][305];

long double dp(ll n,ll a, ll b, ll c)
{
	if(dpp[a][b][c]!=-1)
		return dpp[a][b][c];
	else
	{
		dpp[a][b][c] = (1.0*n)/(1.00*(a+b+c));
		if(a!=0)
			dpp[a][b][c] +=  ((1.0*a)/(1.0*(a+b+c))*(1.0*dp(n,a-1,b,c)));
		if(b!=0)
			dpp[a][b][c] += ((1.0*b)/(1.0*(a+b+c))*(1.0*dp(n,a+1,b-1,c)));
		if(c!=0)
			dpp[a][b][c] += ((1.0*c)/(1.0*(a+b+c))*1.0*dp(n,a,b+1,c-1));
		return dpp[a][b][c];
	}
}	 

int main(void)
{
	ll n;
	scanf("%lld",&n);
	ll a=0,b=0,c=0;
	ll A[n];
	for(ll i = 0;i<n;i++)
	{
		scanf("%lld",A+i);
		if(A[i] == 1) a++;
		if(A[i] == 2) b++;
		if(A[i] == 3) c++;
	}
	long double ans;
	for(ll i = 0;i<305;i++)
		for(ll j = 0;j<305;j++)
			for(ll k = 0;k<305;k++)
				dpp[i][j][k] = -1.0;
	dpp[0][0][0] = 0.0;
	dpp[1][0][0] = 1.0*n;
	ans = dp(n,a,b,c);
	printf("%.14llf\n",ans);
	return 0;
}


Measured memory_bytes: 443520
/*  -*- coding: utf-8 -*-
 *
 * 2919.cc: Training
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a, b, c;
  scanf("%d%d%d%d", &n, &a, &b, &c);

  printf("%d\n", n - (a + b - c));
  return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	if(s.size()==2) cout << s << endl;
	else{
		reverse(s.begin(),s.end());
		cout << s << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAXN 101

using namespace std;
int a[MAXN];
int main()
{
    int n;
    char c;
    int ans=0;
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        char a=getchar();
        if(i&&c!=a)
        {
            ans++;
        }
        c=a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 20
#define MAX_M 20
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, M;
int A[MAX_N][MAX_M];
int B[MAX_M];
int C;

void solve()
{
  int cnt = 0;
  REP(i, N)
  {
    int sum = 0;
    REP(j, M) { sum += A[i][j] * B[j]; }
    sum += C;
    if (sum > 0) cnt++;
  }
  cout << cnt << endl;
}

int main(void)
{
  cin >> N >> M >> C;
  REP(i, M) cin >> B[i];
  REP(i, N) REP(j, M) cin >> A[i][j];
  solve();
  return 0;
}


Measured memory_bytes: 256