akhauriyash/Code-Regression huggingface dataset:
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
const INF: isize = 1_000_000_001;
fn main() {
    input! { n: chars };
    let mut n = n
        .into_iter()
        .rev()
        .map(|x| (x as u8 - '0' as u8) as isize)
        .collect::<Vec<_>>();
    n.extend(vec![0]);
    let mut dp = vec![vec![INF; 2]; n.len() + 1];
    dp[0][0] = 0;
    for i in 0..n.len() {
        for j in 0..2 {
            let d = n[i] + j as isize;
            if d < 10 {
                dp[i + 1][0] = std::cmp::min(dp[i + 1][0], dp[i][j] + d);
            }
            if d > 0 {
                dp[i + 1][1] = std::cmp::min(dp[i + 1][1], dp[i][j] + 10 - d);
            }
        }
    }
    println!("{}", dp[n.len()][0]);
}


Measured memory_bytes: 53496
# -*- coding: utf-8 -*-
"""


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


def main(args):
    for line in stdin:
        n, m = map(int, line.split())
        print(fractions.gcd(n, m))



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

Measured memory_bytes: 10212
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = int(input())

    base = [2**x for x in range(7)]

    max_base = 0
    for dum in base:
        if n >= dum:
            max_base = dum

    print(max_base)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define in auto&it
#define out auto it
#define fi first
#define se second
#define allr(x) (x).rbegin(),(x).rend()
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
const double pi = acos(-1);
#define err(x) cerr<<#x<<" = "<<x<<'\n';
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif
	fastio
	int a;
	cin>>a;
	if(a==1) cout<<0;
	else cout<<1;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i)
    {
        cin >> A[i];
    }
    int C[200000]{0};
    for (int a : A){
        ++C[a];
    }
    sort(C, C + N, greater<>());
    cout << N - accumulate(C, C + K, 0) << endl;
}

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

using namespace std;

using ll = long long;

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define rot(s, k) rotate(s.begin(), s.begin()+ s.size()-(k%s.size()), s.end()); 

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	ll total = 0;
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=n; ++j){
			for(int k=1; k<=n; ++k){
				total += __gcd(i,__gcd(j,k));
			}
		}
	}

	cout << total << "\n";


}


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

int main() {
    int n; cin >> n;
    vector<double> v(n,0.0); for (int i=0; i<n; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    int a, b, c;
    for (int i=1; i<n; ++i) {
        v[i] = (v[i]+v[i-1])/2.0;
        sort(v.begin(), v.end());
    }
    cout << fixed << setprecision(12) << v.back() << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int k, p;
	int i,j;
	
	scanf("%d", &n);
	for (j = 0; j < n; j++){
		scanf("%d%d", &k, &p);
	    printf("%d\n", ((k- 1) % p) + 1);
	}
	
	return (0);
}

Measured memory_bytes: 596
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;
class Main{
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Main() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		
		int[][] adjMatrix = new int[totalVertex][totalVertex];
		for(int i = 0; i < adjList.size() ; i++ )
		{
			LinkedList<Integer> tmp = adjList.get(i);
			for(int j : tmp)
			{
				adjMatrix[i][j] = 1;
			}
		}
		for(int i = 0; i < adjMatrix.length;i++)
		{
			for(int j = 0; j < adjMatrix[i].length;j++)
			{
				if(j == adjMatrix[i].length-1)
				{
					System.out.println(adjMatrix[i][j]);
				}
				else
				{
					System.out.print(adjMatrix[i][j] + " ");
				}
			}
		}
	}
	public static void main(String argv[]) {
		Main g = new Main();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 32944
def solve():
    N = int(input())
    D = [int(i) for i in input().split()]
    # 対象となる木のパターン数のチェック
    mD = max(D)
    nD = [0] * (mD + 1)
    for d in D:
        nD[d] += 1
    # 頂点が1でなくてはならない
    if D[0] != 0:
        print(0)
        return
    # 頂点が複数あってはならない
    if nD[0] != 1:
        print(0)
        return
    count = nD[0]
    for i in range(2, len(nD)):
        count *= nD[i - 1] ** nD[i]
        count = count % 998244353
    print(count)


if __name__ == '__main__':
    solve()


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
	int n;cin>>n;
	int a=0;
	for(int i=1;i<=n;i++)if(i&1)a++;
	printf("%.20f\n",1.0*a/n);
	return 0;
}

Measured memory_bytes: 256
def resolve():
    # スイッチ数, 電球数
    (n, m) = list(map(int, input().split(" ")))
    ks = [] # 電球リスト、idx:0は対応するスイッチの個数
    for i in range(m):
        o = list(map(int, input().split(" ")))
        ks.append(o)
    ps = list(map(int, input().split(" "))) # 偶数か奇数か

    swstates = [2] * n
    cnt = 0
    for i in range(2 ** n):
        bins = format(i,'b').zfill(n)
        flg = False
        # 各電球につながったswitchについて、onの数を計算
        for j, k in enumerate(ks): # k[1:]は電球につながったスイッチのリスト
            ons = 0
            for s in k[1:]: # sは電球につながったスイッチ
                ons += int(bins[s-1])
            # 電球kにつながるswitchのonの数がわかった
            # 電球kにつながるswitchオンのodd/evenがps[j]と一致する必要がある
            if not ps[j] == ons % 2:
                flg = False
                break
            else:
                flg = True
        if flg:
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
//*************** Constraints are always Imaginary,I'm real **************
using namespace std;
#define int long long 
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define fi first
#define se second
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
int32_t main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
   // freopen("output.txt","w",stdout);
    // #endif
     int n;
     cin>>n;
     vector<pair<string,int>> pal(n);
     //unordered_map<string,int> mp;
     for(int i=0;i<n;i++)
     {
          string str;
          int a;
          cin>>str>>a;
          pal[i]={str,a};
         // mp[str]=a;

     }
     string f;
     cin>>f;
     int index;
     for(int i=0;i<n;i++)
     {
          if(pal[i].first==f)
          {
               index=i+1;
               break;
          }
     }
     int sum=0;
     while(index<n)
     {
          sum+=pal[index].second;
          index++;
     }
     cout<<sum;
     return 0;
}

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

#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 16;
const int M = (1LL<<N);

const int inf = 1e14;

int n;
int a[N][N];
int dp[M];
int val[M];

signed main()
{
    fast;
    
    cin >> n;
    
    f(i,n) f(j,n) cin >> a[i][j];
  
    f(i,(1LL<<n)) f(j,n)    
               if(i&(1LL<<j))
               { 
                    val[i] = (val[i^(1LL<<j)]);
        
                    f(k,n) if(i&(1LL<<k)) val[i]+=a[j][k];
        
                    break;
               }
    
    dp[0] = 0;
    
    f(i,(1LL<<n))
        for(int j=i;;j=(j-1)&i)
    {
        dp[i] = max(dp[i],dp[j] + val[i^j]);
        if(j==0)break;
    }
    cout << dp[(1LL<<n)-1];
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

void solve()
{
 int n;cin>>n;
map<string,int>mp;
while(n--)
{
    string s;cin>>s;
    mp[s]++;
}
cout<<"AC x "<<mp["AC"]<<endl;
cout<<"WA x "<<mp["WA"]<<endl;
cout<<"TLE x "<<mp["TLE"]<<endl;
cout<<"RE x "<<mp["RE"]<<endl;
 
}


int32_t main()
{
    rapido;
    int t;
    t=1;
    while(t--) 
    {
        solve();
    }
}

Measured memory_bytes: 3664
#include<stdio.h>
int main(){
int a,b,c,d;
scanf("%d %d %d",&a,&b,&c);
d=c-a;
if(a>=c){
printf("0\n");
}
else if(d<=b){
printf("%d\n",d);
}
else{
printf("NA\n");
}
return 0;
}



Measured memory_bytes: 2120
#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()

int main(){
    int n,m;
    cin>>n>>m;
    char fi1[n][n];
    char fi2[m][m];

    rep(i,n){
        rep(j,n){
            cin>>fi1[i][j];
        }
    }

    rep(i,m){
        rep(j,m){
            cin>>fi2[i][j];
        }
    }

    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            bool ok=true;
            rep(k,m){
                rep(l,m){
                    if(fi1[i+k][j+l]!=fi2[k][l]) ok=false;
                }
            }
            if(ok){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    cout<<"No"<<endl;
}


Measured memory_bytes: 3644
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  string s;
  cin >> s;
  rep(bi, 1 << 3)
  {
    char op[3];
    int temp = bi;
    rep(i, 3)
    {
      op[i] = (temp % 2 == 0 ? '+' : '-');
      temp /= 2;
    }
    int sum = s[0] - '0';
    rep(i, 3)
    {
      sum += (op[i] == '+' ? 1 : -1) * (s[i + 1] - '0');
    }
    if (sum == 7)
    {
      cout << s[0];
      rep(i, 3) cout << op[i] << s[i + 1];
      cout << "=7\n";
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  ll n;
  cin >> n;
  ll a[100001];
  for (ll i = 0; i <= 100000; ++i) a[i] = 0;
  for (ll i = 0; i < n; ++i) {
    ll ai;
    cin >> ai;
    a[ai]++;
  }
  ll ans = 0;
  for (ll i = 2; i <= 100000; ++i) {
    ans = max(ans, a[i-2]+a[i-1]+a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans,k;
int d[111];
int a[111][111];
signed main(){
	
	cin>>n>>k;
	rep(i,k){
		cin>>d[i];
		rep(j,d[i]){
			cin>>a[i][j];
		}
	}
	int su[111]={0};
	rep(i,k){
		rep(j,d[i]){
			su[a[i][j]]=1;
		}
	}
	rep(i,n){
		if(!su[i+1])ans++;
	}
	cout<<ans<<endl;
}


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

long long int gcd(long long a, long long b) {
	if (a % b == 0)return b;
	else return gcd(b, a % b);
}

int main() {
	int n;
	long long x, input,ans;
	cin >> n >> x;

	cin >> input;
	ans = abs(input - x);
	for (int i = 1; i < n; i++) {
		cin >> input;
		ans = gcd(ans, abs(x - input));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int gcd(int a,int b){
	if(a<=b){
		swap(a,b);
	}
	if(b==0){
		return a;
	}else{
		return gcd(b,a%b);
	}
}
int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int gc=gcd(a[0],a[1]);
	for(int i=2;i<n;i++){
		gc=gcd(gc,a[i]);
	}
	if(gc!=1){
		cout<<"not coprime"<<endl;
		return 0;
	}
	set<int> s;
	for(int i=0;i<n;i++){
		if(a[i]==1){
			continue;
		}
		for(int j=1;j*j<=a[i];j++){
			if(a[i]%j==0){
				if((j!=1&&s.find(j)!=s.end())||s.find(a[i]/j)!=s.end()){
					cout<<"setwise coprime"<<endl;
					return 0;
				}
				s.insert(j);
				s.insert(a[i]/j);
			}
		}
	}
	cout<<"pairwise coprime"<<endl;
	return 0;
}

Measured memory_bytes: 6844
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define SZ(x) ((int)(x).size())
#define MEM(x,a) memset(x,a,sizeof(x))
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
const ll mod=1000000007,N=1e5+5,M=1e5+5,INF=0x3f3f3f3f;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//head

int main(void){
    int r;
    cin>>r;
    printf("%f",acos(-1)*2*r);
    return 0;
}

Measured memory_bytes: 3760
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = list(map(int, sys.stdin.buffer.readline().split()))
    A = set([int(sys.stdin.buffer.readline().rstrip()) for _ in range(M)])

    ret = [0, 1]
    for i in range(1, N + 1):
        if i in A:
            ret.append(0)
        else:
            ret.append((ret[-1] + ret[-2]) % MOD)

    print(ret[-1] % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13200
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!

    var max = 0
    for (i in 0 until N) {
        val s1 = S.substring(0..i)
        val s2 = S.substring(i + 1 until N)

        val s2dis = s2.toCharArray().distinct()
        max = Math.max(max,s1.toCharArray().distinct().filter{s2dis.contains(it)}.size)
    }
    println(max)
}




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


int main() {
  
  string s ;
  cin >> s ;
  
  int a=s.size();
  int c=0;
  for(int i=0;i<a/2 ;i++){
    if(s.at(i)!=s.at(a-1-i)){
      c++;
    }
  }
  
  cout << c <<endl;
}

Measured memory_bytes: 256
package main
import(
  "fmt"
)
func main(){
  var(
    a string
    rec []int
    val int
  )
  fmt.Scan(&a)
  rec=append(rec,-1)
  for i,j:=range a{//A65G71C67T84
    if j!=65&&j!=71&&j!=67&&j!=84{//AGCT以外の位置を記録
      rec=append(rec,i)
    }
  }
  rec=append(rec,len(a))
  for i,j:=range rec{
    if i<len(rec)-1{
      b:=rec[i+1]-j-1
      if b>val{
        val=b
      }
    }
  }
  fmt.Println(val)
}

Measured memory_bytes: 512
N = int(input())
money = 0
for i in range(N):
    x, u = list(input().split(' '))
    if(u == 'JPY'):
        rate = 1.0
        x = int(x)
    else:
        rate = 380000.0
        x = float(x)
    money += x * rate
print(money)


Measured memory_bytes: 2940
// यथा चतुर्भिः कनकं परीक्ष्यते निघर्षणच्छेदनतापताडनैः।
// तथा चतुर्भिः पुरुषः परीक्ष्यते त्यागेन शीलेन गुणेन कर्मणा॥
#include <bits/stdc++.h>
using namespace std;
#define lld long long int
#define M 1000000007
#define fors(i,n) for(int i=0;i<n;++i)
#define fore(i,a,b) for(int i=a;i<=b;++i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vv std::vector<int>
#define mapii std::map<int,int>
#define mpaci std::map<char,int>
#define umapii std::unordered_map<int,int>
#define umapci std::unordered_map<char,int>
#define seti std::set<int>
#define useti std::unordered_set<int>
#define qi std::queue<int>
#define qc std::queue<char>
#define sti std::stack<int>
#define stc std::stack<char>
#define endl "\n"
#define test(i) cout<<i<<endl
#define tests(i) cout<<"i: "<<i<<endl;
#define itrt int t; cin>>t; fors(i,t)
#define itr1 int t; cin>>t;
#define ff first
#define ss second
#define pb push_back
#define vmp make_pair
#define ppb pop_back
#define sorta(a,n) sort(arr,arr+n)
#define sortv(x) sort(x.begin(),x.end())
#define all(x) x.begin(),x.end() 
#define printv(v) for(auto x: v){ cout<< x << " ";}
#define pi 3.14159265358979323846
#define setprc(x) setprecision(x)
void file(){
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
bool sortdesk(const pair<int,int> &a, const pair<int,int> &b){return a.ff>b.ff;}
bool sortdesv(const pair<int,int> &a, const pair<int,int> &b){return a.ss>b.ss;}
bool sortascv(const pair<int,int> &a, const pair<int,int> &b){return a.ss<b.ss;}
bool sortasck(const pair<int,int> &a, const pair<int,int> &b){return a.ff<b.ff;}
bool is_prime(int n){if(n==1){return false;}int i=2;while(i*i<=n){if(n%i==0){return false;}i+=1;}return true;}
int gcd(int a, int b){if (b == 0){return a;} return gcd(b, a % b);}
int cntdiv(int n){int cnt=0;for(int i=1;i<=sqrt(n);++i){if(n%i==0){if(n/i==i)++cnt;else{cnt = cnt + 2;}}}return cnt;}
lld posnegmod(lld a,lld b){//return (x%mod+mod)%mod; //long long int r = a % b;return r < 0 ? r + b : r;
}
// cout<<fixed<<setprecision(20)
// lld fact(lld n);
// lld nCr(lld n,lld r){return fact(n) / (fact(r) * fact(n - r));}
// lld fact(lld n){ lld res = 1; for(lld i = 2; i <= n; i++){res = res * i;}return res;} 
// const int maxi = 1e6+10;
// vector<lld> v[maxi];
// vector<lld> h(maxi);
// vector<long long> a(maxi,0);
// lld res=0;
// void dfs(int x){
//     if(a[x]){
//         return;
//     }
//     a[x]=1;
//     int flag=1;
//     for(int i:v[x]){
//         if(h[x]<=h[i]){
//             flag=0;
//             break;
//         }
//     }
//     if(flag){
//         ++res;
//     }
// }

void test_case(){
    int n;
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(i%2 && x%2){
            ++cnt;
        }
    }
    cout<<cnt<<endl;
}

int main(){
    fastio;
    file();
    int T=1;
    // int T;
    // cin>>T;
    for(int nr=1;nr<=T;++nr) {
        // cout<<"Case #"<<nr<<": ";
        test_case();
    }
}
// PD?D??P

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
const int N = 20;
const int M = 100000;
const int MOD = 1e9 + 7;
int n, m;
int A[N], B[N], S = 1;
int f[M], c[M];
void ADD(int &t, int d)
{
    t += d; if (t >= MOD) t -= MOD;
}
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i)
    {
        int a, b;
        cin >> a >> b;
        B[a - 1] |= 1 << (b - 1);
    }
    for (int i = 1; i < (1 << n); ++ i)
        c[i] = c[i >> 1] + (i & 1);
    f[(1 << n) - 1] = 1;
    for (int i = (1 << n) - 1; i; -- i)
    {
        for (int j = i; j; j = (j - 1) & i)
        {
            if (!(((bool)(j & 1)) ^ ((bool)(j & 2))))
            {
                int w = f[i];
                for (int k = 0; k < n; ++ k)
                    if ((1 << k) & (i ^ j))
                        w = 1ll * w * ((1 << c[B[k] & j]) - 1) % MOD;
                for (int k = 0; k < n; ++ k)
                    if ((1 << k) & j)
                        w = 1ll * w * (1 << c[B[k] & (i ^ j)]) % MOD;
                ADD(f[i ^ j], w);
            }
        }
    }
    for (int i = 0; i < m; ++ i) S = 2ll * S % MOD;
    cout << (S - f[0] + MOD) % MOD << endl;
}


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

using namespace std;

void read(){
    freopen("in.txt", "r", stdin);
}
int main(){
    //read();
    int n; cin >> n;
    vector<int> h(n);

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

    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);

    for(int i = 2; i < n; i++){
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]),
                    dp[i - 1] + abs(h[i] - h[i - 1]));
    }
    cout << dp[n - 1];
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define maxn 500086

using namespace std;

int n, m;
map<pair<int, int>, int> mp;
int x, y, z;
int cnt;

vector<pair<int, int> > v[maxn]; 

inline void addEdge(int x, int y, int z){
	v[x].push_back({y, z}), v[y].push_back({x, z});
}

priority_queue<pair<int, int>, vector<pair<int, int> >, greater<pair<int, int> > > q;
bool vis[maxn];
int dis[maxn];

int main(){
	scanf("%d%d", &n, &m), cnt = n;
	while(m--){
		scanf("%d%d%d", &x, &y, &z);
		if(!mp[{x, z}]) mp[{x, z}] = ++cnt;
		if(!mp[{y, z}]) mp[{y, z}] = ++cnt;
		int xx = mp[{x, z}], yy = mp[{y, z}];
		addEdge(x, xx, 1), addEdge(xx, yy, 0), addEdge(yy, y, 1);
	}
	memset(dis, 0x3f, sizeof(dis));
	dis[1] = 0, q.push({dis[1], 1});
	for(int i = 1;i <= cnt;i++){
		while(!q.empty() && vis[q.top().second]) q.pop();
		if(q.empty()) break;
		int x = q.top().second;q.pop();
		vis[x] = true;
		for(int j = 0;j < v[x].size();j++){
			int to = v[x][j].first, co = v[x][j].second;
			if(dis[to] > dis[x] + co){
				dis[to] = dis[x] + co;
				q.push({dis[to], to});
			}
		}
	}
	printf("%d", dis[n] == 0x3f3f3f3f ? -1 : (dis[n] / 2));
}

Measured memory_bytes: 61452
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

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

void dfs(const vector<vector<int64_t>>& adjs, int64_t current,
         vector<int64_t>& parent, vector<int64_t>& depth,
         vector<int64_t>& max_depth) {
    for (auto v : adjs[current]) {
        if (v == parent[current]) {
            continue;
        }

        depth[v] = depth[current] + 1;
        max_depth[v] = depth[current] + 1;
        parent[v] = current;
        dfs(adjs, v, parent, depth, max_depth);
        max_depth[current] = max(max_depth[current], max_depth[v]);
    }
}

int main() {
    int64_t n, u, v;
    cin >> n >> u >> v;
    --u;
    --v;

    vector<vector<int64_t>> adjs(n);
    for (auto i : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        adjs[a].push_back(b);
        adjs[b].push_back(a);
    }

    vector<int64_t> parent(n, -1), depth(n), max_depth(n);
    dfs(adjs, v, parent, depth, max_depth);
    int64_t u_depth = depth[u];
    int64_t m = max_depth[u];
    while (parent[u] >= 0) {
        u = parent[u];
        if (2 * depth[u] <= u_depth) {
            break;
        }

        m = max(m, max_depth[u]);
    }

    cout << m - 1 << endl;
}

Measured memory_bytes: 16000
N,K=map(int,input().split())
A=[0]+list(map(int,input().split()))
T={1:1}
c=1
for i in range(2,K+1):
    c=A[c]
    K-=1
    if c in T:
        l = list(T.keys())[T[c]-1:]
        print(l[K%len(l)])
        break
    else: T[c]=i
else: print(A[c])

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

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

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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

string s;
void input()
{
    cin>>s;
    return;
}

void solve()
{
    rep(i,s.length()) s[i]='x';
    cout<<s<<endl;
    return;
}

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

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	char c;
	cin >> c;
	cout << (char)(c + 1) << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
lst = [[] for _ in range(N + 1)]
dist = [float("inf")]*(N+1)
for _ in range(M):
    a, b = map(int, input().split())
    lst[a].append(b)
    lst[b].append(a)

q = deque()
d = 0
q.append([1,d])

while q:
    now, d = q.popleft()
    dist[now] = d
    if now == N:
        if d <= 2:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")
        exit()
    
    for itm in lst[now]:
        if dist[itm] > d+1:
            q.append([itm,d+1])
            
print("IMPOSSIBLE")

Measured memory_bytes: 49816
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int dx[2] = {1, 0};
int dy[2] = {0, 1};
int dist[110][110];
string fi[110];
int main() {
  int h,w;
  cin >> h >> w;
  rep(i,h) cin >> fi[i];
  rep(i,h)rep(j,w){
    dist[i][j] = 100100;
  }
  dist[0][0] = (fi[0][0] == '#');
  queue<P> que;
  que.push(P(0, 0));
  while (!que.empty()) {
      P cur = que.front();
      que.pop();
      int x = cur.first;
      int y = cur.second;
      for (int dir = 0; dir < 2; ++dir) {
          int nx = x + dx[dir];
          int ny = y + dy[dir];
          if (nx >= h || ny >= w) continue;
          int m = dist[x][y]+(fi[x][y]=='.' && fi[nx][ny] == '#');
          if (dist[nx][ny] > m) {
              dist[nx][ny] = m;
              que.push(P(nx, ny));
          }
      }
  }
  cout<<dist[h-1][w-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

const int MAX = 500000;
int dp[MAX];

int main() {
  int n;
  int N = 0;
  while(cin>>n, n) {
    int c[n];
    int M = 1;
    REP(i, n) {
      cin >> c[i];
      M += c[i];
    }
    sort(c, c+n);
    printf("Case #%d: ", ++N);
    if (c[0] != 1) {
      puts("Cannot pay some amount");
      continue;
    }
    REP(i, M) dp[i] = INF;
    dp[0] = 0;
    REP(i, n) {
      REP(j, M-c[i]) {
        dp[j+c[i]] = min(dp[j+c[i]], dp[j]+1);
      }
    }
    //REP(i, MAX) cout << dp[i] << " ";
    bool dame = 0;
    REP(i, M) {
      int now = i;
      int cnt = 0;
      for (int j=n-1; j>=0; --j) {
        cnt += now / c[j];
        now %= c[j];
      }
      if (dp[i] != cnt) {
        dame = 1;
        break;
      }
    }
    if (!dame) {
      puts("OK");
    } else {
      puts("Cannot use greedy algorithm");
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
void Set(); void Solve(); void Clean();
int main(){Set(); Solve(); Clean(); return 0;}

int N;
int *d;

void Solve()
{
	LL ans = 0L;
	for (int i = 0; i < N - 1; ++i)
		for (int j = i + 1; j < N; ++j)
			ans += d[i] * d[j];
	cout << ans << endl;
}

void Set()
{
#if DEBUG_MODE
	N = 3;
	d = new int[N];
	d[0] = 3; d[1] = 1; d[2] = 2;
#else
	cin >> N;
	d = new int[N];
	for (int i = 0; i < N; ++i) cin >> d[i];
#endif
}

void Clean()
{
	delete[] d;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

int gcd(int x, int y) {
  if (x < y) swap(x, y);
  while (y > 0) {
    int r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//for(int i = ; i < ; i++){}

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

    bool a[26];
    bool b[26];
    
    int ans = 0;
    for(int i = 0; i < n-1; i++){
        int sum = 0;
        for(int j = 0; j < 26; j++){
            a[j]=false;
            b[j]=false;
        } 
        for(int j = 0; j < i+1; j++){
            a[s[j]-'a']=true;
        }
        for(int j = i+1; j < n; j++){
            b[s[j]-'a']=true;
        }
        for(int j = 0; j < 26; j++){
            if(a[j]&&b[j])sum++;
        }
        ans = max(sum,ans);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	s := []string{rs(), rs(), rs()}
	length := []int{len(s[0]), len(s[1]), len(s[2])}
	abc := []string{"A", "B", "C"}

	var turn = 0
	nthCard := []int{0, 0, 0}

	for nthCard[turn] != length[turn] {
		temp := nthCard[turn]
		nthCard[turn]++
		switch s[turn][temp] {
		case 'a':
			turn = 0
		case 'b':
			turn = 1
		case 'c':
			turn = 2
		}
	}

	fmt.Println(abc[turn])
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (c > b && d > a || c < b && d < a) {
        cout << 0 << endl;
        return 0;
    }
    if (a < c) {
        swap (a, c);
    }
    if (b > d) {
        swap (b, d);
    }
    cout << b - a << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;

int mark[MAX];
int CNT[MAX];
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, n)CNT[i] = 1;
	
	mark[0] = 1;
	FOR(i, 0, m)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (mark[a]) mark[b] = 1;
		CNT[a]--;
		CNT[b]++;
		if (CNT[a] == 0) mark[a] = 0;
	}

	int ans = 0;
	FOR(i, 0, n)
	{
		if (mark[i]) ans++;
	}

	cout << ans << endl;
}

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

int main(){
  int N;
  int ans = 1;
  cin >> N;
  int pow = 1;
  for(int i = 1 ; i < 7; i++){
    pow = pow * 2;
    if(N >= pow){
      ans = pow;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d double
#define pii pair<int,int>
#define pb push_back
#define cases int tc;cin>>tc;while(tc--)
#define N 100003
#define M 1003
//int mod=1e9+7;
//int mod=998244353;

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

    int a,b,k;
    cin>>a>>b>>k;
    int i,j;
    int cnt=0;
    for(i=min(a,b);i>=1;--i)
    {
        if(a%i==0 && b%i==0)
            ++cnt;
        if(cnt==k)
        {
            cout<<i;
            return 0;
        }
    }



    return 0;
}


Measured memory_bytes: 256
import numpy as np
S = input()

s_list = [int(s) for s in S]

case_1 = []
case_2 = []
for i in range(len(S)):
    if i % 2 == 0:
        case_1.append(1)
        case_2.append(0)
    else:
        case_1.append(0)
        case_2.append(1)

s_list_array = np.array(s_list)
case_1_array = np.array(case_1)
case_2_array = np.array(case_2)
result_1_list = (s_list_array + case_1_array).tolist()
result_2_list = (s_list_array + case_2_array).tolist()
result_1 = result_1_list.count(1)
result_2 = result_2_list.count(1)

print(min(result_1, result_2))


Measured memory_bytes: 19752
#include<bits/stdc++.h>
using namespace std ;
 
#define int long long
 
#define IOS ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vp vector<pii>
#define vs vector<string>
#define all(v) v.begin(),v.end()
 
#define lb  lower_bound
#define ub  upper_bound
#define bs  binary_search
#define ff  first
#define ss  second
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
 
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
     
#define pi 3.14159265358979323846//20 decimals
#define MOD 1000000007

int32_t main(){
 
   
     IOS
    
   int n;
   cin>>n;
   vi dp(3,0);
   vi new_dp(3,0);
   vi happy(3,0);
   for(int vac=0;vac<n;vac++)
   {
      for(int i=0;i<3;i++)
        cin>>happy[i];
      for(int i=0;i<3;i++){
        for(int j=0;j<3;j++)
        {
          if(i!=j)
          {
            new_dp[j]=max(new_dp[j],dp[i]+happy[j]);
          }
        }
      }
      dp=new_dp;
   }
  

   cout<<max({dp[0],dp[1],dp[2]});
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int A, B;
            cin >> A >> B;
                if(A == B){
                    cout << 2 * A << endl;
                }else if(A > B){
                    cout << 2 * A - 1 << endl;
                }else if(B > A){
                    cout << 2 * B - 1 << endl;
                }else{}
    return 0;}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner (System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [] list = new int[M];
        for(int a=0;a<N;a++){
            int k = sc.nextInt();
            for(int b=0;b<k;b++){
                int A = sc.nextInt();
                list[A-1]++;
            }
        }
        int num=0;
        for(int a=0;a<M;a++) if(list[a]==N)num++;
        System.out.println(num);
    }
}


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

int main() {
  char c;
  scanf("%c", &c);

  char vowels[] = {'a', 'i', 'u', 'e', 'o'};

  bool flag = false;
  for(int i = 0; i < 5; i++) {
    if (c == vowels[i]) {
      flag = true;
    }  
  }
  
  if(flag){
    printf("vowel\n");
  } else {
     printf("consonant\n");
  }

}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
x,y= [int(i) for i in input().split()]
a1 = [1,3,5,7,8,10,12]
a2 = [4,6,9,11]
a3 = [2]
if x in a1 :
    if y in a1 :
        print("Yes")
    else :
        print("No")
elif x in a2 :
    if y in a2 :
        print("Yes")
    else :
        print("No")
elif x == 2 :
    if y == 2:
        print("Yes")
    else :
        print("No")


Measured memory_bytes: 3064
for i in xrange(input()):
    base, result, out = 0, 0, 0
    while out != 3:
        cmd = raw_input()
        if cmd == "HIT":
            if base == 3:
                result += 1
            else:
                base += 1
        elif cmd == "HOMERUN":
            result += base + 1
            base = 0
        else:
            out += 1
    print result

Measured memory_bytes: 4204
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long 
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int n=a.length()+b.length();
	char name[n+2];
	int i=1;
	for(int j=0;j<a.length();j++)
	{
		name[i]=a[j];
		i+=2;
	}
	i=2;
	for(int j=0;j<b.length();j++)
	{
		name[i]=b[j];
		i+=2;
	}
	for(int i=1;i<=n;i++)cout<<name[i];
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
  int key;
  Node *next,*prev;
};

Node *nil;

Node* listSearch(int key){
  Node *cur =nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void printList(){
  Node *cur=nil->next;
  int isf=0;
  while(1){
    if(cur==nil)break;
    if(isf++>0)printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t==nil)return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void deletekey(int key){
  deleteNode(listSearch(key));
}

void insert(int key){
  Node *x=(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key,n,i;
  int size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%s%d",com,&key);
    if(com[0]=='i'){insert(key);np++;size++;}
    else if(com[0]=='d'){
      if(strlen(com)>6){
        if(com[6]=='F')deleteFirst();
        else if(com[6]=='L')deleteLast();
      }else{
        deletekey(key);nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}

Measured memory_bytes: 33844
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

bool han(int a){
    for(int i = 2; i * i <= a; i++){
        if(a % i == 0){
            return false;
        }
    }
    return a != 1;
}


bool d2017(int n){
    if(n == 1 || n == 2) return false;
    else if(n % 2 == 0) return false;
    else {
        if(han(n) && han((n + 1) / 2)) {
            return true;
        }
    }
    return false;
}


int main(){
    int N;
    cin >> N;
    vector<int> a(100001);
    for(int i = 0; i <= 100000; i++){
        if(d2017(i)) a[i] = 1;
        else a[i] = 0;
    }

    vector<int> sum(100002);
    sum[0] = 0;
    for(int i = 0; i <= 100000; i++){
        sum[i+1] = sum[i] + a[i];
    }

    for(int i = 0; i < N; i++){
        int r, l;
        cin >> r >> l;
        cout << sum[l + 1] - sum[r] << endl;
    }
    return 0;
}

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

int main() {
	int a,b;
  	cin >> a >> b;
  	if(a == b){
      cout << "Draw" << endl;
    }else if(a > b && b != 1 || a == 1){
      cout << "Alice" << endl;
    }else if(a < b || a != 1 || b == 1){
      cout << "Bob" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a,b,c,x,y;
int main(){
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if (2*c<a+b){
		int ans=0;
		if (x>y) swap(x,y),swap(a,b);
		if (x<y){
			ans+=x*2*c;
			y-=x;
			if (c*2<b) ans+=y*2*c;
			else ans+=y*b;
			printf("%d\n",ans);
		}else if (x==y){
			printf("%d\n",(x+y)*c);
		}
	}else{
		printf("%d\n",a*x+b*y);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n;
  string s,t;
  cin >> n >> s >> t;
  vi blocks;
  rep(i, n){
    if(s[i] == t[i]){
      blocks.push_back(1);
    }else{
      blocks.push_back(2);
      i++;
    }
  }
  ll ans = 3 * blocks[0];
  for(int i = 0; i < n - 1; i++){
    if(blocks[i] == 1 && blocks[i + 1] == 1){
      ans *= 2;
      ans %= mod;
    }
    if(blocks[i] == 1 && blocks[i + 1] == 2){
      ans *= 2;
      ans %= mod;
    }
    //if(blocks[i] == 2 && blocks[i + 1] == 1){
    //}
    if(blocks[i] == 2 && blocks[i + 1] == 2){
      ans *= 3;
      ans %= mod;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256