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

const int IINF = 1e9 + 100;

struct edge{
    pair<int, int> to;
    int cost;
};

struct node{
    pair<int, int> v;
    int cost;

    bool operator<(const node & right) const {
        return cost > right.cost;
    }
};

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

    int n, m;
    cin >> n >> m;

    map<pair<int, int>, vector<edge> > g;
    for(int i = 0 ; i < m ; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        g[{a, c}].push_back({{b, c}, 0});
        g[{b, c}].push_back({{a, c}, 0});
        g[{a, c}].push_back({{a, 0}, 0});
        g[{a, 0}].push_back({{a, c}, 1});
        g[{b, c}].push_back({{b, 0}, 0});
        g[{b, 0}].push_back({{b, c}, 1});
    }

    map<pair<int, int>, int> cost;
    for(auto x : g){
        cost[x.first] = IINF;
    }
    cost[{n - 1, 0}] = IINF;

    priority_queue<node> que;
    que.push({{0, 0}, 0});
    while(!que.empty()){
        node now = que.top();
        que.pop();
        if(cost[now.v] <= now.cost){
            continue;
        }
        cost[now.v] = now.cost;
        for(auto x : g[now.v]){
            if(cost[x.to] > now.cost + x.cost){
                que.push({x.to, now.cost + x.cost});
            }
        }
    }

    if(cost[{n - 1, 0}] < IINF){
        cout << cost[{n - 1, 0}] << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 94752
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void){
	int n, k; cin >> n >> k;
	ll dp[k]; fill(dp, dp+k, 0);
	for(int i=1; i<=n; i++) dp[i%k]++;
  ll an = 0;
	for(int i=0; i<k; i++) {
		if (i*2 % k == 0) an += dp[i] * dp[i] * dp[i];
	}
	cout << an << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
char a[N],b[N];
int main() {
  ios::sync_with_stdio(false);
  cin>>a+1>>b+1;
  int l=strlen(a+1),r=strlen(b+1);
  if(l<=r){
  	for(int i=1;i<=l;i++){
  		if(a[i]!=b[i])return cout<<"No\n",0;
  	}
  	cout<<"Yes\n";
  }else cout<<"No\n";
 	return 0;
}

Measured memory_bytes: 3640
n = int(input())
if n == 1:
    print(0)
    exit()

def primes(n):
    prime = [True] * (n + 1)
    prime[0] = False
    prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            prime[j] = False
    return [i for i in range(n + 1) if prime[i]]


pms = primes(n)
num = [0]*len(pms)
ans = 0
for j in range(2,n+1):
    for i in range(len(pms)):
        while j % pms[i] == 0:
            j //= pms[i]
            num[i] += 1
c74 = 0
c24 = 0
c14 = 0
c4 = 0
c2 = 0
for i in range(len(num)):
    if num[i] >= 74:
        c74 += 1
        c24 += 1
        c14 += 1
        c4 += 1
        c2 += 1
    elif num[i] >= 24:
        c24 += 1
        c14 += 1
        c4 += 1
        c2 += 1
    elif num[i] >= 14:
        c14 += 1
        c4 += 1
        c2 += 1
    elif num[i] >=4:
        c4 += 1
        c2 += 1
    elif num[i] >= 2:
        c2 += 1
ans += c74
ans += c24 * (c2-1)
ans += c14 * (c4-1)
ans += c4*(c4-1)//2 * (c2-2)
print(ans)








Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
const int MAXN=200010;
long long n,k,ans,a[MAXN];
int main () {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) {scanf("%d",&a[i]);}
	if (k>=n) {printf("0\n");return 0;}
	sort(a+1,a+n+1);
	for (int i=n-k;i>=1;i--) {ans+=a[i];}
	printf("%lld\n",ans);
	return 0;
}

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

vector<ll> l;

void dfs(string s){
    ll x=stoll(s);
    l.push_back(x);
    if(x>3234566667) return;
    char y=s.back();
    if(y=='0'){
        dfs(s+'0');
        dfs(s+'1');
    }
    else if(y=='9'){
        dfs(s+'8');
        dfs(s+'9');
    }
    else{
        dfs(s+y);
        dfs(s+char(y+1));
        dfs(s+char(y-1));
    }
}

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

    dfs("1");
    dfs("2");
    dfs("3");
    dfs("4");
    dfs("5");
    dfs("6");
    dfs("7");
    dfs("8");
    dfs("9");

    sort(all(l));
    //rep(i,k) cout<<l[i]<<endl;
    cout<<l[k-1]<<endl;
}




Measured memory_bytes: 6512
#import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001



H,W = map(int,input().split())

table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]


for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]


for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]


for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()


Measured memory_bytes: 6256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

namespace{
int par[100001];
int rank[100001];

void init(int n){
	REP(i,n){
		par[i] = i;
		rank[i] = 0;
	}
}

int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x==y)return;

	if(rank[x] < rank[y]){
		par[x] = y;
	}
	else{
		par[y] = x;
		if(rank[x] = rank[y] ) rank[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}
}

int main(){
	
	int N,M;
	vector<int> arr;

	cin>>N>>M;
	arr.resize(N);
	REP(i,N)cin>>arr[i];

	init(N);	
	REP(i,M){
		int x,y;
		cin>>x>>y;
		unite(x,y);
	}
	
	int ans_sum = 0;
	REP(i,N){
		
		if(same(i+1,arr[i]))ans_sum++;
	}
	
	cout<<ans_sum<<endl;
	return 0;
}



Measured memory_bytes: 1408
//Exawizerds 2019, problem C
//Reference: submission #4875983.

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long int N,Q;
string s;
vector<string> wizerd;

//______________________________________________________________
//This function checks whether if the golem will vanish or not.
//If this function returns 1 or -1, that golem will vanish.
//If this function returns 0, that golem will alive.
int DeadOrAlive(long long int pos){
  char s_temp = s[pos];
  for(int i=0; i<Q; i++){
    if(wizerd[i][0] == s_temp){
      if(wizerd[i][1] == 'L') pos -= 1;
      else pos += 1;
    }
    s_temp = s[pos];
    if(pos < 0) return -1; // position becomes <0, lower limit should be larger than left
    else if(pos > N-1) return 1;//pos become N-1, higher limit should be lower than right
  }
  return 0;
}

//______________________________________________________________
//This function is binary search to determine the lower-bound and the higher bound.
//direction is defined as: lower (left) -> -1, higher (right) -> 1//
long long int BinarySearch(long long int left, long long int right, int direction){
  long long int middle = (left + right)/2;
  if(right - left <= 1) return left;
  if(DeadOrAlive(middle) == -1 && direction == -1) left = middle;
  else if(direction == -1) right = middle;

  if(DeadOrAlive(middle) == 1 && direction == 1) right = middle;
  else if(direction == 1) left = middle;
  return BinarySearch(left, right, direction);
}

//______________________________________________________________
int main(){
  
  cin >> N >> Q;
  cin >> s;
  for(int i=0; i<Q; i++){
    string t_temp, d_temp;
    cin >> t_temp >> d_temp;
    wizerd.push_back(t_temp+d_temp);
  }
  long long int lower_limit = BinarySearch(-1, N, -1);
  long long int higher_limit = BinarySearch(lower_limit, N, 1);
  cout << higher_limit - lower_limit << endl;
  return 0;
}



Measured memory_bytes: 11380
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;



int main()
{
	//fast
	string s,t;
	cin>>s>>t;
	int count=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=t[i])
			count++;
	}
	cout<<count;

	return 0;
}

Measured memory_bytes: 3912
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	scan_init()
	n := scanInt()
	a := make([]int, n)
	for i:= 0; i<n; i++ {
		a[i] = scanInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	// fmt.Println(a)
	sum := a[0]
	for i:= 2; i <n; i++ {
		sum += a[i/2]
	}
	fmt.Println(sum)
}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 5916
#include <cstdio>
#include <vector>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 5005;

int N, coef[MN], Ans;
std::vector<int> G[MN];

int siz[MN], f[MN][MN];
void DFS(int u, int p) {
	siz[u] = 1;
	f[u][1] = 1;
	for (auto v : G[u]) if (v != p) {
		DFS(v, u);
		static int g[MN];
		for (int i = 1; i <= siz[u] + siz[v]; ++i) g[i] = 0;
		for (int i = 1; i <= siz[u]; ++i)
			for (int j = 1; j <= siz[v]; ++j) {
				g[i] = (g[i] - (LL)f[u][i] * f[v][j] % Mod * coef[j]) % Mod;
				g[i + j] = (g[i + j] + (LL)f[u][i] * f[v][j]) % Mod;
			}
		siz[u] += siz[v];
		for (int i = 1; i <= siz[u]; ++i) f[u][i] = g[i];
	}
}

int main() {
	scanf("%d", &N);
	for (int i = 1, x, y; i < N; ++i)
		scanf("%d%d", &x, &y),
		G[x].push_back(y),
		G[y].push_back(x);
	coef[0] = 1;
	for (int i = 2; i <= N; i += 2) coef[i] = (LL)coef[i - 2] * (i - 1) % Mod;
	DFS(1, 0);
	for (int i = 2; i <= N; i += 2) Ans = (Ans + (LL)f[1][i] * coef[i]) % Mod;
	printf("%d\n", (Ans + Mod) % Mod);
	return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e2 + 10;
const int mod = 1e9 + 7;

int gr[N][N];
bool vis[N][N];
int n , a , b , w , m;
pair<int,int> edge[N*10];
int wt[N*10];

int32_t main(){
	boost;
    //code

	cin >> n >> m;

	for(int i = 1 ; i <= n ; ++i){
		for(int j = 1 ; j <= n ; ++j){
			gr[i][j] = 1e18;
		}
		gr[i][i] = 0;
	}

	for(int i = 1 ; i <= m ; ++i){
		cin >> a >> b >> w;
		gr[a][b] = w;
		gr[b][a] = w;
		edge[i] = {a,b};
		wt[i] = w;
	}
	map<pair<int,int> , int> mp;
	for(int k = 1 ; k <= n ; ++k){
		for(int i = 1 ; i <= n ; ++i){
			for(int j = 1 ; j <= n ; ++j){
				int dis = gr[i][k] + gr[k][j];
				if(dis < gr[i][j]){
					gr[i][j] = dis;
				}
			}
		}    	
	}

	int ans = m;
	for(int i = 1 ; i <= m ; ++i){
		bool hai = false;
		for(int j = 1 ; j <= n ; ++j){
			if(gr[j][edge[i].first] + wt[i] == gr[j][edge[i].second]){
				hai = true;
				break;
			}
		}
		if(hai)
			ans--;
	}
	cout << ans ;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int low(int p,int q,int r){
  if(r<=p && r<=q){
    return r;
  }else if(p<=r && p<=q){
    return p;
  }else{
    return q;
  }


}
int gcd(int a,int b,int c){
  int d=low(a,b,c);
  int e=0;
  for(int l=1;l<=d;l++){
    if(a%l==0 && b%l==0 && c%l==0){
      e=l;
    }
  }
  return e;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  long long int sum=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      for(int k=1;k<=n;k++){
        sum +=gcd(i,j,k);
      }
    }
  }
  cout<<sum<<"\n";

}


Measured memory_bytes: 3604
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> k)
    {
		ans = 1;

		for(ll i = 1; i <= 10000000; i++)
		{
			if((i * k) % 360 == 0)
			{
				ans = i;
				break;
			}
		}

		cout << ans << "\n";
    }

}





Measured memory_bytes: 3632
n = int(input())
s = []
while(n>0):
    s.append(int(input()))
    n -= 1

mi = 10e9
ma = -10e9

for i in range(len(s)-1):
    mi = min(mi,s[i])
    ma = max(ma,s[i+1] - mi)
    
print(ma)


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

int a[105];

int main()
{

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    int ans = 1e9;
    for (int i = 1; i <= 100; i++) {
        int res = 0;
        for (int j = 1; j <= n; j++)
            res += (a[j] - i) * (a[j] - i);
        ans = min(ans, res);
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	out(N / 3)
}


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

int main() {
  int S;
  int a;
  
  // 3個の入力を受け取れるように 3要素の配列 {0, 0, 0} で初期化
vector<int> vec(1000000);

  
  
  
  cin>>S;
  
  vec.at(0)=S;
  
  
  if(vec.at(0)==1){
    cout<<4<<endl;
  }
  else if(vec.at(0)==2){
    cout<<4<<endl;
  }
  else{
    
  
  
  
for (int i = 0; i < 1000000; i++) {
  if(vec.at(i)%2==0)
  {
    vec.at(i+1)=vec.at(i)/2;
  }
  else{
    vec.at(i+1)=vec.at(i)*3+1;
  }
  
  if(vec.at(i)==4){
    a=i;
    cout<<a+4<<endl;
    break;
  }
}
}
  
  
 
}

Measured memory_bytes: 4096
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;

ll x[100002] = {};
int main() {
	ll n; cin >> n;

	rep(i, 0, n) {
		ll a; cin >> a;
		a++;
		x[a - 1]++;
		x[a]++;
		x[a + 1]++;
	}

	ll maxV = 0;
	rep(i, 0, 100001) {
		maxV = max(maxV, x[i]);
	}

	cout << maxV << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define pi 3.141592653589793238
main()
{
    int n,m,i;
    cin>>n>>m;
    int a[m];
    int s=0;
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(n-s<0)
    cout<<-1<<endl;
    else
    {
        cout<<n-s<<endl;
    }
    
}

Measured memory_bytes: 3684
d = int(input())
cl = list(map(int, input().split()))
sl = []
for _ in range(d):
    sl.append(list(map(int, input().split())))

tl = []
# for _ in range(d):
#     tl.append(int(input()))

last_di = [-1]*26
ans = 0
for day in range(d):
    best_t = 0
    best_t_val = 0
    for t in range(26):
        curr_val = sl[day][t]
        for i in range(26):
            if i == t: continue
            curr_val -= (day-last_di[i])*cl[i]
        if curr_val >= best_t_val:
            best_t = t
            best_t_val = curr_val
    tl.append(best_t+1)
    last_di[best_t] = day
    ans += best_t_val
    # print(ans)

for t in tl:
    print(t)

# for day, t in enumerate(tl):
#     ans += sl[day][t-1]
#     last_di[t-1] = day
#     for ld, c in zip(last_di, cl):
#         # if ld == -1: continue
#         ans -= (day-ld)*c
#     print(ans)

Measured memory_bytes: 9512
import java.util.Scanner;

/**
 * http://tenka1-2017.contest.atcoder.jp/tasks/tenka1_2017_c
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		sc.close();
		
		long h = -1;
		long n = -1;
		long w = -1;
		for(long x=1; x<=3500; x++){
			for(long y=1; y<=3500; y++){
				long dived = 4*x*y-N*(x+y);
				if(dived==0) continue;
				long z = (N*x*y)/dived;
				if(4*x*y*z==N*(x*y+y*z+z*x) && z >=0){
					h = x;
					n = y;
					w = z;
					break;
				}
			}
			if(h>0) break;
		}
		
		System.out.println(String.format("%d %d %d", h,n,w));

	}

}

Measured memory_bytes: 22736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int judge(int x)
{
	int y=(int)(sqrt(x));
	return y*y==x;
}
int n,d;
int x[11][11];
int calc(int a,int b)
{
	int s=0;
	for(int i=1;i<=d;++i)
		s+=(x[a][i]-x[b][i])*(x[a][i]-x[b][i]);
	return s;
}
int main()
{
	n=read(),d=read();
	for(int i=1;i<=n;++i)
		for(int j=1;j<=d;++j)
			x[i][j]=read();
	int ans=0;
	for(int i=1;i<n;++i)
		for(int j=i+1;j<=n;++j)
			ans+=judge(calc(i,j));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	SPEED;
	string s;
	cin >> s;
	int n = s.length();
	int l=0;
	int k = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] - '0' != (i % 2))l++;
		else k++;
	}
	cout << min(l, k);
	ed;

	return 0;
}

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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	int rating;
	cin >> rating;
	if(rating < 1200) {
		puts("ABC");
	} else if(rating < 2800) {
		puts("ARC");
	} else {
		puts("AGC");
	}
}


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

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

  a = n % 10;
  b = (n/10) % 10;
  c = n/100;

  if(a == 7 || b == 7 || c == 7) printf("Yes\n");

  else printf("No\n");

  return 0;
}


Measured memory_bytes: 1620
N = int(input())
A = list(map(int,input().split()))

from collections import Counter

A.sort(reverse=True)
d = Counter(A)
d = d.most_common()
d.sort(reverse=True)
x = []

for i in range(len(d)):
    if d[i][1] >= 4:
        x.append(d[i][0])
        x.append(d[i][0])
    elif d[i][1] >= 2:
        x.append(d[i][0])
        
if len(x) < 2:
    print(0)
else:   
    print(x[0]*x[1])
        

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

void pre(){


}

void solve(){

    ll n;
    cin >> n;
    ll a[n+1];
    for(ll i=1;i<n+1;i++){
        cin >> a[i];
    }
    ll pre[n+1];
    ll suf[n+1];
    pre[1] = a[1];
    for(ll i=2;i<n+1;i++)
        pre[i] = pre[i-1]^a[i];
    suf[n] = a[n];
    for(ll i=n-1;i>=1;i--){
        suf[i] = suf[i+1]^a[i];
    }
    cout << suf[2] << " ";
    for(ll i=2;i<n;i++){
        ll ans = pre[i-1]^suf[i+1];
        cout << ans << " ";
    }
    cout << pre[n-1];
    
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 8300
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		int ans = 0;
		for(int i=0;i<W.length();i++){
			if('+' == W.charAt(i)){
				ans++;
			}else{
				ans--;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 20948
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
 

int main(){
  ll N,K=0,J=999999999999;
  
  cin>>N;
  vector<ll> vec(N);
	for (int i = 0; i < N; i++) {
  		cin >> vec.at(i);
      J=min(J,vec.at(i));
      K=max(K,vec.at(i));
	}
  

  cout<<K-J<<endl;
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll n,m; cin>>n>>m;
	ll ret=min(n,m/2);
	m-=2*ret;
	ret+=m/4;
	cout<<ret<<"\n";
	return 0;
}

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

int main(){
	ll n,c;
	cin>>n>>c;

	vector<ll> X(n);
	vector<ll> V(n);
	vector<ll> f(n);
	vector<ll> fv(n);
	vector<ll> finv(n);	
	vector<ll> fvinv(n);

	for(int i = 0; i < n; i++) cin>>X[i]>>V[i];
	for(int i = 0; i < n; i++){
	   fvinv[i] = V[n-i-1];
	    fv[i] = V[i];
	}
	for(int i = 1; i < n; i++) fvinv[i]+=fvinv[i-1];
	for(int i = 1; i < n; i++) fv[i]+=fv[i-1];
	for(int i = 0; i < n;i++) f[i] = fv[i] - X[i];
	for(int i = 0; i < n; i++) finv[i] = fvinv[i] -  (c - X[n-i-1]);

	ll ans = 0;
	ll mxg = 0;
	ll fclockmx = 0;
	//for(int i = 0; i < n; i++) cout<<f[i]<<endl;
	for(int i = 0; i < n; i++) ans = max(ans,f[i]);
	for(int i = 0; i < n; i++) ans = max(ans,finv[i]);
	for(int i = 0; i < n-1; i++){
		mxg = max(mxg,f[i] - X[i]);
		fclockmx = max(fclockmx,f[i]);
		ans = max(finv[n-i-2]+mxg,ans);
		ans  = max(finv[n-i-2]+fclockmx-(c-X[i+1]), ans);
	}

	cout<<ans;
}

Measured memory_bytes: 4992
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if ("ABC".equals(S)) {
		    System.out.println("ARC");
		} else {
		    System.out.println("ABC");
		}
		
    }
}

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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1;
  cin>>s1;
  vector<char> l1,l2;
  int q;
  cin>>q;
  int q1=0;
  for(int i=0;i<q;i++){
    int t;
    cin>>t;
    if(t==1){
      if(q1==0)
         q1=1;
      else
         q1=0;
    }
    else{
      int f;
      char c;
      cin>>f>>c;
      if(f==1){
        if(q1==0)
          l1.push_back(c);
        else
           l2.push_back(c);
      }
      else{
        if(q1==0)
           l2.push_back(c);
        else
           l1.push_back(c);
      }
    }
  }
  string s="";
  for(int i=0;i<l1.size();i++)
   s=s+l1[i];
  reverse(s.begin(),s.end()); 
  s1=s+s1;
  //if(q1==1){
	  for(auto i:l2)
	   s1=s1+i;
  if(q1==1)
   reverse(s1.begin(),s1.end());
  cout<<s1;
    
    
}
    


Measured memory_bytes: 2364
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();
        int ans = 0;
        for(int i = 0; i < S.length(); i++){
         if(S.charAt(i) != T.charAt(i)) ans++; 
        }
          
        System.out.println(ans);
    } 
}

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, a, b;
	cin >> n >> a >> b;

	cout << min(a * n, b) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    ll x = 0;
    for (int j = 0; j < N - 2; j += 2) {
        x += A[j] - A[j + 1];
    }

    x += A[N - 1];

    cout << x << endl;

    x /= 2;
    for (int i = 1; i < N; ++i) {
        cout << ((A[i - 1] - x) * 2) << endl;
        x = A[i - 1] - x;
    }
    return 0;
}

Measured memory_bytes: 2048
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int dp1[310][310], dp2[310];
int solve_testcase() {
    int N; scanf("%d", &N);
    if(N == 0) return 1;
    vector<int> A(N);
    for(int i=0; i<N; i++) scanf("%d", &A[i]);
    
    fill(dp1[0], dp1[N+1], false);
    for(int i=0; i<N; i++) {
        dp1[i][i] = true;
    }
    for(int d=2; d<=N; d++) {
        for(int l=0; l<N-d+1; l++) {
            int r = l + d;
            if(abs(A[l] - A[r-1]) <= 1 and dp1[l+1][r-1]) dp1[l][r] = true;

            if(r - l >= 4) {
                for(int k=l+2; k<=r-2; k++) {
                    if(dp1[l][k] and dp1[k][r]) dp1[l][r] = true;
                }
            }
        }
    }

    fill(dp2, dp2 + N + 1, -1);
    dp2[0] = 0;
    for(int i=0; i<N; i++) {
        chmax(dp2[i+1], dp2[i]);
        for(int j=i+1; j<=N; j++) {
            if(!dp1[i][j]) continue;
            chmax(dp2[j], dp2[i] + (j - i));
        }
    }
    printf("%d\n", dp2[N]);
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



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

int main(){

	int N;
  	int out=0,tmp;
	
  	cin >> N;
    for(int i=0;i<N;i++){
    	cin>>tmp;
        out = out ^ tmp;
    }

  	if(out==0){
      cout<<"Yes";
    }else{
      cout<<"No";
    }
  	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n, m;
  cin >> n >> m;
  //priority_queue<ll, vector<ll>,greater<ll>> que;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  vector<vector<ll>> b(m, vector<ll>(2));
  for(int i = 0; i < m; i++) {
    cin >> b[i][1] >> b[i][0];
  }
  sort(b.rbegin(), b.rend());
  ll sum = 0;
  int cnt = 0;
  for(int i = n - 1; i >= 0; i--){
    bool ok = false;
    while(b[cnt][1]) {
      if(a[i] < b[cnt][0]){
        a[i] = b[cnt][0];
        b[cnt][1]--;
        break;
      }else {
        ok = true;
        break;
      }
    }
    if(ok){
      break;
    }
    if(b[cnt][1] == 0){
      cnt++;
    }
    if(cnt >= m){
      break;
    }
  }
  for(int i = 0; i < n; i++){
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N,A,B,maxA=1,minB;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A>>B;
        if(A>=maxA){
            maxA=A;
            minB=B;
        }
    }
    cout<<maxA+minB<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

int main(){
    int n,m;
    cin>>n>>m;
    Graph g(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> visit(n,-1);
    vector<int> mark(n,-1);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int nv:g[v]){
            if(visit[nv]!=-1)continue;
            visit[nv]=visit[v]+1;
            mark[nv]=v;
            q.push(nv);
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;++i){
        cout<<++mark[i]<<endl;
    }
    
}


Measured memory_bytes: 10568
import sys,math,collections
from collections import defaultdict

#from itertools import permutations,combinations
    
def file():
    sys.stdin = open('input.py', 'r')
    sys.stdout = open('output.py', 'w') 
def get_array():
    l=list(map(int, input().split()))
    return l
def get_ints():   
    return map(int, input().split())
    #return a,b
def get_3_ints():   
    a,b,c=map(int, input().split())
    return a,b,c    
def sod(n):
    n,c=str(n),0
    for i in n: 
        c+=int(i)
    return c    
def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while(i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
  
    return True
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    floor = -1
    while left <= right:
        mid = (left + right) // 2
        if A[mid] == x:
            return A[mid]
        elif x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            left = mid + 1
            
    return floor
def chk(aa,bb):
	f=0
	for i in aa:
		for j in bb:
			if(j[0]>=i[0] and j[1]<=i[1]):
				f+=1
			elif(j[0]<=i[0] and j[1]>=i[1]):	
				f+=1
			elif(i[0]==j[1] or i[1]==j[0]):
				f+=1
			else:
				continue
	return f			

#file()
def main():

	s=input()
	if(s[-1]=='s'):
		s+='es'
	else:
		s+='s'
	print(s)	
		
	#for tt in range(int(input())):
	#	a,b=get_ints()
		




				





		


	





        
            
        























    

    
    

        











        
        

        























































                

            







            
            
































        








if __name__ == '__main__':
    main()

Measured memory_bytes: 9368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n,x; cin>>n>>x;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));
    int ans=0,sum=0;
    rep(i,n){
        sum+=a.at(i);
        if(sum<=x) ans++;
        else break;
    }
    if(sum<x) ans--;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define P pair<ll, ll>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
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;}
ll INF = 1e+18;
int iINF = 1e9;

int
main()
{
  double a, b, x; cin >> a >> b >> x;
  double s = x / a;
  bool flag = s >= (a * b) / 2;

  auto area = [&](double th, bool flag){
      double dgree = th * PI / 180.0;
    if(flag){
      return (a * b) - (a *(a * tan(dgree))/2) >= s;
    } else {
      return b * (b /tan(dgree)) / 2 >= s;
    }
  };

  double ok = 0;
  double ng = 91;
  rep(i, 0, 100){
    double th = (ok + ng) / 2;
    if(area(th, flag)) ok = th;
    else ng = th;
  }

  printf("%.10f\n", ok);

  return 0;
}


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

void trace(int[], int);
int selectionSort(int[], int);

void trace(int a[], int n){
  for(int i = 0; i < n; i++){
    if(i>0) cout << " ";
    cout << a[i];
  }
  cout << endl;
}

int selectionSort(int a[], int n){
    int count = 0;
    for(int i = 0; i < n; i++){
        int minj = i;
        for(int j = i; j < n; j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(i != minj){
            count++;
            swap(a[i], a[minj]);
        }
    }
    return count;
}

int main(){
    int n;
    int a[100];
    
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];

    int count = selectionSort(a, n);
    trace(a, n);
    cout << count << endl;
    return 0;
}

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

int main() {
  int N, H;
  cin >> N >> H;
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0; i<N; i++)cin >> A.at(i) >> B.at(i);
  
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  
  int count =0;
  for(int i=N-1; i>=0; i--){
    if(A.at(N-1)<B.at(i)){
      count ++;
      H -= B.at(i);
        if(H<=0)break;
    }
    else break;
  }
  
  if(H>0){
    count += (H-1)/A.at(N-1)+1;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 4036
from collections import defaultdict
inpl = lambda: list(map(int,input().split()))

N, Q = inpl()
S = input()
T = []
D = []
for i in range(Q):
    t,d = input().split()
    T.append(t)
    D.append(d)

finalposmem = defaultdict(lambda: None)
def finalpos(i):
    if i < 0:
        return -1
    elif i >= N:
        return 1

    for q in range(Q):
        if S[i] == T[q]:
            if D[q] == 'L':
                i -= 1
            else:
                i += 1
            if i < 0:
                return -1
            elif i >= N:
                return 1
    return 0

def finalpos_withmem(i):
    mem = finalposmem[i]
    if mem is None:
        z = finalpos(i)
        finalposmem[i] = z
        return z
    else:
        return mem

def bisect_left_withkey(a, x, key=lambda x: x):
    right_max = len(a)-1
    right = right_max
    left = 0
    kx = key(x)
    while left + 1 < right:
        new = (left + right)//2
        kn = key(a[new])
        if kx <= kn:
            right = new
        else:
            left = new
    if right == right_max and kx > key(a[right]):
        return right + 1
    else:
        return right

def bisect_right_withkey(a, x, key=lambda x: x):
    right_max = len(a)-1
    right = right_max
    left = 0
    kx = key(x)
    while left + 1 < right:
        new = (left + right)//2
        kn = key(a[new])
        if kx < kn:
            right = new
        else:
            left = new
    if right == right_max and kx >= key(a[right]):
        return right + 1
    else:
        return right

right_bound = bisect_left_withkey(range(N),N,key=finalpos_withmem)
left_bound = bisect_right_withkey(range(N),-1,key=finalpos_withmem)
left_killed = left_bound
right_killed = N - right_bound
killed = left_killed + right_killed
ans = N - killed

print(ans)

Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
int N,K,a=0,ans[123456],arr[123456];
int main()
{
    cin>>N;
    for(int i=2; i<=N; i++)
    {
        cin>>arr[i];
    }
    ans[1]=arr[2];
    if(N>2){
        for(int i=2; i<N; i++)
        {
            if(arr[i]<=arr[i+1]){
                ans[i]=arr[i];
            }
            else{
                ans[i]=arr[i+1];
            }
        }
    }
    ans[N]=arr[N];
    for(int i=1; i<=N; i++)
    {
    	a+=ans[i];
    }
    cout<<a;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		
		int[][]card=new int[3][3];	//3*3のビンゴカード配列
		
		for(int i=0;i<3;i++) {
			for(int j=0;j<3;j++) {
				card[i][j]=sc.nextInt();
			}
		}
		//当選番号入力数分回す
				int Count = sc.nextInt();
				int[] win = new int[Count];
				for(int c = 0; c <Count; c++) {
					win[c] = sc.nextInt();
				}
		 
				
				for(int cnt = 0; cnt < win.length; cnt++) {
					for(int i = 0 ; i < 3; i++) {
						for(int j = 0 ; j < 3; j++) {
							if(card[i][j] == win[cnt]) {
								card[i][j] = 0;
							}
						}
					}
				}
				//ビンゴのパターン
				boolean p1 = card[0][0] + card[0][1] + card[0][2] == 0;
				boolean p2 = card[1][0] + card[1][1] + card[1][2] == 0;
				boolean p3 = card[2][0] + card[2][1] + card[2][2] == 0;
				boolean p4 = card[0][0] + card[1][1] + card[2][2] == 0;
				boolean p5 = card[2][0] + card[1][1] + card[0][2] == 0;
				boolean p6 = card[0][0] + card[1][0] + card[2][0] == 0;
				boolean p7 = card[0][1] + card[1][1] + card[2][1] == 0;
				boolean p8 = card[0][2] + card[1][2] + card[2][2] == 0;
		 
				
				if(p1 || p2 || p3 || p4 || p5 || p6 ||  p7 || p8) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
	
		
		sc.close();
	}

}

Measured memory_bytes: 21844
n = int(input())
vv = []
for i in range(n):
    v = [int(x) for x in input().split()]
    vv.append(v)

dp = [[0 for i in range(3)] for j in range(n+1)]

for i in range(n):
    for h in range(3):
        dp[i+1][h] = max(dp[i][(h+1)%3],dp[i][(h+2)%3]) + vv[i][h]

print(max(dp[n]))

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

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
            A[i] = A[i] - (i + 1);
        }
        Arrays.sort(A);
        int b = A[N / 2];
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += Math.abs(A[i] - b);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65160
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        int ans  =0;
        for (int i = 0 ; i < c.length ; i++) {
            if (c[i] == '+') {
                ans++;
            } else {
                ans--;
            }
        }
        System.out.println(ans);
    }

}


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

int main(){
    int_fast64_t H, W, K;
    cin >> H >> W >> K;

    vector<vector<int_fast64_t>> tap({{0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 4, 5}, {0, 1, 2, 4, 5, 8, 9, 10}, {0, 1, 2, 4, 5, 8, 9, 10, 16, 17, 18, 20, 21}, {0, 1, 2, 4, 5, 8, 9, 10, 16, 17, 18, 20, 21, 32, 33, 34, 36, 37, 40, 41, 42}, {0, 1, 2, 4, 5, 8, 9, 10, 16, 17, 18, 20, 21, 32, 33, 34, 36, 37, 40, 41, 42, 64, 65, 66, 68, 69, 72, 73, 74, 80, 81, 82, 84, 85}});

    vector<vector<int_fast64_t>> dp(H + 1, vector<int_fast64_t>(W));
    dp[0][0] = 1;
    for(int i = 1; i <= H; ++i){
        for(auto j : tap[W - 1]){
            for(int k = 0; k < W; ++k){
                if((j >> k) & 1){
                    dp[i][k] -= dp[i - 1][k];
                    dp[i][k] += dp[i - 1][k + 1];
                    dp[i][k + 1] -= dp[i - 1][k + 1];
                    dp[i][k + 1] += dp[i - 1][k];
                }
                dp[i][k] += dp[i - 1][k];
            }
        }
        for(int k = 0; k < W; ++k)dp[i][k] %= 1000000007;
    }

    cout << dp[H][K - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
T=[]
A=[]
for i in range(N):
  t,a=map(int,input().split())
  T.append(t)
  A.append(a)
a=1
b=1
for i in range(N):
  n=max((a+T[i]-1)//T[i], (b+A[i]-1)//A[i])
  a=n*T[i]
  b=n*A[i]
print(a+b)


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

int main()
{
	int d;
	cin >> d;
	switch(d){
		case 22: cout << "Christmas Eve Eve Eve" << endl; break;
		case 23: cout << "Christmas Eve Eve" << endl; break;
		case 24: cout << "Christmas Eve" << endl; break;
		case 25: cout << "Christmas" << endl; break;
	}
	return 0;
}

Measured memory_bytes: 256
d, g = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in range(d)]

ans = 10**9
for bit in range(1<<d):
    score = 0
    n = 0
    
    for i in range(d): 
        if bit & 1<<i: # Problems completely answered
            score += pc[i][1] + pc[i][0]*100*(i+1)
            n += pc[i][0]

    if score >= g:
        ans = min(ans, n)
    else: # additional answering
        for i in range(d-1, -1, -1): # answer from high-score problem
            if bit & 1<<i: # already answered completely
                continue
            for j in range(pc[i][0]): # answer to remaining problems
                if score >= g:
                    break
                score += 100*(i+1)
                n += 1
        ans = min(ans, n)

print(ans)


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B) cout << C << endl;
    else if (A == C) cout << B << endl;
    else cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <cinttypes>
#include <cstdio>

using namespace std;

int main()
{
    int64_t X, Y;
    if (scanf("%" PRId64 "%" PRId64, &X, &Y) < 2) return 0;

    int a = 1;
    int64_t x = X;
    while (2 * x <= Y) x = 2 * x, a++;

    printf("%d\n", a);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            int h = scanner.nextInt();
            map.put(i+1,h);
        }
        boolean[] nongood = new boolean[n+1];
        for(int i = 0; i < m; i++){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if(map.get(a) > map.get(b)){
                nongood[b] = true;
            }else if(map.get(a) < map.get(b)){
                nongood[a] = true;
            }else{
                nongood[b] = true;
                nongood[a] = true;
            }
        }
        int count = 0;
        for(int i = 1; i <= n; i++){
            if(!nongood[i]){count++;}
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 69160
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<bitset>
using namespace std;

int main() {

	int K;
	string S;
	cin >> K;
	cin >> S;

	if (S.length() <= K) {
		cout << S << endl;
	}
	else {
		string str = S.substr(0, K);
		str += "...";
		cout << str << endl;
	}

	return 0;
}



Measured memory_bytes: 3628
# 2019-11-14 20:54:46(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, l = [int(x) for x in sys.stdin.readline().split()]
    flavors = []
    for i in range(1, n+1):
        flavors.append(l + i - 1)
    # key=function  要素にfunctionを適用した戻り値でsortする
    flavors.sort(key=abs)
    print(sum(flavors[1:]))
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int cnt(ll n){
	int c=0;
	while(n){
		c++;
		n=n/10;
	}
	return c;
}

int main()
{      
  fastio();
  ll n,i;
  cin>>n;
  int ans=10000;
  for(i=2;i*i<=n;i++){
  	if(n%i==0){
  		ans=min(ans,max(cnt(i),cnt(n/i)));
  	}
  }
  if(ans!=10000)
  	cout<<ans;
  else
  	cout<<(cnt(n));
  return 0;
}

Measured memory_bytes: 256