akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int k,mod=7,ans=1;
int main()
{
	cin>>k;
	mod=7%k;
	while(mod!=0&&ans<=k)
	{
		ans++;
		mod*=10;
		mod+=7;
		mod%=k;
	}
	if(ans>k) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3632
N, M = map(int, input().split())
A = []
for i in range(N):
	A.append(input())
B = []
for i in range(M):
	B.append(input())
t = 0
for i in range(N-M+1):
	for j in range(N-M+1):
		t = 0
		for k in range(M):
			if t:
				break
			for l in range(M):
				if A[i+k][j+l] != B[k][l]:
					t = 1
					break
		else:
			if A[i+k][j+l] == B[k][l]:
				print("Yes")
				exit()
print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const int INF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    vector<double> a(n);
    rep(i,n)cin >> a[i];
    rep(i,n)a[i] = 1.0 / a[i];
    cout << fixed;
    cout << setprecision(10) <<  1.0 / accumulate(ALL(a),0.0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll maxn=2e3+10, maxm=2e5+500, lg=19, mod=924844033, inf=1e18;

ll n,k,dp[maxn][2],fac[maxn];

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	fac[0]=1; for(int i=1;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
	cin>>n>>k;
	dp[0][0]=1;
	for(int i=1;i<=min(n,k);i++)for(int T:{0,1}){
		for(int j=1;j<=(n-i)/k;j++)for(int l=n;l>=0;l--){
			(dp[l][0]+=dp[l][1])%=mod;
			if(l) dp[l][1]=dp[l-1][0];
		}
		for(int j=0;j<=n;j++) (dp[j][0]+=dp[j][1])%=mod, dp[j][1]=0;
	}
	ll ans=0;
	for(int i=0;i<=n;i++) ans=(ans+(i%2 ? -1:+1)*(dp[i][0]*fac[n-i]%mod)+mod)%mod;
	cout<<ans;
	
	return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <cmath>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

template<class T> inline bool chmax(T &a, T b) {
    if (a < b) a = b; return true;
    return false;
}

void solve(long long N, std::vector<long long> A){
    long long ans = -1;
    REP(i, N) REP(j, N)
        chmax(ans, abs(A[i] - A[j]));
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
"""bfs"""

import sys
sys.setrecursionlimit(10**6)

n = int(input())

to = [[] for _ in range(n)]
eid = [[] for _ in range(n)]
ans = [0]*(n-1)

for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b); eid[a].append(i) # to:nodeの繋がり、eid:edgeの色
    to[b].append(a); eid[b].append(i)

import queue

q = queue.Queue()
used = [0]*n
q.put(0)
used[0] = 1
while not q.empty():
    v = q.get()
    c = -1
    for i in range(len(to[v])):
        u = to[v][i]; ei = eid[v][i]
        if used[u]: c = ans[ei]
    k = 1
    for i in range(len(to[v])):
        u = to[v][i]; ei = eid[v][i]
        if used[u]: continue
        if k == c: k += 1
        ans[ei] = k
        k += 1
        q.put(u)
        used[u] = 1

mx = 0
for i in range(n):
    mx = max(mx, len(to[i]))
print(mx)
for i in range(n-1):
    print(ans[i])

Measured memory_bytes: 40028
#from functools import lru_cache
import sys

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

ls = reader()
n = int(ls[0][0])
wr =ls[1][0]
nr = len(list(filter(lambda a:a=='R',wr)))
nleftr = len(list(filter(lambda a:a=='R',wr[:nr])))
print(nr-nleftr)


Measured memory_bytes: 96520
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    long x = sc.nextLong();

    double temp = 100;
    long l = (long) temp;
    long cnt = 0;

    while (l < x) {
      temp = (double) l;
      cnt++;
      temp = temp * 1.01;
      l = (long) temp;
    }

    System.out.println(cnt);

  }
}


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

int main(){
	int n, a[3];
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int i = 0;i < 3;i++)cin >> a[i];
		sort(a, a+3);
		if(a[0]*a[0] + a[1]*a[1] == a[2]*a[2])cout << "YES" << endl;
		else cout << "NO" << endl;
	}
    return 0;
}

Measured memory_bytes: 3056
#include <stdio.h>
#include<math.h>

#define N 10000
#define TRUE 0
#define FALSE -1

int prime(int);

int main(){
  int n,num[N],i,j,flag=0,count=0;

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

  for(i=0;i<n;i++){
    if(prime(num[i])==TRUE) count++;
  }
  printf("%d\n",count);
  return 0;
}

int prime(int num){
  int i=3;
  if(num==2) return TRUE;

  if(num<2 || num%2==0) return FALSE;

  while(i<=sqrt((double)num)){
    if(num%i==0) return FALSE;
    i=i+2;
  }

  return TRUE;
}

Measured memory_bytes: 632
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	map<int, int> mp;
	rep (i, n) {
		mp[a[i]]++;
		mp[a[i] - 1]++;
		mp[a[i] + 1]++;
	}
	
	int ans = -1;
	for (auto x: mp) {
		chmax(ans, x.se);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i, j, a, b, c;
	cin >> num;
	ll dp[101][4][4][4] = { 0 }, ans = 0;
	dp[0][0][0][0] = 1;
	for(i = 1; i <= num; i++) {
		rep(a, 4) {
			rep(b, 4) {
				rep(c, 4) {
					dp[i][b][c][0] += dp[i - 1][a][b][c];
					dp[i][b][c][1] += dp[i - 1][a][b][c];
					if(b != 1 || c != 3)
						dp[i][b][c][2] += dp[i - 1][a][b][c];
					if(!((min(b, c) == 1 && max(b, c) == 2) || (a == 1 && (b == 2 || c == 2))))
						dp[i][b][c][3] += dp[i - 1][a][b][c];
					rep(j, 4)
						dp[i][b][c][j] %= MOD;
				}
			}
		}
	}
	rep(a, 4) {
		rep(b, 4) {
			rep(c, 4) {
				ans += dp[num][a][b][c];
			}
		}
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe

ll gcd(ll c, ll d) { return d ? gcd(d, c%d) : c;}
ll lcm(ll c, ll d) { return c / gcd(c,   d) * d;}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
int a,b;   
string s;
cin >>s;
a = (s[0]-'0')*10 + (s[1]-'0');
b = (s[2]-'0')*10 + (s[3]-'0');

if ((a >= 13|| a == 0) && (b >= 13|| b == 0))
{
    cout << "NA" << endl;
}else if ((a > 0 && a <= 12)&&(b > 0 && b <= 12))
{   
    cout << "AMBIGUOUS" << endl;
}else if ((a >= 13 || a == 0) && (b <= 12 && b > 0))
{
    cout << "YYMM" << endl;
}else
{
    cout << "MMYY"<< endl;
}











//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	int L,M,N;
	int kari;
	int meter;
	int i;
	int data;

	while (cin >> L) {
		if (L == 0) {
			break;
		}
		meter = 0;
		for (i = 0; i < 12; i++) {
			cin >> M >> N;
			kari = M - N;
			L -= kari;
			if (L <= 0 && meter == 0) {
				meter = 1;
				data = i+1;
			}
		}

		if (meter == 1) {
			cout << data << endl;
		} else {
			cout << "NA" << endl;
		}
	}
	return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    srand((unsigned)time(NULL));
    ll X,Y;
    cin>>X>>Y;
    ll ans=2019;
    for(int i=1;i<=10000000;i++)
    {
        //a+1-Y
        ll a=rand()%(Y-X)+X; //生成[x,y-1]的数
        ll b=rand()%(Y-a)+a+1;
        ll num=a*b%2019;
        ans=min(ans,num);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
    int K, S;
    cin >> K >> S;

    int count = 0;

    for (int x = 0; x <= K && x <= S; x++) {
        for (int y = 0; y <= K && y <= (S - x); y++) {
            if ((S - (x + y)) <= K) count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		
		int N=sc.nextInt();
		int K=sc.nextInt();
		int Q=sc.nextInt();
		
		
		if(K-Q>0) {
			for(int i=0;i<Q;i++) {
				sc.next();
			}
			for(int i=0;i<N;i++) {
				p("Yes");
			}
		}else {
			int t=K-Q;
			int v[]=new int[N];
			
			for(int i=0;i<Q;i++) {
				v[sc.nextInt()-1]++;
			}
			for(int i=0;i<N;i++) {
				if(v[i]+t>0)p("Yes");
				else p("No");
			}
			
		}
		
		 
		
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 67440
#include<stdio.h>
int main(void)
{
  int data[3];
  int work;

  for(int i=0;i<3;i++)
    scanf("%d",&data[i]);

  for(int i=0;i<3;i++)
  {
    for(int k=i+1;k<3;k++)
    {
      if(data[i]>data[k])
      {
        work=data[i];
        data[i]=data[k];
        data[k]=work;
      }
    }
  }
  if(1 <=data[1] &&data[1]<= 10000 && 1 <=data[2] &&data[2]<= 10000 &&1 <=data[0] &&data[0]<= 10000)
    printf("%d %d %d\n",data[0],data[1],data[2]);
}

Measured memory_bytes: 1812
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String c = sc.next();
      	if(c.equals("a") || c.equals("e") || c.equals("i") || c.equals("o") || c.equals("u")){
        System.out.println("vowel");
        }else{
        	System.out.println("consonant");}
    }	
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

using namespace std;
 
#define F first
#define S second
#define EB emplace_back
#define PB push_back
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define ar array
#define sz(x) (int)x.size()
#define bit(x) __builtin_popcount(x)
#define all(x) (x).begin(), (x).end()
#define FOR(c,l,r) for(int c=(l);c<=(r);c++)
 
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
 
using ll = long long;
//#define int ll
 
const int N = 2e6 + 7;
const int MOD = 1e9 + 7;
const int inf = 2e9 + 7;
const int  dx[]  = {-1,   0,   1,   0,  1, -1, -1,  1};
const int  dy[]  = { 0,   1,   0,  -1,  1, -1,  1, -1};
const char dt[] = {'U', 'R', 'D', 'L'};

void solve() {	
	int n, m;
	cin >> n >> m;
	vector <string> a(n);
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
		string s = a[i];
		for (int j = 0; j < m; j ++) {
			s[j] = tolower(s[j]);
		}
	}
	sort(all(a));
	for (auto i : a) cout << i;
}
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
   	//cin >> tt;
    while (tt --){
        solve();
        cout << '\n';
    }
}



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

int A[1003];
vector<long long> X, Y;

long long solve(int K)
{
    long long ans = 0;
    
    for(int i=39; i>=0; i--)
    {
        Y.clear();
        
        for(int j=0; j<X.size(); j++)
            if(X[j] & (1LL << i))
                Y.push_back(X[j]);
        
        if(Y.size() >= K)
            ans += (1LL << i), X = Y;
    }
    
    return ans;
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N, K;
    cin >> N >> K;
    
    for(int i=1; i<=N; i++)
        cin >> A[i];
    
    for(int i=1; i<=N; i++)
    {
        long long sum = 0;
        
        for(int j=i; j<=N; j++)
        {
            sum += A[j];
            X.push_back(sum);
        }
    }
    
    cout << solve(K) << "\n";
    return 0;
}


Measured memory_bytes: 6384
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pl=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

vector<pair<int,int>> prime_factorize(int x){
    vector<pair<int,int>> res;
    for(int i=2;i*i<=x;i++){
        if(x % i != 0) continue; 
        int cnt = 0;
        while(x % i == 0){
            cnt++;
            x /= i;
        }
        res.emplace_back(i, cnt);
    }
    if(x != 1) res.emplace_back(x, 1);
    return res;
}

void solve() {
    int N;
    cin >> N;
    vi A(N);
    rep(i,N){
        cin >> A[i];
    }

    // その数を割り切る最小の素数を記録
    int uplim = 1000001;
    vi d(uplim, -1);
    rng(prime,2,uplim){
        int i = prime;
        while(i < uplim){
            if(d[i] == -1){
                d[i] = prime;
            }
            i += prime;
        }
    }

    // Aの素因子をカウント
    map<int, int> factor_num;
    for(int a : A){
        for(auto p : prime_factorize(a)){
            factor_num[p.fi]++;
        }
    }
    bool is_pairwise = true;
    for(auto f : factor_num){
        if(f.sc >= 2) is_pairwise = false;
    }
    if(is_pairwise){
        print("pairwise coprime");
        return;
    }
    int g = 0;
    rep(i,N) g = gcd(g, A[i]);
    if(g == 1){
        print("setwise coprime");
        return;
    }
    print("not coprime");
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}


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

int main(void)
{
    int i, j;
    int len;
    int ans;
    char str[256];
    char str_r[256];

    ans = 0;

    memset(str,'\0',sizeof(str));
    memset(str_r,'\0',sizeof(str_r));

    while (scanf("%s", str) != EOF){
        len = strlen(str);
        
        j = 0;
        for (i = len - 1;i >= 0;i--){
            str_r[j] = str[i];
            j++;
        }

        if (strcmp(str,str_r) == 0){
            ans++;
        }

        memset(str,'\0',sizeof(str));
        memset(str_r,'\0',sizeof(str_r));

    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
 
int main(){
  int N, D; cin >> N >> D;
  vvi x(N, vi(D));
  rep(i,N)rep(j,D) cin >> x[i][j];
  int count = 0;
  rep(i,N){
    rep2(j, i+1, N){
      float l = 0; 
      rep(k,D) l += pow(x[i][k]-x[j][k],2);
      l = sqrt(l);
      if(floor(l)==l) count++;
    }
  }
  cout << count << endl;  
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
//#define ll __int128
//#define int ll
//#define int ll
//#define char ll
#define double ld
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef MAX_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template<class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template<class T0, class T1>
inline istream &operator>>(istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template<class T0, class T1, class T2>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template<class T0, class T1, class T2, class T3>
inline ostream &operator<<(ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " << get<3>(a) << "}";
}

template<class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MAX_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef MAX_HOME
    cout << "\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

void smain() {

    ll h, m, h2, m2, k;
    cin >> h >> m >> h2 >> m2 >> k;
    m += h * 60;
    m2 += h2 * 60;
    ll ans = m2 - m - k;
    inmax(ans, 0LL);

    cout << ans;

}

Measured memory_bytes: 3660
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

fn string() -> String {
    read()
}

fn int() -> i64 {
    read()
}

fn char() -> char {
    read::<String>().pop().unwrap()
}

fn vecchar() -> Vec<char> {
    string().chars().collect()
}

fn vecint(n: i64) -> Vec<i64> {
    let mut vec = Vec::new();
    for i in 0..n {
        vec.push(int())
    }
    vec
}

fn main() {
    let (a, b, c) = (vecchar(), vecchar(), vecchar());
    println!(
        "{}",
        if a.last().unwrap() == &b[0] && b.last().unwrap() == &c[0] {
            "YES"
        } else {
            "NO"
        }
    )
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int main() {
    int a; cin >> a;
    out(lcm(a, 2));
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int p[200007];
int par(int x){ return (p[x] == x) ? x : (p[x] = par(p[x])); }
void merge(int a, int b){ p[par(a)] = par(b); }
 
int main(){
	for(int i = 0; i < 200007; i++) p[i] = i;
	int n, m, k, a;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
		cin >> k;
        for(int j = 0; j < k; j++){
			cin >> a;
            merge(i, n+a+1);
        }
    }
    for(int i = 0; i < n; i++){
    	if(par(i) != par(1)){
			cout << "NO\n";
            return 0;
            }
}
	cout << "YES\n";
}

Measured memory_bytes: 1792
//ABC 064 B - Traveling AtCoDeer Probrem 
#include <iostream>
#include <vector>
#include <algorithm>

int main(void){
  int N;
  std::cin >> N;
  
  std::vector<int> v;
  
  for(int i = 0 ; i<N ; i++){
    int k;
    std::cin >> k;
    v.push_back(k);
  }
  
  sort(v.begin(),v.end());
  std::cout << v[N-1]-v[0] << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;

int main(){
    ll n,k;
    std::cin >> n>>k;
    std::cout << min(n%k,k-(n%k)) << std::endl;
}

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

int main(void){
int n,m;
int sum=0;
int aa;
int a[100005];

scanf("%d %d",&n,&m);

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

for(int i=0;i<m;i++){
    sum=sum+a[i];
}
aa=n-sum;
if(aa>=0){printf("%d\n",aa);}
else{printf("-1\n");}
}

Measured memory_bytes: 1768
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ++ii)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define emp emplace
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n;
int main()
{
		FAST
		ll m;
		cin>>n>>m;
		m+=n*3;
		cout<<m/2<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
 
    int main()
    {
        
   char x ;                             //,a , e , i ,o , u ;
   
   cin >> x;
   if ( x=='a' || x=='e' || x=='o' || x=='i' || x=='u')
   
   cout <<"vowel";
   else
   cout << "consonant";
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;int flag=-1;
  cin>>n;
  while(n!=0)
  {
    if((n%10)==7)
    {
      cout<<"Yes";
      flag=0;
      break;
    }
    n=n/10;
  }
  if(flag==-1)
    cout<<"No";
}


Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC_IHCA
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            long D = RL();
            long[] Ca = RLa(26);
            long[,] La = RLa(D, 26);


            long msum = 0;
            for (int j = 0; j < 26; ++j)
            {
                msum += Ca[j];
            }
            long[] minus = new long[26];
            for (int j = 0; j < 26; ++j)
            {
                minus[j] = msum - Ca[j];
            }

            for (int i = 0; i < D; ++i)
            {
                Console.WriteLine(max(La, i, minus) + 1);
//                Console.WriteLine((i % 26) + 1);
            }

#if DEBUG
            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int max(long[,] La, int i, long[] minus)
        {
            long m = long.MinValue;
            int midx = 0;
            for (int j = 0; j < 26; ++j)
            {
                if (La[i, j] - minus[j] > m)
                {
                    m = La[i, j] - minus[j];
                    midx = j;
                }
            }
            return midx;
        }

        static long RL()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] RLa(long n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            long[] la = new long[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = long.Parse(sa[i]);
            }
            return la;
        }

        static long[,] RLa(long r, long c)
        {
            long[,] la = new long[r, c];
            for (int i = 0; i < r; ++i)
            {
                string[] sa = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; ++j)
                {
                    la[i, j] = long.Parse(sa[j]);
                }
            }
            return la;
        }
    }
}


Measured memory_bytes: 28144
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int n;cin>>n;
  vector<i_i> G[n+10];
  int u,v,w;
  REP(i,n-1) {
    cin>>u>>v>>w;
    G[u-1].push_back(make_pair(v-1,w));
    G[v-1].push_back(make_pair(u-1,w));
  }

  // p("===");

  // 幅優先探索
  bool seen[n+10]={false};
  queue<int> todo;
  todo.push(0);
  int result[n+10];
  result[0]=0;
  int tar_v;
  while(todo.size()!=0) {
    tar_v=todo.front();
    todo.pop();
    if(!seen[tar_v]) {
      for(i_i g: G[tar_v]) {
        // p(tar_v+1,g.first+1,g.second);
        // p(g.first);
        // p(g.second);
        todo.push(g.first);
        if(g.second%2==0) {
          result[g.first] = result[tar_v];
        } else {
          result[g.first] = (result[tar_v]+1)%2;
        }
      }
      seen[tar_v]=true;
    }
  }

  // p("===");

  REP(i,n) p(result[i]);
  return 0;
}

// 9
// 1 3 8
// 2 3 5
// 3 4 2
// 4 8 3
// 4 9 4
// 2 5 3
// 5 6 4
// 5 7 1


Measured memory_bytes: 6912
import math
def input_parser():
    N, M=(int(str) for str in input().split())
    return N, M
N, M=input_parser()
if N*2>M:
    ans=math.floor(M/2)
else:
    remc=M-N*2
    ans=N+math.floor(remc/4)

def output_parser(output):
    print(output)

output_parser(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

//x,y structure
typedef struct{
  double x;
  double y;
}XY;

//flag
bool flagfirst=true;

//function kochCurve
void kochCurve(XY p1,XY p2,int n){
  XY s,u,t;
  //calculate x,y
  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  u.x=(t.x-s.x)*cos(M_PI/3)-(t.y-s.y)*sin(M_PI/3)+s.x;
  u.y=(t.x-s.x)*sin(M_PI/3)+(t.y-s.y)*cos(M_PI/3)+s.y;

  //print to 8 decimal places
  if(flagfirst==true) {
    printf("%.8f  %.8f\n",p1.x,p1.y);
    flagfirst=false;
  }
 
  //execute and print
  if(n>0){
    kochCurve(p1,s,n-1);
    printf("%.8f  %.8f\n",s.x,s.y);
    kochCurve(s,u,n-1);
    printf("%.8f  %.8f\n",u.x,u.y);   
    kochCurve(u,t,n-1);
    printf("%.8f  %.8f\n",t.x,t.y); 
    kochCurve(t,p2,n-1);
  } 

}

int main(){

  int n;
  XY p1,p2;

  //load number
  cin >>n;

  //initialize
  p1.x=0;
  p1.y=0;
  p2.x=100;
  p2.y=0;


  //execute kochCurve
  kochCurve(p1,p2,n);
  //print end of x and y
  printf("%.8f  %.8f\n",p2.x,p2.y);   

  return 0;

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,x;cin>>n>>x;
    set<int> s;
    int k;
    for(int i=0;i<n;i++){
        cin>>k;
        x-=k;;
        s.insert(k);
    }
    k=*begin(s);
    cout<<n+x/k<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N; cin >> N;
    mat a(N, vec(N));
    REP(i, N) readv(a[i]);

    mat dp(N + 1, vec(1 << N, 0));
    dp[0][0] = 1;
    int mod = 1000000007;
    REP(i, N){
        int k = (1 << (i + 1)) - 1;
        while(k < (1 << N)){
            REP(j, N){
                if(a[i][j] == 1 && ((k >> j) & 1) == 1) dp[i + 1][k] += dp[i][k ^ (1 << j)];
                dp[i + 1][k] %= mod;
            }
            int x = k & -k, y = k + x;
            k = ((k & ~y) / x >> 1) | y;
        }
    }
    //debug(dp);
    cout << dp[N][(1 << N) - 1];
    
    return 0;
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> vec(5);
  rep(i,5) cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  ll ans = 0;
  if (n % vec.at(0) > 0) ans++;
  ans += n / vec.at(0) + 4;
  cout << ans << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int a[MAX_N][3];
int dp[MAX_N][3];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    rep(i,n){
        rep(j,3){
            srep(k,1,3){
                cmx(dp[i+1][(j+k)%3], dp[i][j]+a[i][(j+k)%3]);
            }
        }
    }
    cout << *max_element(dp[n], dp[n]+3) << "\n";
    return 0;
}

Measured memory_bytes: 2560
/* 
 * Project: AtCoder Beginners Contest 169 C - Multiplication 3
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/31
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <string>
#include <iostream>
using namespace std;

long a;
string b;

void solve() {

    string b_dec = b.substr(0,1)+b.substr(2,2);
    long mul = a * stoi(b_dec);

    printf("%ld\n", (long)mul/100);

}

int main() {

    scanf("%ld", &a);
    cin >> b;

    solve();
}

Measured memory_bytes: 3228
n = int(input())						# 5
a = list( map(int, input().split()) )	# 1 2 3 4 5 ...

ans=0
for i in a:
	b = True
	while b:
		if (i//2)==(i/2):
			ans+=1
			i = i//2
		else:
			b=False
			
print(ans)


Measured memory_bytes: 4148
# 問題　解釈違い…最近多い…

import sys
h,w,k=map(int,input().split())
a=list(sys.stdin.read().split())
ans=0
for i in range(2**h-1):
    for j in range(2**w-1):
        cnt=0
        for y in range(h):
            if i>>(y)&1:
                continue
            for x in range(w):
                if j>>(x)&1:
                    continue
                if a[y][x]=="#":
                  cnt+=1
                
        if cnt==k:
            ans+=1
print(ans)




Measured memory_bytes: 9212
#include <iostream>
#include <vector> 
#include <algorithm>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    ll N,W;

    cin >> N >> W;

    vector<long> wight(N);
    vector<long> value(N);

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

    vector<vector<ll> > dp(110,vector<ll>(100010,1e10));

    dp[0][0] = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < 100010; j++)
        {
            if(j - value[i] >= 0){
                dp[i+1][j] = min(dp[i+1][j],dp[i][j-value[i]] + wight[i]);
            }
            
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            
        }
    }

    long ans = 0;
    for(int i = 0;i < 100010;i++){
        if(dp[N][i] <= W){
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 87296
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
  
 int N,Y; 
 cin>>N>>Y;
 bool Q=false;
   
 for(int a=0;a<N+1;a++){
   for(int b=0;b<N-a+1;b++){
     int c=N-a-b;
       if(1000*a+5000*b+10000*c==Y){
         cout<<c<<" "<<b<<" "<<a<<endl;
         Q=true;
         break;
       }
     }
      if(Q){
        break;
      }
    }
     
     if(Q==false){
       cout<<-1<<" "<<-1<<" "<<-1;
     }
}
   


Measured memory_bytes: 3588
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  string ans;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == 'B') {
      if (ans.length() > 0) {
	ans.erase(ans.length()-1, 1);
      }
    } else {
      ans += s[i];
    }
  }

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


Measured memory_bytes: 256
#abc149_d
from sys import stdin

#stdin = open("test/abc149_d_sample-2.in")

N, K = map(int, stdin.readline().strip().split(" "))
R, S, P = map(int, stdin.readline().strip().split(" "))
T = stdin.readline().strip()

pmap = {
  "r": R,
  "s": S,
  "p": P
}

winmap = {
  "r": "p",
  "s": "r",
  "p": "s"
}

point = 0
T2 = list(T)
#print(N,K)

for i,t in enumerate(T):
  #print(t)
  wintp = "x"
  if i>K-1:
    tp = T2[i-K]
    if tp!="x":
      wintp = winmap[tp]
  
  wint = winmap[t]
  if wint!=wintp:
    point += pmap[wint]
  else:
    T2[i] = "x"

#print(T2)
print(point)


Measured memory_bytes: 4084
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//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(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl


ll get_result(vector<ll>& As, vector<vector<ll>>& abcds) {
	ll res = 0;
	for (ll i = 0; i < abcds.size(); ++i) {
		if (As[abcds[i][1]] - As[abcds[i][0]] == abcds[i][2]) {
			res += abcds[i][3];
		}
	}
	return res;
}

ll solve(vector<ll>& As, ll idx, ll M, vector<vector<ll>>& abcds) {
	if (idx == As.size()) {
		return get_result(As, abcds);
	}
	
	ll A_begin = (idx > 0 ? As[idx - 1] : 1);
	ll res = 0;
	for (ll i = A_begin; i <= M; ++i) {
		As[idx] = i;
		res = max(res, solve(As, idx + 1, M, abcds));
	}
	return res;
}

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

	ll N, M, Q;
	cin >> N >> M >> Q;
	
	vector<vector<ll>> abcds(Q, vector<ll>(4));
	for (ll i = 0; i < Q; ++i) {
		cin >> abcds[i][0] >> abcds[i][1] >> abcds[i][2] >> abcds[i][3];
		--abcds[i][0], --abcds[i][1], abcds[i][2], abcds[i][3];
	}

	vector<ll> As(N);
	ll res = solve(As, 0, M, abcds);
	cout << res << endl;

	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int q;
    cin >> q;
    int tmp1, tmp2, tmp3;
    cin >> tmp1 >> tmp2 >> tmp3;
    map<long long, int> dct;
    dct[tmp2] = 1;
    int left = 0, right = 0;
    long long sum_left = 0, sum_right = 0;
    long long constant = tmp3;
    auto it = dct.find(tmp2);
    int cnt = 1;
    while (--q)
    {
        int type;
        cin >> type;
        if (type == 2)
        {
            cout << (*it).first << ' ' << sum_left + sum_right + constant << '\n';
        }
        else
        {
            ++cnt;
            int a, b;
            cin >> a >> b;
            constant += b;
            
            if (a == (*it).first)
                ++dct[a];
            
            else if (a < (*it).first)
            {
                ++left;
                sum_left += (*it).first - a;
                
                if (dct.find(a) != dct.end())
                    ++dct[a];
                else
                    dct[a] = 1;
                
                if (2 * left == cnt)
                {
                    --it;
                    sum_left -= left * ((*(next(it))).first - (*it).first);
                    left -= (*it).second;
                    right += (*(next(it))).second;
                    sum_right += right * ((*(next(it))).first - (*it).first);
                }
            }
            
            else
            {
                ++right;
                sum_right += a - (*it).first;
                
                if (dct.find(a) != dct.end())
                    ++dct[a];
                else
                    dct[a] = 1;
                
                if (2 * right > cnt)
                {
                    sum_right -= right * ((*(next(it))).first - (*it).first);
                    right -= (*(next(it))).second;
                    left += (*it).second;
                    sum_left += left * ((*(next(it))).first - (*it).first);
                    ++it;
                }
            }
        }
    }
}

Measured memory_bytes: 8832
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

suml = [0] * (N+1)
tmp = 0
for i in range(1, N+1):
    tmp += A[i-1]
    suml[i] = tmp

c = Counter(suml)
ret = 0
for i in c.values():
    if i > 1:
        ret += (i-1) * i // 2

print(ret)


Measured memory_bytes: 41568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll n;
    cin >> n;
    vector<int> p(n);
    for(ll i=0; i<n; i++) cin >> p[i];
    ll cnt=0;
    int saisyo=1e9;
    for(ll i=0; i<n ;i++){
        saisyo = min(saisyo,p[i]);
        if(saisyo == p[i] )cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024