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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }else if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int max = sc.nextInt();
   int[] a = new int[max];
   int count = 0;
   for(int i=0;i<max;i++){
   int c = sc.nextInt();
     if(c<0){
     count++;
     c = -c;
     }
   a[i] = c;
   }
   long sum =0;
   if(count%2 == 1){
     int min = a[0];
     for(int i = 0;i<a.length;i++)
     {
       if(min > a[i]) min = a[i];
       sum += a[i];
     }
     sum = sum - 2*min;
   }else{
     for(int i =0;i<a.length;i++)
     {
       sum +=a[i]; 
     }
   }
    System.out.print(sum);
   
   
 }
}

Measured memory_bytes: 50252
import sys 
n = int(input())
num = [int(x) for x in input().split()]
t = 0 
while True: 
  for i in range(n):
    if num[i]%2 == 0:
      num[i] //= 2 
    else:
      print(t)
      sys.exit()
  t += 1

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

int main()
{
	int64_t n;
	int x,m;
	cin >> n >> x >> m;

	vector<int> firstappear(m);

	int64_t a=x;
	firstappear[a]=1;
	for (int64_t i=2;i<=n;++i)
	{
		a=(a*a)%m;
		if (firstappear[a]==0)
		{
			firstappear[a]=i;
		}
		else
		{
			// todo
			int64_t loopstart=firstappear[a];
			int64_t inloopcount=n-loopstart+1;
			int64_t period=i-loopstart;
			int64_t loopcount=inloopcount/period;
			int64_t residue=inloopcount%period;
#ifdef NEVER_DEFINED
			fprintf(stderr,"loopstart %d\n",loopstart);
			fprintf(stderr,"inloopcount %d\n",inloopcount);
			fprintf(stderr,"period %d\n",period);
			fprintf(stderr,"loopcount %d\n",loopcount);
			fprintf(stderr,"residue %d\n",residue);
#endif
			int64_t sum=0;
			for (int i=0;i<m;++i)
			{
				if (firstappear[i]==0)
				{
					continue;
				}
				else if (firstappear[i]<loopstart)
				{
					sum+=i;
				}
				else if (firstappear[i]<loopstart+residue)
				{
					sum+=(int64_t)i*(loopcount+1);
				}
				else
				{
					sum+=(int64_t)i*loopcount;
				}
			}
			cout << sum << endl;
			return 0;
		}
	}

	int64_t sum=0;
	for (int i=0;i<m;++i)
	{
		if (firstappear[i]!=0)
		{
			sum+=i;
		}
	}
	cout << sum << endl;
}







Measured memory_bytes: 3772
#include <iostream>
#include <vector>]

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	vector<int> cc(n, 0);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		a--;
		b--;
		cc[a]++;
		cc[b]++;
	}
	for (int i = 0; i < n; i++) {
		cout << cc[i] << endl;
	}
	return 0;
}

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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  
  // s_up
  int up = ty - sy;
  int right = tx - sx;
  rep(i,up) cout << 'U';
  rep(i,right) cout << 'R';

  // t_down
  int down = ty - sy;
  int left = tx - sx;
  rep(i,down) cout << 'D';
  rep(i,left) cout << 'L';

  // s_left
  cout << 'L';
  up = ty - sy + 1;
  right = tx - sx + 1;
  rep(i,up) cout << 'U';
  rep(i,right) cout << 'R';
  cout << 'D';

  // t_right
  cout << 'R';
  down = ty - sy + 1;
  left = tx - sx + 1;
  rep(i,down) cout << 'D';
  rep(i,left) cout << 'L';
  cout << 'U';

  cout << endl;

  return 0;
}

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

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> x = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();
        List<int> y = new List<int>(x);
        y.Sort();

        for (int i = 0; i < x.Count; i++)
        {
            int ans = y[y.Count / 2 - 1];
            if (ans < x[i]) Console.WriteLine(ans);
            else Console.WriteLine(y[y.Count / 2]);
        }
    }
}

Measured memory_bytes: 35272
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const NK = input[0].split(' ').map(item => parseInt(item, 10))
const N = NK[0]
const K = NK[1]
let d = []
let A = []
input.shift()
input.pop()
let dA = input.map(item => item.split(' ').map(item => parseInt(item, 10)))
nosuke = new Map()
for (i = 0; i < K; i++) {
    d.push(dA.shift())
    A.push(dA.shift())
    for (k = 0; k < d[i]; k++) {
        nosuke.set(A[i][k], true)
    }
}

console.log(N - nosuke.size)


Measured memory_bytes: 30364
import java.util.Scanner;

public class Main {
	public static int Merge(int[] arr, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		int[] l = new int[n1 + 1];
		int[] r = new int[n2 + 1];
		for(int i = 0; i < n1; i++) {
			l[i] = arr[left + i];
		}
		l[n1] = Integer.MAX_VALUE;
		for(int i = 0; i < n2; i++) {
			r[i] = arr[mid + i];
		}
		r[n2] = Integer.MAX_VALUE;
		int i = 0;
		int j = 0;
		for(int k = left; k < right; k++) {
			if(l[i] <= r[j]) {
				arr[k] = l[i];
				i++;
			} else {
				arr[k] = r[j];
				j++;
			}
		}
		return right - left;
	}
	public static int MergeSort(int[] arr, int left, int right) {
		int count = 0;
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			int a = MergeSort(arr, left, mid);
			int b = MergeSort(arr, mid, right);
			int c = Merge(arr, left, mid, right);
			count = a + b + c;
		}
		return count;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		int count = MergeSort(arr, 0, n);
		for(int i = 0; i < n; i++) {
			if(i == n - 1) {
				System.out.println(arr[i]);
			} else {
				System.out.print(arr[i] + " ");
			}
		}
		System.out.println(count);
	}
}



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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

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

int main() {

  int a , b ;
  string str ;
  cin >> a >> b ;
  cin >> str ;
  if( a + b + 1 != sz( str ) ){
    cout << "No\n" ;
    return 0 ;
  }

  vector < int > pos ;
  forn( int , i , 0 , sz( str ) ) {
    if( str[ i ] == '-' ) pos.pb( i ) ;
  }

  if( sz( pos ) == 1 && pos.back() + 1 == a + 1 ){
    cout << "Yes\n" ;
  } else cout << "No\n" ;

  return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 998244353
#define int long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;

signed main()
{
	int a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w) {cout<<"NO\n"; return 0;}
	if(abs(a-b)<=abs(v-w)*t) {cout<<"YES\n";}
	else cout<<"NO\n";
	return 0;
}




Measured memory_bytes: 3592
#Python


N = map(int, raw_input().split())
inu=N[0]
saru=N[1]
#print N


def kai(x):
	sum=1
	while x!=1:
		sum=sum*x
		if sum > 1000000007:
			sum = sum%1000000007
		x-=1
	return sum



if inu == saru:
	print kai(inu)*kai(saru)*2%1000000007
elif abs(inu-saru)==1:
	print kai(inu)*kai(saru)%1000000007
else:
	print 0


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

int now,n,k;

int main(){
  int ans=0;
  cin >> n ;

  cout<<(n*n*3)<<endl;
  return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()

result=0
for i in range(1,n):
    ml=min(i,n-i)
    count=0
    for j in range(n-i):
        if s[j]==s[j+i]:
            count+=1
        else:
            result=max(count,result)
            count=0
        if count==ml:
            result=max(result,count)
            break
        result=max(result,count)
print(result)

Measured memory_bytes: 43292
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <sstream>
#include <set>
#include <string>
#include <math.h>
#include <map>
#include <climits>
#include <iomanip>


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

#define ll long long

using namespace std;

void A();
void B();
void C();
void D();
void E();
void F();

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	D();


}

void A() {
	string s;
	cin >> s;

	cout << (s == "ABC" ? "ARC" : "ABC") << '\n';

}

void B() {
	int N, K;
	cin >> N >> K;

	set<int> have;

	forn(k, K) {

		int d;
		cin >> d;

		forn(dd, d) {

			int sn;
			cin >> sn;
			have.insert(sn);

		}
	}

	int c = 0;
	forn(i, N) {
		if (have.find(i+1) == have.end()) c++;
	}

	cout << c;

}

void C() {
	
	int N, M;
	cin >> N >> M;

	vector<int> h;
	forn(i, N) {
		int hh;
		cin >> hh;
		h.push_back(hh);
	}

	vector<vector<int>> adj(N);

	forn(m, M) {

		int a, b;
		cin >> a >> b;

		adj[a - 1].push_back(b - 1);
		adj[b - 1].push_back(a - 1);

	}
	
	int r = 0;
	forn(i, N) {

		bool good = true;
		for (int ind : adj[i]) {
			if (h[ind] >= h[i]) good = false;
		}

		if (good) r++;

	}

	cout << r;

}

void D() {
	int X;
	cin >> X;

	vector<ll> dp(1000);

	ll A, B;

	for (int i = -126; i < 126; i++) {

		if (dp[i + 130] == 0) {
			dp[i + 130] = pow(i, 5);
		}
		A = dp[i + 130];

		for (int j = -126; j < 126; j++) {

			if (dp[j + 130] == 0) {
				dp[j + 130] = pow(j, 5);
			}
			B = dp[j + 130];
			
			if (A - B == X) {
				cout << i << " " << j;
				return;
			}


		}
	}
}

void E() {
	int N;
	cin >> N;

	vector<int> e;
	map<int, int> m;
	map<int, int> m2;
	forn(i, N) {
		int ee;
		cin >> ee;
		e.push_back(ee);
		int dif1 = (i + 1) - ee;
		int dif2 = (i + 1) + ee;
		m[dif1]++;
		m2[dif2]++;

	}


	int count = 0;
	forn(i, N) {

		int ee = e[i];
		int dif1 = (i + 1) - ee;
		int dif2 = (i + 1) + ee;

		count += m2[dif1];
		count += m[dif2];

	}

	cout << count;



}

void F() {
	int T;
	cin >> T;
	for (int t = 1; t <= T; t++) {

		int N;
		cin >> N;


		int result = 0;

		cout << "Case #" << t << ": ";

		cout << result << endl;

	}
}



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

int main() {
	int n, d, x;
	int a[100];
	cin >> n >> d >> x;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	int cnt = 0;
	int day;
	for (int i = 0;i < n;i++) {
		day = 0;
		for (int j = 0;day <= d;j++) {
			day = j*a[i] + 1;
			if (day <= d) {
				cnt++;
			}
		}
	}
	cout << cnt + x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << endl
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N=100000;
ll n,ans,m;
void  generator()
{	m=n;
	while(n>0)
	{
		ans+=n%10;
		n/=10;
	}
	if(m%ans==0)
	cout << "Yes";
	else
	cout << "No";
}
int main()
{
	cin >> n;
	generator();
}


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

using namespace std ;

#define ll long long

ll a , b , c , d , e , cnt , ans ;

int main ()
{
    cin >> a ;
    for ( int i = 1 ; i <= a ; i += 2 ){
        for ( int j = 1 ; j <= i ; j += 2 ){
            if ( i % j == 0 ){
                cnt ++ ;
            }
        }
        if ( cnt == 8 ){
            ans ++ ;
        }
        cnt = 0 ;
    }
    cout << ans ;

}


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

int main() {
  int N;
  cin >> N;
  
  int flag = 0;
  for (int i = 0; i < N; i++) {
    string x;
    cin >> x;
    
    if(x == "Y") flag = 1;
  }
  
  if(flag == 1) cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

template <class T> bool chmax(T& a, T b) {if(a<b){a = b; return 1;} return 0;}

int N;
vector<int> s;

int main() {
    cin >> N; s.resize(N);
    for (int i = 0; i < N; i++) cin >> s[i];
    int sum = accumulate(s.begin(), s.end(), 0);
    vector<int> selects;
    for (int i = 0; i < N; i++) if (s[i]%10) selects.push_back(s[i]);
    if (!selects.size()) {
        cout << 0 << endl;
        return 0;
    }
    if (sum%10) {
        cout << sum << endl;
        return 0;
    }
    sort(selects.begin(), selects.end());
    cout << sum-selects[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#UnionFindクラス
class UnionFind(object):
 
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        self.size=[1 for i in range(n)]
 
    def find(self, x):
  
        if self.par[x] == x:
            return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x]+=self.size[y]
            
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def tree_size(self,x):
        return self.size[self.find(x)]
    
def main():
    n,m = map(int, input().split())
    uf = UnionFind(n)
    for i in range(m):
        x, y, z = map(int, input().split())
        x -= 1
        y -= 1
        if not uf.same(x,y):
            uf.union(x,y)
    res = 0
    for i in range(n):
        if uf.par[i] == i:
            res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 8628
#include<stdio.h>
 
int main() {
  int A, B, C,i;
  i=0;
  scanf("%d %d %d", &A, &B, &C);
  if((A==5 && B==5 && C==7) || (A==5 && B==7 && C==5) || (A==7 && B==5 && C==5)){
    printf("YES\n");}
  else
    printf("NO\n");
  return 0;
}

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

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if ( A1 + A2 + A3 >= 22 ) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    lr = []
    for _ in range(n):
        x,l = map(int, input().split())
        lr.append((x-l, x+l))
    lr.sort(key=lambda a: a[1])
    res = 0
    cur = -10**10
    for i in range(n):
        if cur <= lr[i][0]:
            cur = lr[i][1]
            res += 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18632
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int power(int n){
	return n*n*n*n*n;
}
 
int32_t main(void){
	IOS;
	
	in(n);
	rep(i, 0, 151)
	{
		rep(j, -i, i+1)
		{
			if(power(i) - power(j) == n)
			{
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
}

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

int main(){
    int q, h, s, d;
    cin >> q >> h >> s >> d;
    long long n;
    cin >> n;
    int one = min({q*4, h*2, s});
    if (d > one*2) cout << n * one << endl;
    else cout << (n / 2) * d + (n % 2) * one << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0085

"""
import sys
from sys import stdin
input = stdin.readline


def solve(n, m):
    remaining = list(range(1, n+1))
    start = n - 1               #  ????????????????????????????????????
    while n > 1:
        v = (m+start) % n       #  ????????????????±???????
        remaining.pop(v)
        start = v - 1           #  ????????????????????¢????????£??????????????????
        n -= 1
    return remaining[0]


def main(args):
    while True:
        n, m = map(int, input().split())
        if n == 0 and m == 0:
            break
        result = solve(n, m)
        print(result)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7788
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: usize = sc.cin();
    let mut hs: Vec<u64> = sc.vec(n);
    if n <= k {
        put!(0);
        return;
    }
    hs.sort();
    put!((0..n-k).map(|i| hs[i]).sum::<u64>());
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


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

int main(){
    int h, w, j = 0;
    cin >> h >> w;
    string c[h+1], ans[h*2+1];

    for(int i = 0; i < h; i++) cin >> c[i];

    for(int i = 0; i < h; i++){
        ans[j] = c[i];
        ans[j+1] = c[i];
        j += 2;
    }

    for(int i = 0; i < h * 2; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int t[105][105];

int main () {
  int r, c;
  cin >> r >> c;
  rep(i,r)rep(j,c) cin >> t[i][j];
  rep(i,r) {
    rep(j,c) t[i][c] += t[i][j];
  }
  rep(j,c+1) {
    rep(i,r) t[r][j] += t[i][j];
  }
  rep(i,r+1)rep(j,c+1) {
    printf("%d%c", t[i][j], j==c ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define SIZE 20
#define BT (1<<16)
#define INF 1000000000000000LL
using namespace std;
typedef long long int ll;

int X[SIZE],Y[SIZE],P[SIZE];
ll score[BT];
ll dp[BT][SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d %d %d",&X[i],&Y[i],&P[i]);
	for(int S=1;S<1<<n;S++)
	{
		score[S]=INF;
		for(int i=0;i<n;i++)
		{
			int x=X[i];
			ll sx=0;
			for(int k=0;k<n;k++) if(S>>k&1) sx+=(ll) abs(X[k]-x)*(ll) P[k];
			score[S]=min(score[S],sx);
			
			int y=Y[i];
			ll sy=0;
			for(int k=0;k<n;k++) if(S>>k&1) sy+=(ll) abs(Y[k]-y)*(ll) P[k];
			score[S]=min(score[S],sy);
		}
	}
	for(int S=0;S<1<<n;S++)
	{
		ll score=0;
		for(int k=0;k<n;k++) if(S>>k&1) score+=(ll) min(abs(X[k]),abs(Y[k]))*(ll) P[k];
		for(int k=0;k<=n;k++)
		{
			dp[S][k]=score;
		}
	}
	for(int k=0;k<=n;k++) dp[0][k]=0;
	for(int S=0;S<1<<n;S++)
	{
		for(int k=0;k<n;k++)
		{
			if(dp[S][k]==INF) continue;
			int Z=(1<<n)-1-S;
			for(int T=Z;T>0;T=(T-1)&Z)
			{
				dp[S|T][k+1]=min(dp[S|T][k+1],dp[S][k]+score[T]);
			}
		}
	}
	for(int i=0;i<=n;i++) printf("%lld\n",dp[(1<<n)-1][i]);
}

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

const double pi = acos(-1);
struct cp {
	double x, y;
	cp operator+(cp a) { return { x + a.x,y + a.y }; }
	cp operator-(cp a) { return { x - a.x,y - a.y }; }
	cp operator*(cp a) { return { x*a.x - y * a.y,x*a.y + y * a.x }; }
};

const int maxn = 2100010;
int rev[maxn]; cp w[maxn];
void fft(cp x[], int len, int on) {

	for (int i = 0; i < len / 2; i++) {
		double alpha = 2 * pi*i / len;
		double c = cos(alpha), s = sin(alpha);
		w[i] = { c,s }; w[i + len / 2] = { -c,-s };
	}

	for (int i = 0; i < len; i++)rev[i] = (i & 1)*(len >> 1) + (rev[i >> 1] >> 1);
	for (int i = 0; i < len; i++)if (i < rev[i])swap(x[i], x[rev[i]]);
	for (int i = 2; i <= len; i <<= 1) {
		int wn = len / i, d = i >> 1;
		for (int j = 0; j < len; j += i) {
			int wk = 0;
			for (int k = j; k < j + d; k++) {
				cp a = x[k], b = w[wk] * x[k + d];
				x[k] = a + b, x[k + d] = a - b;
				wk += wn;
			}
		}
	}
	if (on == -1) {
		reverse(x + 1, x + len);
		for (int i = 0; i < len; i++)x[i].x /= len;
	}
}

// void work(cp x[], int n, cp y[], int m) {
// 	int len = 1;
// 	while (len <= n + m)len <<= 1;

// 	fft(x, len, 1); fft(y, len, 1);
// 	//这里是虚数的相乘不仅仅只是实部！！！
// 	for (int i = 0; i < len; i++)x[i] = x[i] * y[i];
// 	fft(x, len, -1);
// 	//有效长度n+m,请使用int(x+0.5)(负0),对于负数为int(x-0.5)
// 	for (int i = 0; i <= m + n; i++)cout << int(x[i].x + 0.5) << " "; cout << endl;
// }

cp a[maxn];
int x[maxn],y[maxn],base=5,mod=200003;
ll z[maxn];
int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	// int n, m; cin >> n >> m;
	// for (int i = 0; i <= n; i++)cin >> a[i].x;
	// for (int i = 0; i <= m; i++)cin >> b[i].x;
	// work(a, n, b, m);

    int now=1;
    for(int i=0;i<mod-1;i++){
        x[now]=i;
        now=now*base%mod;
    }
    int n;cin>>n;
    for(int i=1;i<=n;i++) {
        int tmp;cin>>tmp;if(tmp==0)continue;
        y[x[tmp]]++;z[x[tmp]*2]--;
    }

    int len=1<<19;
    for(int i=0;i<len;i++) a[i].x=y[i];
    fft(a, len, 1);
    for(int i=0;i<len;i++) a[i]=a[i]*a[i];
    fft(a,len,-1);
    for(int i=0;i<len;i++) z[i]=(z[i]+(ll)(a[i].x + 0.5))/2;
    
    ll ans=0,now2=1;
    for(int i=0;i<len;i++){
        ans+=1ll*now2*z[i];
        now2=now2*base%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 28048
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int A,B,m;cin >> A >> B >> m;
  vector<int> a(A),b(B);
  rep(i,A) cin >> a[i];
  rep(i,B) cin >> b[i];
  vector<int> x(m),y(m),c(m);
  rep(i,m) {
    cin >> x[i] >> y[i] >> c[i];
    x[i]--;y[i]--;
  }
  int res = 1e+9;
  rep(i,m){
    res = min(res,a[x[i]]+b[y[i]]-c[i]);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  res = min(res,a[0]+b[0]);
  cout << res << "\n";
  return 0;
}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;


#define INF 999999999
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

int main() {
	
	int n, ans = 1,b = 1;

	cin >> n;
	

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		ans *= 3;
		if (a % 2 == 0)b *= 2;
	}
	cout << ans -b << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

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

  ll ans=0;
  bool flag=false;

  for(int i=sz-1; i>=0; i--){
    int tmp = (int)(s[i]-'0');
    if(flag){
      tmp++;
//      if(tmp==10){continue;}
      flag=false;
    }    

    if(tmp>5){
      flag=true;
      ans += (10-tmp);
      continue;
    }
    if(tmp<5){
      flag=false;
      ans += tmp;
      continue;
    }
    if(tmp==5){
      if(i==0){
        flag=false;
        ans += tmp;
        continue;
        }
      if((int)(s[i-1]-'0')<=4){
        flag=false;
        ans += tmp;
        continue;
        }
      if((int)(s[i-1]-'0')>=5){
        flag=true;
        ans += (10-tmp);
        continue;
        }
    }
  }
  if(flag){ans++;}

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1412
d = int(input())
c = list(map(int,input().split()))
s = []
p = [1]*d
for i in range(d):
    s.append(list(map(int,input().split())))
x = [1]*26
for i in range(d):
    q = 1
    m = -1
    for j in range(26):
        n = s[i][j] + (x[j]**2 + x[j])*c[j]
        x[j] += 1
        if(m < n):
            m = n
            q = j
    x[q] *= 0
    p[i] = q+1
for i in range(d):
    print(p[i])

Measured memory_bytes: 68396
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 1e5 + 120;
 

int a ,b ,c ,d;
int main(){FAST;
    cin >> a >> b >> c >> d;
    if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes";
    else
        cout << "No";

   return 0;
}
 












Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
// template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
// template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       ll n;
       cin>>n;
       ll a[n];
       for(ll i=0; i<n ;i++){
           cin>>a[i];
       }
       sort(a,a+n);
       reverse(a,a+n);
       ll ans=a[0];ll j=1;
       for(ll i=1; i<n-1 ;i++){
           ans+=a[j];
           if(i%2==0)j++;
           //cout<<j<<" ";
       }
       cout<<ans<<endl;
     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 5160
#include<bits//stdc++.h>
using namespace std;
typedef long long ll;
#define req(i,n) for(int i = 1;i <= n;i++)
#define ALL(a)  (a).begin(),(a).end()
ll n,m, ans = 0;
int main() {
    cin >> n >> m; priority_queue<int> pq; int a, b,j =0;
    vector<pair<int, int>> v;
    req(i, n) {
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }sort(ALL(v));
    req(i, m) {
        for(;j < n;j++)  {
            if (v[j].first <= i) {
                pq.push(v[j].second); continue;
            }
            break;
        }
        if (!pq.empty()) ans += pq.top(), pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1908
n = int(input())
adj = [[None for _ in range(n)] for _ in range(n)]
for i in range(n):
    l = list(map(int, input().split()))
    if l[1] == 0:
        continue 
    else:
        for j in range(2,len(l)):
            adj[l[0]-1][l[j]-1] = 1
color = ['white' for _ in range(n)]
d = [None for _ in range(n)]
f = [None for _ in range(n)]
time = 1

def dfs(node):
    global color
    global d 
    global f
    global time 
    S = [node]
    color[node -1] = 'grey'
    d[node -1] = time 
    while S:
        u = S[-1]
        v = 1
        while v <= n:
            if adj[u-1][v-1] == 1 and color[v-1] == 'white':
                break
            v += 1
        if v < n+1:
            color[v-1] = 'grey'
            time += 1
            d[v-1] = time 
            S.append(v)
        else:
            time += 1
            S.pop()
            color[u-1] = ['black']
            f[u-1] = time

for node in range(1, n+1):
    if color[node-1] == 'white':
        dfs(node)
        time += 1
for i in range(n):
    print(' '.join([str(i+1), str(d[i]), str(f[i])]))



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

using namespace std;

int main()
{
	int n;
	int a[100];
	cin >> n;
	for(int i = 0; i < n; i++)cin >> a[i];
	int ans = 10000000;
	for(int i = -100; i <= 100; i++)
	{
		int tmp = 0;
		for(int j = 0; j < n; j++)tmp += (i - a[j] == 0 ? 0 : (int)pow(i - a[j], 2));
		ans = min(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


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

#define ll long long int

using namespace std;

int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> S(h);
    for (auto & s : S) cin >> s;

    bool gok = true;
    for (ll i = 0; i < h; ++i) {
        for (ll j = 0; j < w; ++j) {
            if (S[i][j] == '.') continue;
            bool ok = false;
            if (i > 0 && S[i-1][j] == '#') ok |= true;
            if (i < h-1 && S[i+1][j] == '#') ok |= true;
            if (j > 0 && S[i][j-1] == '#') ok |= true;
            if (j < w-1 && S[i][j+1] == '#') ok |= true;
            if (!ok) {
                gok = false;
                break;
            }
        }
        if (!gok) break;
    }

    if (gok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int N;
void bfs(vector<vector<int>> &v, vector<vector<int>> &l, int start) {
    vector<int> seen(N,-1);
    seen[start] = 0;
    queue<int> q;
    q.push(start);
    l[seen[start]].push_back(start);

    while(q.size()>0) {
        int next = q.front();
        q.pop();
        for (auto p:v[next]) {
            if (seen[p]==-1) {
                q.push(p);
                seen[p] = seen[next]+1;
                l[seen[p]].push_back(p);
            }
        }
    }
    return;

}

int main(){
    cin >> N;
    vector<vector<int>> d(N,vector<int> (N));
    vector<vector<int>> e(N,vector<int> (N));
    vector<vector<int>> v(N);
    vector<vector<int>> l(N);
    
    rep(i,N) {
        string tmp;
        cin >> tmp;
        rep(j,N) {
            int a = tmp[j]-'0';
            if (a==0) a = INF;
            if (i==j) d[i][j] = 0;
            else {    
                d[i][j] = a;
                e[i][j] = a;
            }
            if (a==1) {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }

    rep(k,N) {
        rep(i,N) {
            rep(j,N) {
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    int smax = 0;
    int start = 0;
    rep(i,N) {
        rep(j,N) {
            if (smax<d[i][j] && d[i][j]<INF) {
                smax = d[i][j];
                start = i;
            }
        }
    }
    bfs(v,l,start);

    bool t = true;
    //cout << smax << endl;
    rep(i,smax+1) {
        rep(j,l[i].size()-1) {
            for (int k=j+1;k<l[i].size();k++) {
                if (e[l[i][j]][l[i][k]]==1) {
                    t = false;
                }
            }
        }
    }
    if (t) cout << smax+1 << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 4380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rpt(i,a,b) for(int i=a;i<=(int)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    string S; cin >> S;

    if (S == "RRR") { cout << 3 << endl; }
    else if (S == "RRS" | S == "SRR") { cout << 2 << endl; }
    else if (S == "RSR" | S == "RSS" | S == "SRS" | S == "SSR") { cout << 1 << endl; }
    else if (S == "SSS") { cout << 0 << endl; }

}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int res = 0;
  for (int a = 0; a <= A; ++a) {
    for (int b = 0; b <= B; ++b) {
      for (int c = 0; c <= C; ++c) {
        int total = 500*a + 100*b + 50*c; // 合計金額
        if (total == X) ++res; //合計金額がXに一致したら答をインクリメント
      }
    }
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 3588
#include <iostream>
using namespace std;
int main(void){
   int c1,c5,c10,c50,c100,c500;
   cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
   int x=c1+c5*5+c10*10+c50*50+c100*100+c500*500;
   if(x >= 1000){
       cout << 1 << endl;
   }
   else{
       cout << 0 << endl;
   }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000009
const long long INF = 1LL<<60;

int main() {
    ll A;
    string B;
    cin>>A>>B;
    ll B100=(B[0]-'0')*100+(B[2]-'0')*10+(B[3]-'0');
    cout<<A*B100/100<<endl;
}

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

const int64_t MOD = 1000000007;
typedef int64_t ll;
typedef uint64_t ull;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

/* 
  //エラトステネスのふるい
  int maxNum = 100000;
  char isNotPrime[maxNum+1] = {};
  isNotPrime[0]=isNotPrime[1]=1;
  for(int i=2;i<maxNum;i++){
    if(isNotPrime[i]==1) continue;
    int num = i+i;
    while(num<=maxNum){
      isNotPrime[num]=1;
      num += i;
    }
  }
*/
// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

// 降順ソート vector<int> v;
// sort(v.begin(),v.end(),greater<int>());

signed main() {
  int n,m;
  cin >> n >> m;
  
  vector< vector<pair<int,int>> > g(n);
  
  int a,b;
  for(int i=0;i<m;i++){
    cin >> a >> b;
    a--;b--;
    g[a].emplace_back(b,i);
    g[b].emplace_back(a,i);
  }
  
  int numBridges = 0;
  for(int i=0;i<m;i++){
    char flag[n] = {};
    queue<int> q; q.push(0);
    
    while(!q.empty()){
      int node = q.front(); q.pop();
      flag[node] = 1;
      for(auto edge: g[node]){
        if(edge.second==i) continue; // should remove this edge;
        if(flag[edge.first]==1) continue; // This is alredy visited
        q.push(edge.first);
      }
    }
    
    for(int j=0;j<n;j++){
      if(flag[j]==0){
        numBridges++;
        break;
      }
    }
  }
  
  cout << numBridges << endl;
  
  return 0;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		double prob[]=new double[n+1];
		for(int i=1;i<=n;i++)
		{
			prob[i]=scan.nextDouble();
		}
		double dp[][]=new double[n+1][n+1];
		dp[1][0]=1-prob[1];
		dp[1][1]=prob[1];
		for(int i=2;i<=n;i++)
		{
			for(int j=0;j<=i;j++)
			{
				dp[i][j]=dp[i-1][j]*(1-prob[i]);
				
				if(j!=0)
				{
					dp[i][j]+=dp[i-1][j-1]*prob[i];
				}
			}
		}
		double ans=0;
		for(int i=(n+1)/2;i<=n;i++)
		{
			ans+=dp[n][i];
		}
		System.out.print(ans);
	}
}


Measured memory_bytes: 124432
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		int k = in.nextInt();
		int total =0;
		total += Math.min(a, k);
		k -= Math.min(a, k);
		if (k==0) {
			System.out.println(total);}
		else {
			k-= Math.min(b, k);
			if (k==0) {
				System.out.println(total);}
			else {
				total -= Math.min(c, k);
				k -= Math.min(c, k);
				System.out.println(total);}}
	}
	
}

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

using namespace std;

bool is753(long long n) {
    string n_str = to_string(n);
    bool ret = (n_str.find('3') != n_str.npos);
    ret &= (n_str.find('5') != n_str.npos);
    ret &= (n_str.find('7') != n_str.npos);
    return ret;
}

long long count753(long long N) {
    vector<long long> candidates({ 33LL, 35LL, 37LL, 53LL, 55LL, 57LL, 73LL, 75LL, 77LL });
    long long pow10 = 100LL;
    long long ans = 0LL;
    for (long long d = 3; d < 11; ++d) {
        vector<long long> nextCandidate;
        for (long long i = 0; i < 3; ++i) {
            long long toAdd = (3LL + 2LL * i) * pow10;
            for (long long j = 0; j < candidates.size(); ++j) {
                long long x = toAdd + candidates[j];
                if (x > N) {
                    return ans;
                }
                nextCandidate.push_back(x);
                if (is753(x)) {
                    ++ans;
                }
            }
        }
        candidates = nextCandidate;
        pow10 *= 10LL;
    }
}

void Main() {
    long long N;
    cin >> N;
    cout << count753(N) << endl;
}

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


Measured memory_bytes: 764
N, M  = list(map(int, input().split()))
K=[list(map(int,input().split())) for i in range(N)]

A = []
for i in range(N):
    for j in range(1,K[i][0] + 1):
        temp = K[i][j]
        A.append(temp)
ans = 0
for i in range(1,31): 
    if A.count(i) == N:
        ans +=1
    if N == 1:
        ans = K[0][0]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;

#define ll signed long long 

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

  ll r = 0;
  ll g = 0;
  ll b = 0;
  for (int i = 0; i < N; ++i) {
    if (s[i] == 'R') ++r;
    if (s[i] == 'G') ++g;
    if (s[i] == 'B') ++b;
  }
  if (r == 0 || g == 0 || b == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = r * g * b;

  for (int i = 1; i < N; ++i) {
    for (int j = 0; j + 2 * i < N; ++j) {
      if (s[j] != s[j + i] &&
          s[j + i] != s[j + i * 2] &&
          s[j + i * 2] != s[j]) {
        --ans;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
import sys
import queue
input = sys.stdin.readline

N,M = map(int,input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    A,B = [int(i)-1 for i in input().split()]
    adj[A].append(B)
    adj[B].append(A)
blis = [True]*N
ans = [0]*N
q = queue.Queue()
cou = 1
q.put(0)
blis[0] = False

while cou != N:
    now = q.get()
    for ad in adj[now]:
        if blis[ad]:
            blis[ad] = False
            ans[ad] = str(now+1)
            cou += 1
            q.put(ad)

print("Yes")
print("\n".join(ans[1:]))


Measured memory_bytes: 42260
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    int n;
    cin >> n;
    int a[n],b[n];
    REP(i,n){
        cin >> a[i];
    }
    REP(i,n){
        cin >> b[i];
    }
    int ans = 0;

    REP(i,n){
        int tmp = 0;
        for(int j=0; j<=i; ++j){
            tmp += a[j];
        }
        for(int j=i; j<n; ++j){
            tmp += b[j];
        }
        ans = max(ans,tmp);
    }
    
    
    cout << ans <<ENT;
    return 0;
}

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


Measured memory_bytes: 256
#n, m = map(int,input().split())
x = int(input())
#hl = list(map(int,input().split()))

if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

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

int n,m;
int a[100002];
int b,c;
priority_queue<pair<int,int> >pq;

int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<m;i++){
		cin>>b>>c;
		pq.push(make_pair(c,b));
	}

	int cnt=0;
	while(!pq.empty()){
		pair<int,int>f=pq.top();pq.pop();
		int val=f.first,lim=f.second;
		while(0<lim && a[cnt]<val && cnt<n){
			a[cnt]=val;cnt++;lim--;
		}
	}

	long long ans=0;
	for(int i=0;i<n;i++){
		ans += a[i];
	}

	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 1784
//organize and stay in moment - Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
#define MAXN (int)2e5+5
#define pb push_back
int mod= 1e9+7;
int mod2=998244353;
int arr[MAXN];
int as;
void input(){
  cin>>as;
  f(i,0,as) cin>>arr[i];
}
int nc2(int n){
	if(n<2)
	return 0;
	int p=n-1;
	if(n&1)
		p/=2;
	else n/=2;
	p*=n;
	return p;
}
bool isPallin(string s){
	int n=s.size();
	f(i,0,n/2)
	if(s[i]!=s[n-i-1])
	return 0;
	return 1;
}
void solve(){
	string s;
	cin>>s;
	int n=s.size();
	int l=n/2;
	string a,b;
	a=s.substr(0,l);
	b=s.substr(n-l,l);
	if(isPallin(s)&&isPallin(a)&&isPallin(b))
	cout<<"Yes\n";
	else cout<<"No\n";

}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t; t=1; //cin>>t;
  while(t--) solve();
  return 0;
}


Measured memory_bytes: 256