akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

bool check(int n){
	while(n){
		if(n%10==7)return true;
		n/=10;
	}
	return false;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n;
	if(check(n))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3640
import java.util.*;

class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      
      	String[] result = new String[n];
      	for (int i = 0; i<n; i++) {result[i] = sc.next();}
      
      	int c0 = 0;
      	int c1 = 0;
      	int c2 = 0;
      	int c3 = 0;
      	String ac = "AC";
      	String wa = "WA";
      	String tle = "TLE";
      	String re = "RE";
      	String s;
      	for (int i=0; i<n; i++) {
        	s = result[i];
          	
          	if (s.equals(ac)) {c0++;}
          	else if (s.equals(wa)) {c1++;}
          	else if (s.equals(tle)) {c2++;}
          	else if (s.equals(re)) {c3++;}
        }
      	
      	System.out.println("AC" + " x " + c0);
      	System.out.println("WA" + " x " + c1);
      	System.out.println("TLE" + " x " + c2);
      	System.out.println("RE" + " x " + c3);
    }
}

Measured memory_bytes: 64964
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int x = sc.nextInt();
    	int xx = x / 2;
    	int ans = 0;

    	for(int i = 1; i <= x; i++){
    		for(int j = 2; j <= x + 1; j++){
    			if(Math.pow(i, j) > ans && Math.pow(i, j) <= x){
    				ans = (int)Math.pow(i, j);
    			}
    		}
    	}

    	System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int w[310];
		int dp[310][310]={};
		REP(i,0,n) cin>>w[i];
		for(int k=1;k<n;k++){
			for(int i=0;i+k<n;i++){
				if(dp[i+1][i+k-1]==k-1&&abs(w[i]-w[i+k])<=1)
					dp[i][i+k]=dp[i+1][i+k-1]+2;
				for(int j=i;j<i+k;j++)
					dp[i][i+k]=max(dp[i][i+k],dp[i][j]+dp[j+1][i+k]);
			}
		}
		p(dp[0][n-1]);
	}
	return 0;
}

Measured memory_bytes: 3472
#include<iostream>
int main(){int t[31],w=1,n,a,b;char c;for(;w<31;)t[w]=w++;for(std::cin>>w>>n;n--;t[a]^=t[b]^=t[a]^=t[b])std::cin>>a>>c>>b;for(n=1;n<w+1;)std::cout<<t[n++]<<'\n';}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
int a[100][100];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) cin>>a[i][j];

int b[100];
for(int i=0;i<m;i++) cin >>b[i];
int c[100] = {};
for(int i=0;i<n;i++)
for(int j=0;j<m;j++) c[i] += a[i][j] * b[j];

for(int i=0;i<n;i++) cout<<c[i]<<endl;

return 0;
}


Measured memory_bytes: 3140
n = gets.to_i
x = n/2*2
a = []

1.upto(x-1){|i| a += [i].product((i+1..x).to_a - [x+1-i]).map{|e| e*" "}}
a += Array.new(x){|i| [i+1,n]*" "} if n.odd?
puts a.size, a

Measured memory_bytes: 5116
n, m = map(int, input().split())
h = list(map(int, input().split()))

s = list(h)

for i in range(m):
    a, b = map(int, input().split())
    if h[a-1] < h[b-1]:
        s[a-1] = 0
    elif h[a-1] > h[b-1]:
        s[b-1] = 0
    else:
        s[a-1] = 0
        s[b-1] = 0

ans = 0

for i in range(n):
    if s[i] == 0:
        continue
    ans += 1

print(ans)


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

int main(){
	string s;
	cin >> s;
	if(s == "SUN"){
		cout << 7;
	}
	if(s == "MON"){
		cout << 6;
	}
	if(s == "TUE"){
		cout << 5;
	}
	if(s == "WED"){
		cout << 4;
	}
	if(s == "THU"){
		cout << 3;
	}
	if(s == "FRI"){
		cout << 2;
	}
	if(s == "SAT"){
		cout << 1;
	}
	return 0;
}



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

int main(){
	std::vector<int> H_list;
	std::vector<int> W_list;
	int H, W;
	std::cin >> H >> W;
	while((H!=0)&&(W!=0)){
		H_list.push_back(H);
		W_list.push_back(W);
		std::cin >> H >> W;
	}
	bool hoge;
	for (int idx = 0; idx < H_list.size(); idx++){
		for (int i = 0; i < H_list[idx];i++){
			if (i % 2 == 0){
				hoge = false;
			}else{
				hoge = true;
			}
			for (int j = 0; j < W_list[idx]; j++){
				if(hoge == false){
					std::cout << "#";
					hoge = true;
				}else{
					std::cout << ".";
					hoge = false;
				}
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
	return 0;
}


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

vector<int> V;
void input()
{
    V.resize(3);
    cin >> V[0] >> V[1] >> V[2];
}

void solve()
{
    sort(V.begin(),V.end());

    int cnt = 0;
    cnt += (V[2] - V[0]) / 2;
    V[0] += (V[2] - V[0]) / 2 * 2;
    cnt += (V[2] - V[1]) / 2;
    V[1] += (V[2] - V[1]) / 2 * 2;

    if (V[2] - V[0] == 0 && V[2] - V[1] == 0) cout << cnt << endl;
    else if (V[2] - V[0] == 1 && V[2] - V[1] == 1) cout << cnt + 1 << endl;
    else  cout << cnt + 2 << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3648
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int MAX(int a,int b){
    return a>b?a:b;
}
int MIN(int a,int b){
    return a<b?a:b;
}
int main()
{   
    int n;
    scanf("%d",&n);
    int b[101];
    for(int i=0;i<n-1;i++){
        scanf("%d",&b[i]);
    }
    long long ans=0;
    int a[n];
    a[0]=b[0];
    for(int i=1;i<n;i++){
        a[i]=b[i-1];
    }
    for(int i=0;i<n-1;i++){
        if(MAX(a[i],a[i+1])<=b[i]){
            continue;
        }else{
            a[i]=MIN(a[i],a[i+1]);
            a[i+1]=MIN(a[i],a[i+1]);
        }
    }
    
   for(int i=0;i<n;i++)ans+=a[i];
    printf("%d",ans);

    return 0;
}


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

using namespace std;

#define llint long long int
#define REP(i,s,l) for(llint i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main() {

//N人
//正解者以外原点
//サバイバル方式

int player;
int life;
int question;
int who;

cin >> player >> life >> question ;

int point[player];
REP(i,0,player){
    point[i] = 0;
}

REP(i,0,question){
    cin >> who; //3ばんならpoint[2]に加算
    point[who-1]++;
}

//30問でlife10なら30-10+1=21問正解する必要がある
//10問でlife20なら -9問 
int norma = question - life + 1;

REP(i,0,player){
    if(point[i] >= norma) cout << "Yes" << endl;
    else cout << "No" << endl;

}

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
typedef long long ll ;
using namespace std ;
ll t=0,e=0,o=0,ans=0;
void digit(ll n)
{
    ll k=5,x;
    while(k<=n)
    {
        ll p ;
        p=(ll)(n/k);
        t+=p;
        e+=(ll)(p/2);
        k*=5;
    }
}
int main()
{
    ll n ;
    cin >> n ;
    digit(n);
    o=t-e;
    if(n%2==0)
    {
        cout << e << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int ss[300];
int main()
{
	int n, sum = 0;
	char str;
	cin >> n;
	memset(ss, 0, sizeof(ss));
	for (int i = 0;i < n;i++)
	{
		cin >> str;
		if (!ss[str])
		{
			sum++;
			ss[str] = 1;
		}
	}
	if (sum == 3)cout << "Three";
	else cout << "Four";
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.Length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n;
	cin >> n;
	int h[n];
	rep(i, n) cin >> h[i];

	bool jud = true;
	int num = h[n - 1];
	for(int i = n - 2; i >= 0; i--){
		if(h[i] <= h[i + 1])continue;
		else if(h[i] - 1 <= h[i + 1]){
			h[i]--;
		}
		else jud = false;
	}

	cout << (jud ? "Yes" : "No");
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()	
	{
		double N = GetDouble();
		double K = GetDouble();

		double ans = 0.0;
		for(double i = 1.0; i <= N; i++)
		{
			double p = 1.0/N;
			double tmp = i;
			while(tmp < K)
			{
				tmp *= 2.0;
				p *= 0.5;
			}
			ans += p;
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int W, H; cin >> W >> H;
	int N; cin >> N;
	vector<int> x(N), y(N);
	REP(i, N) {
		cin >> x[i] >> y[i];
	}
	int xl = 0, xr = W;

	vector<int> X = x, Y = y;
	sort( ALL(X) );
	sort( ALL(Y) );
	int idx = (N-1)/2;
	ll ans = linf;
	int ax = inf, ay = inf;
	vector<int> kx, ky;
	for (int d = -10; d <= 10; ++d) {
		if (idx+d < 0 || idx+d >= N) continue;
		kx.pb(X[idx+d]);
		ky.pb(Y[idx+d]);
	}
	REP(u, kx.size()) REP(w, ky.size()) {
		int sx = kx[u], sy = ky[w];
		vector<ll> a;
		REP(i, N) {
			a.pb( abs(x[i]-sx) + abs(y[i]-sy) );
		}
		sort( ALL(a) );
		ll sum = a[N-1];
		REP(i, N-1) {
			sum += a[i]*2;
		}
		if (sum < ans || (sum == ans && P(sx, sy) < P(ax, ay))) {
			ans = sum;
			tie(ax, ay) = P(sx, sy);
		}
	}
	cout << ans << endl;
	cout << ax << " " << ay << endl;
}

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

//文字列を後ろから見ていくGreedy法

string divide[4]={"dream","dreamer","erase","eraser"};

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

    //後ろから見る操作を簡単にするために左右反転
    reverse(S.begin(),S.end());
    for(int i=0;i<4;++i)reverse(divide[i].begin(),divide[i].end());

    bool can=true;//全体判定
    for(int i=0;i<S.size();)
    {
        bool can2=false;//部分列の判定
        for(int j=0;j<4;++j)
        {
            string d=divide[j];
            if(S.substr(i,d.size())==d)
            {
                can2=true;
                i+=d.size();
            }
        }
        if(!can2)
        {
            can=false;
            break;
        }
    }

    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}

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


int main () {
  string S;
  int ans = 0;
  cin >> S;
  for (int i = 0; i < S.size(); ++i) {
    if (S.at(i) == '+') ++ans;
    else --ans;
  }
  cout << ans << endl;
}

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

const int INF = 1000'000'000;
int c[10][1005];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];

  int ans = INF;
  rep(div, 1 << (h - 1)) {
    int g = 0;
    vector<int> id(h);
    rep(i, h) {
      id[i] = g;
      if ((div >> i) & 1) g++;
    }
    g++;

    rep(i, g) rep(j, w) c[i][j] = 0;
    rep(i, h) rep(j, w) c[id[i]][j] += s[i][j] - '0';

    int num = g - 1;
    vector<int> now(g);
    auto add = [&](int j) {
      rep(i, g) now[i] += c[i][j];
      rep(i, g) if (now[i] > k) return false;
      return true;
    };
    rep(j, w) {
      if (!add(j)) {
        num++;
        now = vector<int>(g);
        if (!add(j)) {
          num = INF;
          break;
        }
      }
    }
    ans = min(ans, num);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String S = sc.next();
        long K = sc.nextLong();

        System.out.println(solve(S, K));

        sc.close();
    }

    static char solve(String S, long K) {
        for (int i = 0; i < K - 1; ++i) {
            char ch = S.charAt(i);
            if (ch != '1') {
                return ch;
            }
        }

        return S.charAt((int) K - 1);
    }
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 15 + 5;

ll n,x[N],y[N],p[N],res[N][N],ans[N];

void dfs(int u,int cnt){
	if(u==n){
		ans[cnt]=min(ans[cnt],accumulate(res[n],res[n]+n,0ll));
		return;
	}
	for(int i=0;i<n;i++) res[u+1][i]=res[u][i];
	dfs(u+1,cnt);
	for(int i=0;i<n;i++) res[u+1][i]=min(res[u][i],p[i]*abs(x[i]-x[u]));
	dfs(u+1,cnt+1);
	for(int i=0;i<n;i++) res[u+1][i]=min(res[u][i],p[i]*abs(y[i]-y[u]));
	dfs(u+1,cnt+1);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
 	cin>>n;
 	for(int i=0;i<n;i++){
 		cin>>x[i]>>y[i]>>p[i];
 		ans[i]=1e18;
 		res[0][i]=p[i]*min(abs(x[i]),abs(y[i]));
 	}
 	dfs(0,0);
 	for(int i=0;i<=n;i++) cout<<ans[i]<<'\n';
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
	int p , r , l;
};

struct Node T[MAX];
int n , D[MAX];

void print(int u)
{
	int i , c;
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].p);
	printf("depth = %d, ",D[u]);
	
	if( T[u].p == NIL) 
	{
		printf("root, ");
	}
	else if(T[u].l == NIL) 
	{
		printf("leaf, ");
	}
	else printf("internal node, ");
	
	printf("[");
	
	for( i = 0, c = T[u].l; c != NIL; i++ , c = T[c].r)
	{
		if(i)
		{
			printf(", ");
		}
	printf("%d",c);
	}
	printf("]\n");
}

int rec( int u , int p)
{
	D[u] = p;
	if(T[u].r != NIL) 
	{
		rec(T[u].r,p);
	}
	if(T[u].l != NIL) 
	{
		rec(T[u].l,p+1);
	}
}

int main(void)
{
	int i , j , d , v , c , l , r;
	scanf("%d",&n);
	for( i = 0; i < n; i++)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	for( i = 0; i < n; i++)
	{
		scanf("%d %d",&v,&d);
		for( j = 0; j < d; j++)
		{
			scanf("%d",&c);
			if( j == 0)
			{
				T[v].l = c;
			}
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}
	for( i = 0; i < n; i++)
	{
		if(T[i].p == NIL) 
		{
		
			r = i;
		}
	}
	
	rec(r,0);
	for( i = 0; i < n; i++)
	{
		print(i);
	}
	return 0;
}



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

void string_init(string &s, int n)
{
  s = "";
  for(int i = 0; i < n; i++)
    s += "0";
}

bool isNatural(int x)
{
  if(x >= 0) return true;
  else return false;
}

int main()
{
  while(1){
    int N, M, Q;
    cin >> N >> M >> Q;
    if(N == 0 && M == 0 && Q == 0) break;
    string S0, B0, S1, B1;
    string_init(S0,N);
    string_init(B0,M);
    int a[M][N];
    for(int i = 0; i < M; i++)
      for(int j = 0; j < N; j++)
        a[i][j] = j;
    for(int i = 0; i < Q; i++){
      cin >> S1 >> B1;
      for(int j = 0; j < N; j++){
        if(S1[j] == '0'){
          for(int k = 0; k < M; k++)
            if(B0[k] != B1[k])
              a[k][j] = -1;
        }else{
          for(int k = 0; k < M; k++)
            if(B0[k] == B1[k])
              a[k][j] = -1;
        }
      }
      S0 = S1;
      B0 = B1;
    }
    for(int i = 0; i < M; i++){
      if(count_if(&a[i][0], &a[i][N], isNatural) == 1){
        int x = *find_if(&a[i][0], &a[i][N], isNatural);
        if(x < 10){
          cout << x;
        }else{
          cout << (char)(x+55);
        }
      }else{
        cout << '?';
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 1360
#include <stdio.h>
int main(void){
    int n[31]={}, who;
    for(int i=1; i<=28; i++){
        scanf("%d", &who);
        n[who]=1;
    }
    
    for(int i=1; i<=30; i++){
        if(n[i]==0){
            printf("%d\n", i);
        }
    }
    return 0;
}



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

int main(){
    constexpr uint_fast32_t mod = 1000000007;

    uint_fast32_t H, W;
    scanf("%lu%lu", &H, &W);
    vector<vector<int_fast32_t>> ans(H + 1, vector<int_fast32_t>(W + 1));

    {
        string S;
        for(auto i = 0; i < H; ++i){
            cin >> S;
            for(auto j = 0; j < W; ++j){
                if(S[j] & 1)ans[i + 1][j + 1] = -1;
            }
        }
    }

    ans[1][1] = 1;

    for(auto i = 1; i <= H; ++i)
        for(auto j = 1; j <= W; ++j)
            if((i + j ^ 2) && !ans[i][j])
                ans[i][j] = (max<int_fast32_t>(0, ans[i - 1][j]) + max<int_fast32_t>(0, ans[i][j - 1])) % mod;

    printf("%lu\n", ans[H][W]);

    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>

using namespace std;

long long N, C, cal;
long long x[100002],v[100002],a[100002],b[100002],c[100002],d[100002],e[200002];

int main(){
  cin >> N >> C;
  int i;
  x[0]=0;
  cal=0;
  a[0]=0;
  int amaxi=0;
  for (i=1;i<=N;++i) {
    cin >> x[i] >> v[i];
    cal += v[i] - (x[i] - x[i-1]);
    a[i] = cal;
    if (a[amaxi] < a[i]) {
      amaxi=i;
    }
    c[i] = a[amaxi];
  }
  cal=0;
  x[N+1] = C;
  b[N+1] = 0;
  int bmaxi=N+1;
  for (i=N;i>0;--i) {
    cal += v[i] - (x[i+1] - x[i]);
    b[i] = cal;
    if (b[bmaxi] < b[i]) {
      bmaxi=i;
    }
    d[i] = b[bmaxi];
  }
  cal=c[N];
  if (d[1]>cal) {
    cal=d[1];
  }
  for (i=1;i<=N;++i) {
    if (a[i]-x[i]+d[i+1] > cal) {
      cal=a[i]-x[i]+d[i+1];
    }
    if (b[i]-(C-x[i])+c[i-1] > cal) {
      cal=b[i]-(C-x[i])+c[i-1];
    }
  }
  cout << cal << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;


int main(){
	map<int,int> mp;
	int N;
	int ans=0;
	int s;
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>s;
		mp[s]++;
	}
	for(auto i=mp.begin();i!=mp.end();i++){
		if(i->first>i->second){
			ans+=i->second;
		}else{
			ans+=i->second-i->first;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4736
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];
    ll ans=0;
    FOR(i,1,n) {
        if((x[i]-x[i-1])*a < b)
            ans += (x[i]-x[i-1])*a;
        else
            ans += b;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
k=1
for i in range(n):
    k = lcm(k,a[i])
ans=0
for i in range(n):
    ans += k//a[i]
ans %= 1000000007
print(ans)


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

using namespace std;

using ll = long long;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PI;

// res: bridges
// v: current node
// from: parent node
int dfs(VVI& g, vector<PI>& res, int v, int& count, int from, VI& low, VI& pre) {
  pre[v] = count++;
  low[v] = pre[v];
  for (VI::iterator it = g[v].begin(); it != g[v].end(); it++) {
    int to = *it;
    if (pre[to] == -1) {
      // destination has not been visited
      // visit destination and update low[v]
      low[v] = min(low[v], dfs(g, res, to, count, v, low, pre));
      if (low[to] == pre[to]) {
        // edge is not contained in a closed path -> bridge
        res.push_back(make_pair(v, to));
      }
    } else {
      if (from == to) {
        // ignore a path to parent
        continue;
      }
      low[v] = min(low[v], low[to]);
    }
  }
  return low[v];
}

// Calculate bridges in a undirected graph.
// Assume graph is connected and has no parallel edges or self-loops.
// g: adjacency list
// V: number of nodes
vector<PI> bridges(VVI& g, int V) {
  vector<PI> res;
  if (V > 0) {
    // assume at least the first vertex exists
    VI low(V, -1);  // lowest reacheable index
    VI pre(V, -1);  // pre-order index
    int count = 0;  // pre-order index counter
    dfs(g, res, 0, count, -1, low, pre);  // start dfs from vertex 0
  }
  return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    VVI g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cout << bridges(g, n).size() << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] x = new int [256];
		int[] y = new int [256];
		Scanner stdIn = new Scanner(System.in);
		int min,max,k=0,h=0;
		while(true)
		{
			int a = stdIn.nextInt();
			if(a==0)
			{
				break;
			}
			else
			{
				for(int i=0;i<a;i++)
				{
					int b = stdIn.nextInt();
					x[i] = b;
				}
				
				min = x[0];
				max = x[0];
				h = x[0];
				
				for(int i=1;i<a;i++)
				{
					h = h + x[i];
					if(min>x[i])
						min = x[i];
					if(max<x[i])
						max = x[i];
				}
				
				y[k]=(h-min-max)/(a-2);
				
				k++;
			}
		}
		
		for(int i=0;i<k;i++)
		{
			System.out.println(y[i]);
		}
	}
}

Measured memory_bytes: 20944
integer :: n
integer,allocatable :: a(:)
integer :: i,k

read *,n
allocate(a(n))
read *,a

do i = 1, n   
   k = 0
   do while (mod(a(i),2) == 0)
      a(i) = a(i) / 2
      k = k + 1
   enddo
   a(i) = k
enddo

print '(i0)',sum(a)
stop
end

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int M,N,k;
int solve(){
    // Your code here!
    vector<int> place(N);
    for(int i=0;i<N;i++) {
        cin >> place.at(i);
    }
    vector<int> dist(N-1);
    for(int i=0;i<N-1;i++) {
        dist.at(i) =place.at(i+1)-place.at(i);
    }
    sort(dist.begin(),dist.end());
    int sum=0;
    if (N <=k){
        sum=0;
    }
    else {
        for(int i=0;i<(N-k);i++) {
            sum +=dist.at(i);
        }
    }
    return sum;
}
int main() {
    cin >>M;
    for (int j=0;j<M;j++) {
    cin >>N >>k;
    cout << solve() << endl;
    }
}


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

int main() {
  
  vector<char> t(4);
  
  rep(i,4) cin >> t.at(i);
  
  sort(t.begin(), t.end());
  
  if(t.at(0) != t.at(3)) {
    if(t.at(0) == t.at(1) && t.at(2) == t.at(3)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  
  
  
}


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

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

ll 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;
    }
}

// 二項係数計算
ll 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;
}

int main() {
    COMinit();

    int N, K;
    cin >> N >> K;
    int red = N-K;
    for (int i = 1; i <= K; i++) {
        ll ans = 0;
        ans = COM(red+1, i) % MOD;
        ans *= COM(K-1, i-1);
        ans %= MOD;
        cout << ans << endl;
    }
}


Measured memory_bytes: 12160
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class DXORWorld {
    ll getXORAccumurate(ll i) {
        if (i<0) return 0;
        if (i % 4 == 1) {
            return 1;
        } else if (i % 4 == 3) {
            return 0;
        } else {
            return getXORAccumurate(i+1) ^ (i+1);
        }
    }

public:
	void solve(std::istream& in, std::ostream& out) {
	    ll A, B;
	    in >> A >> B;
	    out << (getXORAccumurate(B) ^ getXORAccumurate(A-1)) << "\n";
	}
};


int main() {
	DXORWorld solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define f(i,a,b) for (int i = a; i <b ; i++)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	int n; cin>>n;
	int freq[n+1];
	fill(freq,freq+n+1,0);
	f(i,0,n) {
		int a; cin>>a;
		freq[a]++;
	}
	bool found = 0;
	f(a,0,n) {
		int k = freq[a];
		if (a+1>=k+(n-k>0) && 2*(a+1-k) <= n-k && freq[a+1]==n-k)
			found = 1;
	}
	cout << (found?"Yes":"No") << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	
	return 0;
}



Measured memory_bytes: 640
s = gets.chomp.split("")
num=0
ans=0
s.length.times do |i|
  case s[i]
  when /A|C|G|T/
    i.upto(s.length-1) do |j|
      case s[j]
      when /A|C|G|T/
        num+=1
      else
        break
      end
    end
    ans = num if ans < num
    num = 0
  end
end
puts ans

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

int main(){
  char N[200001];
  scanf("%s", N);// scanf("%d", &N);
  int S = 0;
  
  int k = 0;
  
  int L = strlen(N);//N の中に入っている文字の個数
  
  while( k < L ){
    S = S + N[k] - '0';
    k++;//k = k + 1; と同じ
  }
  
  if(S % 9 == 0) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1792
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b=map(int,input().split())
    d=defaultdict(list)
    for i in range(a):
        c,e=map(int,input().split())
        d[c].append(-e)
    for k,v in d.items():
        v=sorted(v)
    ans=[]
    anss=0
    for i in range(1,b+1):
        if i in d.keys():
            for j in d[i]:
                heappush(ans,j)
        if ans:
            anss+=heappop(ans)
    print(-anss)
    
if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

const ll MOD = (ll) 1e9 + 7;

ll mod_pow(ll x, int n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) (ret *= x) %= MOD;

        (x *= x) %= MOD;
        n >>= 1;
    }

    return ret;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n), cnt(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ++cnt[a[i]];
    }

    if (n % 2 != 0 && cnt[0] != 1){
        cout << 0 << endl;
        return 0;
    }

    int s = (n % 2 == 0?1:2);
    while(s <= n - 1){
        if (cnt[s] != 2){
            cout << 0 << endl;
            return 0;
        }
        s += 2;
    }

    cout << mod_pow(2, n / 2) << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mx=100100;
int h[mx];
vector<int>ve[mx]; 
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>h[i];
	while(m--){
		int x,y;
		cin>>x>>y;
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int f=1;
		for(int j:ve[i])
		{
			if(h[i]<=h[j])
			{
				f=0;
				break;
			}
		}
		if(f) ans++;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 9076
n = int(input())
abc = []
for _ in range(n):
    t = [ int(x) for x in input().split() ]
    abc.append(t)

dp = [ [0]*3 for _ in range(n+1) ]

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][j] = max(dp[i+1][j], dp[i][k] + abc[i][j])

print(max(dp[n]))


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

using namespace std;

int main()
{
  int r, c;
  cin >> r >> c;
  vector< vector<int> > ans(r, vector<int> (c));
  vector<int> sum_bar(c), sum_line(r);
  for(int i = 0;i < r;i++)
  {
    for(int j = 0;j < c;j++)
    {
      cin >> ans[i][j];
      sum_bar[j] += ans[i][j];
      sum_line[i] += ans[i][j];
      cout << ans[i][j] << " ";
    }
    cout << sum_line[i] << endl;
  }
  int last = 0;
  for(int i = 0;i < c;i++)
  {
    cout << sum_bar[i] << " ";
    last += sum_bar[i];
  }
  cout << last << endl;
}


Measured memory_bytes: 3132
#include<cstdio>
#include<cmath>
#include<iostream>
#define maxn 100005
using namespace std;

int main(void)
{
    int N;
    cin >> N;
    int a[maxn][3];
    for(int i=1; i<=N; i++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    int dp[N+1][3];
    for(int i=0; i<3; i++){
        dp[0][i] = 0;
    }
    for(int i=1; i<=N; i++){
        for(int j=0; j<3; j++){
            dp[i][j] = max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) + a[i][j];
        }
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2]));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main() {
  int N;
  cin >>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int min =A[0];
  int max =A[0];
  for(int i=0;i<N;i++){
    if(min >A[i]){
      min =A[i];
    }
    if(max <A[i]){
      max =A[i];
    }
  }
  cout<<max-min<<endl;
}

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

#define INF 2147483647

struct data{
	long long from;
	long long to;
	long long val;
};

struct point{
	vector<long long> to;
	vector<long long> val;
};

void init(point p[],data a[],long long w[],long long n){
	for(long long i=1;i<=n;i++){
		w[i] = -INF;
		p[i].to.clear();
		p[i].val.clear();
		a[i].from = a[i].to = a[i].val = 0;
	}
}

void search(point p[],long long x,point tmp[],bool order,bool vis[]){
	vis[x] = true;
	for(long long i=0;i<p[x].to.size();i++){
		if(order){
			tmp[x].to.push_back(p[x].to[i]);
			tmp[x].val.push_back(p[x].val[i]);
		}
		else{
			tmp[p[x].to[i]].to.push_back(x);
			tmp[p[x].to[i]].val.push_back(p[x].val[i]);
		}
		if(vis[p[x].to[i]] == false)
			search(p,p[x].to[i],tmp,order,vis);
	}
}

void make_edge(point p[],data a[],long long x,long long &index,bool vis[]){
	vis[x] = true;
	for(long long i=0;i<p[x].to.size();i++){
		index++;
		a[index].from = x;
		a[index].to = p[x].to[i];
		a[index].val = p[x].val[i];
		if(vis[p[x].to[i]] == false)
			make_edge(p,a,p[x].to[i],index,vis);
	}
	
}

main(){
	long long n,m,k,index,ifrom,ito,ival;
	long long w[2510];
	bool b,vis[2510];
	data a[5010];
	point p[2510],tmp[2510];
	
	cin>>n>>m>>k;
	for(long long i=1;i<=m;i++){
		cin>>ifrom>>ito>>ival;
		p[ito].to.push_back(ifrom);
		p[ito].val.push_back(ival);
	}
	
	index = 0;
	memset(vis,0,sizeof(vis));
	search(p,n,tmp,0,vis);
	init(p,a,w,n);
	memset(vis,0,sizeof(vis));
	search(tmp,1,p,1,vis);
	memset(vis,0,sizeof(vis));
	make_edge(p,a,1,index,vis);
	
	/*
	cout<<index<<endl;
	for(long long i=1;i<=index;i++){
		cout<<a[i].from<<" "<<a[i].to<<" "<<a[i].val<<endl;
	}
	*/
	
	w[1] = 0;
		
	for(long long i=1;i<=n+1;i++){
		b = false;
		for(long long j=1;j<=index;j++)
			if(w[a[j].to] < w[a[j].from] + a[j].val - k){
				b = true;
				w[a[j].to] = w[a[j].from] + a[j].val - k;
			}
		if(b == false)	break;
	}
	if(b)			cout<<-1;
	else if(w[n]<0)	cout<<0;
	else			cout<<w[n];
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
 
const int N = 500005;
char str[N];
int a[N];
bool check(int k,int len)
{
    int sum = k*9;
    int s = 0;
    for(int i = 0;i < len;i++)
    {
        sum += a[i];
        s += sum % 10;
        sum /= 10;
    }
    while(sum)
    {
        s += sum % 10;
        sum /= 10;
    }
    return s <= k*9;
}
int main()
{
    scanf("%s",str);
    int len = strlen(str);
    reverse(str,str+len);
    for(int i = 0;i < len;i++)
        a[i] = (str[i]-'0')*9;
    for(int i = 0;i < len;i++)
        a[i+1] += a[i]/10,a[i] %= 10;
    if(a[len])
        len++;
    int l = 0,r = len*2,mid;
    while(r-l > 1)
    {
        mid = (l+r)>>1;
        if(check(mid,len))
            r = mid;
        else
            l = mid;
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 2688
#include <cstdio>
#include <cstring>

using namespace std;

char t[200001];

int main() {
    int n, i;
    
    scanf("%s", t);
    
    n = strlen(t);
    
    for (i = 0; i < n; i++) {
        if (t[i] == '?') t[i] = 'D';
    }
    
    printf("%s\n", t);
    
    return 0;
}


Measured memory_bytes: 1836
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#ifdef PERVEEVM_LOCAL
    #define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl
#else
    #define debug(x) 238;
#endif

#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define NAME "File"

using ll = long long;
using ld = long double;

#ifdef PERVEEVM_LOCAL
    std::mt19937 rnd(238);
#else
    std::mt19937 rnd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const double PI = atan2(0.0, -1.0);
const int INF = 0x3f3f3f3f;
const ll LINF = (ll)2e18;
const int N = 100100;

ll dp[N];
int h[N];

void run() {
    int n;
    scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
    }

    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        dp[i] = LINF;

        if (i >= 1) {
            dp[i] = std::min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        }
        if (i >= 2) {
            dp[i] = std::min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }

    printf("%lld\n", dp[n - 1]);
}

int main(void) {
    // freopen(NAME".in", "r", stdin);
    // freopen(NAME".out", "w", stdout);

    auto start = std::chrono::high_resolution_clock::now();
    run();
    auto end = std::chrono::high_resolution_clock::now();

    #ifdef PERVEEVM_LOCAL
        std::cerr << "Execution time: "
                  << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count()
                  << " ms" << std::endl;
    #endif

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
using namespace std;
typedef long long LL;

int main() {
  string S; cin >> S;
  LL K; cin >> K;
  LL N = S.size();

  LL cnt = 0;
	for(int i = 1; i < N; ++i) {
		if(S[i] == S[i-1]) {
			++cnt;
      ++i;
    }
  }

  LL c1 = 0, c2 = 0;
	for(int i = 0; i < N && S[i] == S[0]; ++i) ++c1;
	for(int i = N-1; i>=0 && S[i] == S[N-1]; --i) ++c2;

  if (c1 == N) {
    cout << N * K / 2 << endl;
  } else if (S[0] != S.back()) {
    std::cout << cnt * K << endl;
  } else {
    std::cout << cnt * K - (c1/2 + c2/2 - (c1+c2)/2) * (K-1) << endl;
  }
	return 0;
}


Measured memory_bytes: 256
import sys, os

f = lambda:list(map(int,input().split()))
def init():
    if 'local' in os.environ :
        sys.stdin = open('./input.txt', 'r')

def solve():
    n ,m = f()
    for i in range(n):
        a = input()
        print(a)
        print(a)


init()
solve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long double
using namespace std;
int main()
{


    ll k,b,m,q;
    ll c,d,t,i,j,a,n;
    vector<ll> v,s;
    map< pair<ll,ll> ,pair<ll,ll> > ma,sa;
    map< pair<ll,ll> ,pair<ll,ll> > :: iterator it,ki;
    string st,et;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        v.push_back(a);
    }
    c = 0;
    b = -999999999999;
    for(i=0; i+1<n; i++)
    {
        c = 0;
        if(v[i]>=v[i+1])
        {
            c = 1;
            while(v[i]>=v[i+1])
            {
                c++;
                i++;
                if(i==n-1)
                {
                    break;
                }
            }
            if(c>b)
            {
                b = c;
            }
            if(i==n-1)
            {
                break;
            }
        }
    }
    if(b == -999999999999)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<b-1<<endl;
    }
}


Measured memory_bytes: 3444
#include "bits/stdc++.h"
using namespace std;

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string str;

    ll K;
    cin >> str;
    int siz = str.size();
    cin >> K;
    vector <int>  count(0);
    vector <bool> tof(2, false);
    int           counter = 1;
    rep(i, siz - 1) {
        if (str.at(i) == str.at(i + 1)) {
            counter++;
            if (i == 0) { tof.at(0) = true; }
        }
        else if (counter != 1) {
            count.push_back(counter);
            counter = 1;
        }
    }
    if (counter != 1) {
        count.push_back(counter);
        tof.at(1) = true;
    }


    int countsiz = count.size();
    /*rep(i, countsiz) {
        cout << count.at(i);
    }
    cout << endl;*/
    if (siz == 1) { cout << (ll) (K / 2) << endl; return 0; }
    // 全部文字が同じだった時
    if (countsiz == 1) {
        cout << (ll) ((count.at(0) * K  / 2))  << endl;

        return 0;
    }

    // 両端が並ぶ時
    ll sum_e = 0, sum = 0;
    if (str.at(0) == str.at(siz - 1) && (tof.at(0) || tof.at(1))) {
        if (tof.at(0) == true && tof.at(1) == false) {
            sum_e = (ll) (count.at(0) + 1 / 2) * (K - 1);
            for (int i = 1; i < countsiz; i++) {
                sum += (ll) (count.at(i) / 2) * K;
            }
            cout << sum_e + sum + (ll) (count.at(0) / 2) << endl;

            return 0;
        }
        if (tof.at(0) == false && tof.at(1) == true) {
            sum_e = (ll) ((count.at(countsiz - 1) + 1) / 2) * (K - 1);
            for (int i = 0; i < countsiz - 1; i++) {
                sum += (ll) (count.at(i) / 2) * K;
            }
            cout << sum_e + sum + (ll) (count.at(countsiz - 1) / 2) << endl;

            return 0;
        }
        if (tof.at(0) == true && tof.at(1) == true) {
            sum_e = (ll) ((count.at(0) + count.at(countsiz - 1)) / 2) * (K - 1);
            for (int i = 1; i < countsiz - 1; i++) {
                sum += (ll) (count.at(i) / 2) * K;
            }
            cout << sum_e + sum + (ll) (count.at(0) / 2) + (ll) (count.at(countsiz - 1) / 2) << endl;

            return 0;
        }
    }

    rep(i, countsiz) {
        sum += (ll) (count.at(i) / 2) * K;
    }
    cout << sum << endl;

    return 0;
}


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

int main()
{
    int a, b;
    char op;
    while (cin >> a >> op >> b) {
        switch (op) {
        case '+':
            cout << a + b << endl;
            break;
        case '-':
            cout << a - b << endl;
            break;
        case '*':
            cout << a * b << endl;
            break;
        case '/':
            cout << a / b << endl;
            break;
        default:
            return 0;
        }
    }
}



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

t = 1
p = 2
while p * p <= X: # 2からルートxの範囲で素因数分解する
    e = 0
    while X % p == 0:
        X //= p
        e += 1  # 素数のカウント
    t *= p ** (e // N)
    p += 1
t *= X ** (1 // N) # 1または最初に与えられたX（素数）の1乗が残っているので、N個の数に次数を分配する

print(t)


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


int main(){

    int N;
    cin >> N;
    vector<int> X(N);
    for( int i = 0; i < N; i++ ) cin >> X[i];


    vector<int> origin = X;
    sort( X.begin(), X.end() );

    for( int i = 0; i < N; i++ ){
        if( origin[i] < X[N/2] ) cout << X[N/2] << endl;
        else cout << X[N/2-1] << endl;
    }

    return 0;

}

Measured memory_bytes: 3712
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}
int N;

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

    //cout << fixed << setprecision(15);

    cin >> N;
    string s = "";

    if (N == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    while (N != 0)
    {
        if (N > 0)
        {
            if (N % 2 == 0)
            {
                s += "0";
                N /= 2;
                N *= -1;
            }
            else
            {
                s += "1";
                N /= 2;
                N *= -1;
            }
        }
        else if (N < 0)
        {
            N *= (-1);
            if (N % 2 == 0)
            {
                s += "0";
                N = N / 2;
            }
            else
            {
                s += "1";
                N = (N + 1) / 2;
            }
        }
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}


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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int m; cin >> m;
  vector<int> d(m);
  vector<ll> c(m);
  rep(i, m)cin >> d[i] >> c[i];
  ll res = 0;
  ll acc = 0;
  rep(i, m){
    res += c[i];
    acc += c[i] * d[i];
  }
  res--;
  res += (acc - 1) / 9;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560