akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
      vector <string> v;
      int n, l;
      cin >> n >> l;
      while(n--)
      {
        string s;
        cin >> s;
        v.push_back(s);
        // cout<<s<<"\n";
        sort(v.begin(), v.end());
      }
      for(int i = 0 ; i < v.size(); i++)
          cout<<v[i];
    return 0;
    }

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

int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s[n], tmp;
  map<string,int> mp;
  char end;
  rep(i,n){
    cin >> tmp;
    mp[tmp]++;
    s[i] = tmp;
  }
  rep(i,n-1){
    end = s[i][s[i].length()-1];
    if(end != s[i+1][0]) {
      cout << "No" << endl;
      return 0;
    }
  }
  for(auto itr = mp.begin();itr != mp.end();++itr){
    if(itr->second > 1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
s = input()
s = s[::-1]
n = len(s)

num = [0]*2019
num[0] = 1
number = 0
d = 1

for i in s:
    number += int(i)*d
    num[number%2019] += 1
    d *= 10
    d %= 2019

ans = 0

for i in num:
    ans += i*(i-1)//2

print(ans)

Measured memory_bytes: 9232
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {

	int n, k;
	cin >> n >> k;

	if ((n + 1) / 2 >= k)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 29;
constexpr lint   INFL = 1LL << 61;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << max({a + b, a * 2 - 1, b * 2 - 1}) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#define mod 1000000007
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define srep(i,s,t) for (ll i = s; i < t; i++)
#define drep(i,n) for(ll i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef vector<vector<char>> field_t;
typedef unsigned long long ull;
typedef pair<ll, ll> point_t;


int main()
{
    ll n;
    cin >> n;
    string S;
    vector<ll> v(4,0);
    rep(i,n){
        cin >> S;
        if(S=="AC"){
            v[0]++;
        }
        if(S=="WA"){
            v[1]++;
        }
        if(S=="TLE"){
            v[2]++;
        }
        if(S=="RE"){
            v[3]++;
        }
    }
    cout << "AC x "<<v[0]<< endl;
    cout << "WA x "<<v[1]<< endl;
    cout << "TLE x "<<v[2]<< endl;
    cout << "RE x "<<v[3]<< endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		
		if(C*2 < A+B) {
			int cNum = Math.min(X, Y)*2;
			int ans = cNum*C;
			X -= cNum/2;
			Y -= cNum/2;
			ans += Math.min(A, C*2)*Math.max(X, 0);
			ans += Math.min(B, C*2)*Math.max(Y, 0);
			System.out.println(ans);
		} else {
			System.out.println(A*X + B*Y);
		}
				
		sc.close();
	}
}


Measured memory_bytes: 21844
import math
tax_eight, tax_ten = map(int, input().split())
min_eight_price = math.ceil(tax_eight / 0.08)
max_eight_price = math.floor((tax_eight + 1) / 0.08 - 1)
min_ten_price = tax_ten / 0.1 
max_ten_price = (tax_ten + 1) / 0.1 - 1
min_price = max(min_eight_price, min_ten_price)
max_price = min(max_eight_price, max_ten_price)
if max_price < min_price:
    print(-1)
else:
    print(int(min_price))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			String str = sc.nextLine();
			String[] nums = str.split(" ");
			int[] a = new int[nums.length];
			int ace=0, score=0;
			boolean flag = true;
			
			if(nums[0].equals("0")) break;
			
			for(int i=0; i<nums.length; i++) {
				a[i] = Integer.parseInt(nums[i]);
				if(a[i] == 1) ace++;
				else if(a[i]>9 && a[i]<14) score+=10;
				else score+=a[i];
				
				if(score>21) {
					score=0;
					flag = false;
					break;
				}
			}
			
			if(score +1*ace > 21) {
				flag = false;
				score=0;
			}
			
			int tt = score;
					
			if(flag){
				for(int i=0; i<=ace; i++){
					if(tt + 1*i + 11*(ace-i) <= 21) {
						score = tt + 1*i + 11*(ace-i);
						break;
					} 	
				}
			}
		
			System.out.println(score);
		}	

	}
}

Measured memory_bytes: 19220
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	char s[20];
	while(scanf("%s",s)!=EOF)
	{
		s[5]=s[13]=' ';
		puts(s);
	}
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
multiset<ll,greater<ll>> st[200000];
multiset<ll> ss;
ll N;
P A[200000];
 
int main() {
    cin >> N;
    cout << (2199 - N)/200 << endl;
    
}


Measured memory_bytes: 12972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG



signed main() {
  int N, C, K; cin >> N >> C >> K;
  vector<int> T(N);
  rep(i, N) cin >> T[i];
  
  sort(all(T));
  
  int ans = 0;
  int n = 0;
  
  while(true) {
    if(n == N) break;
    ans++;
    int k = 0;
    int t = T[n]+K;
    while(n+k < N && k < C && T[n+k] <= t) k++;
    n += k;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 16 20:59:15 2020

@author: H_Hoshigi
"""

A, B, C = map(int, input().split())

if (A==B and B!=C) or (B==C and C!=A) or (C==A and A!=B):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38384
N,K = list(map(int,input().split()))
D = list(map(str,input().split()))
D = set(D)
# print(D)
i = N
while True:
    # print("i =",i)
    b = list(str(i))
    b = set(b)
    # print(b)
    c = b&D
    # print(c)
    if len(c)>0 :
        i += 1
        continue
    else:
        print(i)
        break

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());
            var B = int.Parse(Console.ReadLine());

            X -= A;
            X %= B;

            Console.WriteLine(X);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans = t;
    for(int i = 0; i < n; i++)
    {
        bool flag = true;
        for(int j = 0; j < n; j++)
        {
            if(ans[j] != s[j]) flag = false;
        }
        if(flag)
        {
            cout << ans.size() << endl;
            return 0;
        }
        ans = s.substr(0, i+1) + t;
    }
    cout << ans.size() << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int s;
    cin >> s;
    bool ok=1;
    if (s%111==0) cout << s;
    else if (s<((int)s/100*111)) cout << (int)s/100*111; else cout << (s/100+1)*111; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int N;
string s;
int main() {
	cin >> N >> s;
	vector<bool> a(N);
	for (int i = 0; i < 4; ++i) {
		a[0] = (i % 2 == 0);
		a[1] = (i / 2 == 0);
		for (int j = 1; j < N-1; ++j) {
			if ((a[j] && s[j] == 'o') || (!a[j] && s[j] == 'x')) {
				a[j + 1] = a[j - 1];
			} else {
				a[j + 1] = !a[j - 1];
			}
		}
		bool ok = true;
		if ((a[0] && s[0] == 'o') || (!a[0] && s[0] == 'x')) {
			if (a[1] != a[N - 1]) ok = false;
		} else {
			if (a[1] == a[N - 1]) ok = false;
		}
		if ((a[N-1] && s[N-1] == 'o') || (!a[N-1] && s[N-1] == 'x')) {
			if (a[0] != a[N - 2]) ok = false;
		} else {
			if (a[0] == a[N - 2]) ok = false;
		}
		if (!ok) continue;
		for (int j = 0; j < N; ++j) cout << (a[j] ? "S" : "W");
		cout << endl;
		return 0;
	}
	cout << -1 << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

		Scanner scanner = new Scanner(System.in);

		String str = scanner.nextLine();
		String[] strs = str.split("");

		int five = 0;
		int seven = 0;

		for(String s: strs) {
			if(s.equals("5")) {
				five += 1;
			}else if(s.equals("7")) {
				seven += 1;
			}
		}

		if(five == 2 && seven == 1) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

		scanner.close();
	}
}

Measured memory_bytes: 21844
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    let A = parseInt(input[0].split(" ")[0]);
    const B = parseInt(input[0].split(" ")[1]);
    let C = parseInt(input[0].split(" ")[2]);
    const D = parseInt(input[0].split(" ")[3]);

    while(true){
        C=C-B
        if(C<=0){
            console.log("Yes")
            return
        }
        A = A - D
        if(A<=0){
            console.log("No")
            return
        }
    }
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 29584
#include "bits/stdc++.h"
#define int long long

using namespace std;

signed main() {
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve(l_1,l_2):
    result = 0
    for i,j in zip(l_1,l_2):
        if i != j:
            result += 1
    return result

s = input()
t = input()
n_s = len(s)
n_t = len(t)
ans = 10**5

for i in range(0,n_s-n_t+1):
    l = s[i:i+n_t]
    ans = min(ans,solve(t,l))

print(ans)

Measured memory_bytes: 9068
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 9999999999.
       01 B PIC 9999999999.
       01 C PIC X(100).
       01 REN PIC 9999999.
       01 RE PIC ZZZZZZZZ9.
       01 temp1 PIC 9999.
       01 temp2 PIC 9999.
       01 N PIC 9999.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT INP.
      	PERFORM VARYING temp1 FROM 1 BY 1 UNTIL INP(temp1:1)=SPACE
      	END-PERFORM.
      	SUBTRACT 1 FROM temp1.
      	MOVE INP(1:temp1) TO A.
      	ADD 2 TO temp1.
      	PERFORM VARYING temp2 FROM temp1 BY 1 UNTIL INP(temp2:1)=SPACE
      	END-PERFORM.
      	COMPUTE N=temp2 - temp1.
      	MOVE INP(temp1:N) TO B.
      	IF A >= B THEN
      		SUBTRACT B FROM A
      	ELSE
      		MOVE 0 TO A
      	END-IF.
      	MOVE A TO RE.
      	DISPLAY RE.
        STOP RUN.



Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
    LL n;
    cin>>n;
    vector<pair<LL, int> > dvs;
    for (LL i=2; i*i<=n; i++) {
        if (0==n%i) {
            dvs.push_back(make_pair(i, 0));
            while (0==n%i) {
                dvs.back().second++;
                n /= i;
            }
        }
    }
    if (n>1) 
        dvs.push_back(make_pair(n, 1));
    int ans = 0;
    for (pair<LL, int> &p : dvs) {
        int i=sqrt(p.second*2);
        if (i*(i+1)>p.second*2) 
            i--;
        ans += i;
    }
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 3724
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	
      	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        	System.out.println("Possible");
        } else {
        	System.out.println("Impossible");
        }
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int H, W, N, sy, sx;
    string S, T;
    cin >> H >> W >> N >> sy >> sx >> S >> T;

    {
        // L
        int x = sx;
        rep(i, N) {
            if (S[i] == 'L') x--;
            if (x == 0) {
                cout << "NO" << endl;
                return 0;
            }
            if (T[i] == 'R' && x < W) x++;
        }
    }

    {
        // R
        int x = sx;
        rep(i, N) {
            if (S[i] == 'R') x++;
            if (x == W + 1) {
                cout << "NO" << endl;
                return 0;
            }
            if (T[i] == 'L' && x > 1) x--;
        }
    }

    {
        // U
        int y = sy;
        rep(i, N) {
            if (S[i] == 'U') y--;
            if (y == 0) {
                cout << "NO" << endl;
                return 0;
            }
            if (T[i] == 'D' && y < H) y++;
        }
    }

    {
        // D
        int y = sy;
        rep(i, N) {
            if (S[i] == 'D') y++;
            if (y == H + 1) {
                cout << "NO" << endl;
                return 0;
            }
            if (T[i] == 'U' && y > 1) y--;
        }
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 1020
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#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
#include <math.h>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<vector<int>> S(N + 2, vector<int>(26));
	vector<int> numChar(26, 100);
	for (int i = 0; i <= N; i++) {
		string s;
		getline(cin, s);
		for (auto j = 0; j < s.size(); j++) {
			S.at(i).at(s.at(j) - 'a')++;
		}
	}

	for (int i = 1; i <= N; i++) {
		for (int k = 0; k < 26; k++) {
			numChar.at(k) = min(numChar.at(k), S.at(i).at(k));
		}
	}

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < numChar.at(i); j++) {
			cout << (char)(i + 'a');
		}
	}
	cout << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 2e5 + 1;

char v[9][9];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> v[i][j];
            cnt += (v[i][j] == '#');
        }
    }
    if (cnt != n + m - 1) {
        cout << "Impossible";
        return 0;
    }
    if (v[0][0] == '.' ||
        v[n - 1][m - 1] == '.') {
        cout << "Impossible";
        return 0;
    }
    int r = 0, c = 0;
    while (r < n - 1 || c < m - 1) {
        if (r < n - 1 && v[r + 1][c] == '#') {
            ++r; continue;
        }
        if (c < m - 1 && v[r][c + 1] == '#') {
            ++c; continue;
        }
        cout << "Impossible";
        return 0;
    }
    cout << "Possible";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int N, mx;
ll ans;
int A[101010], B[101010];
set<int> st;

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

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

	for (int i=0; i<N; i++)
		B[A[i]] = i;

	st.insert(-1); st.insert(N);
	for (int i=N; i>0; i--) {
		st.insert(B[i]);
		set<int>::iterator it = st.find(B[i]);
		set<int>::iterator p = prev(it), n = next(it);

		if (*p!=-1) {
			ans += (ll)i*(*n-*it)*(*p-*prev(p));
		}
		if (*n!=N) {
			ans += (ll)i*(*next(n)-*n)*(*it-*p);
		}
	}

	cout << ans;
}

Measured memory_bytes: 5760
#include<iostream>

using namespace std;

#define REP(i,n) for(int i = 0;i < n;i++)
	
int sum[2010];

void init()
{
	sum[0] = 0;
	for(int i = 1;i < 2001;i++)
		sum[i] = sum[i-1] + i;
}
	


int main()
{
	init();
	
	int n;
	while(cin >> n,n)
	{
		int ans = 0;
		for(int i = 2;i < n;i++)
		{
			for(int j = 0;j <n;j++)
			{
				if(sum[j+i] - sum[j] == n)ans++;
			}
		}
		
		cout << ans << endl;
		
	}
	
	return 0;
	
}

Measured memory_bytes: 2996
using System;
class Program
 {
        static void Main(string[] args)
        {
           string a = Console.ReadLine(); //標準入力
          char[] b = a.ToCharArray();
          char[] c = new char[16]{'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
        
          int num =0;
          for(int j =0;j< b.Length;j++)
          {
            if(b[j]!=c[j])
            {
              num++;
            }
          }
          
            Console.WriteLine(num);//改行付き出力
        }
 }


Measured memory_bytes: 13140
Q,H,S,D = (int(i) for i in input().split())
N = int(input())

q = Q*4
h = H*2
s = S
d = D/2

if min(q,h,s,d)==d:
    if N%2 == 0:
        money = D*(N//2)
    else:
        money = (N//2)*D + min(q,h,s)
else:
    money = min(q,h,s)*N

print(int(money))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
const ll mods = 1e9 + 7;

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<ll> s(n + 1, 0);
  rep(i, n) cin >> a[i];
  rep(i, n) s[i + 1] = s[i] + a[i];
  ll ans = 0;
  rep(i, n) {
    ll num = (s[n] - s[i + 1]) % mods;
    ans += a[i] * num;
    ans %= mods;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 5636
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B;
  cin>>A;
  int N[A-1];
  int M[A+1]={};
  for(int i = 0;i < A-1;i++){
    cin>>N[i];
    M[N[i]]++;
  }
  for(int i  = 1;i < A+1;i++)cout<<M[i]<<endl;
}

Measured memory_bytes: 5184
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t=[input() for _ in range(m)]

dic={}
for i in s:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1

for i in t:
    if i in dic:
        dic[i]-=1
ma=max(dic.values())
print(max(ma , 0))

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

using namespace std;

long long INF=1e15;

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

    long long a,b,c;
    cin>>a>>b>>c;

    long long ans=abs((a/2)*b*c-(a-a/2)*b*c);
    ans=min(ans,abs((a*(b/2)*c)-a*(b-b/2)*c));
    ans=min(ans,abs((a*b*(c/2))-a*b*(c-c/2)));

    cout<<ans<<endl;
}

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

int main(){
    long n;
    cin >> n;

    long ans = 0;
    for (long i=1; i*(i+1)<n; i++){
        long ret = (n-i)%i;
        if (ret==0){
            long cand = (n-i)/i;
            ans+=cand;
//            cout << cand << endl;
        }
    }

    cout << ans << endl;
}

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

int main() {
    int x, y, ans = 0;
    cin >> x >> y;
    if(x == 1) ans += 300000;
    else if(x == 2) ans += 200000;
    else if(x == 3) ans += 100000;
    if(y == 1) ans += 300000;
    else if(y == 2) ans += 200000;
    else if(y == 3) ans += 100000;
    if(x == 1 && y == 1) ans += 400000;
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
   long     a = scan.nextLong();
        long     b = scan.nextLong();
        long     c = scan.nextLong();
        long     d = scan.nextLong();

     long   p=Math.max(Math.max(a*c,b*d),Math.max(a*d,c*b));
        System.out.println(p);


    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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


int main(){
	string S;
	cin>>S;
	FOR(i,1,(int)S.length()){
		if((S.length()-i)%2!=0) i++;
		int div=(S.length()-i)/2;
		
		if(S.substr(0,div)==S.substr(div,div)){
			printf("%d\n",div*2);
			break;
		}
	}
	
	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int d,r;
    double f;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout << d << " " << r << " ";
    cout << fixed << setprecision(8) << f << endl;
    return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll n,a,b,c,d,e; 
    cin >> n >> a >> b >> c >> d >> e;
    ll ans = 4;
    vector<ll> city = {a,b,c,d,e};
    cout << 4 + (ll)ceil((long double)n/MIN(city));

}


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

#define LEFT 0
#define RIGHT 1

int main()
{
  string s;
  int step,num,cnt;
  while(cin>>s,s!="#"){
    for(int i=0;i<s.size();i++)s[i]-='1';
    cnt=0;
    step=LEFT;
    for(int i=1;i<s.size();i++){
      if( step==RIGHT && (s[i-1]%3 < s[i]%3) ){cnt++;step^=1;}
      else if( step==LEFT && (s[i-1]%3 > s[i]%3) ){cnt++;step^=1;}
      step^=1;
    }
    num=cnt;
    cnt=0;
    step=RIGHT;
    for(int i=1;i<s.size();i++){
      if( step==RIGHT && (s[i-1]%3 < s[i]%3) ){cnt++;step^=1;}
      else if( step==LEFT && (s[i-1]%3 > s[i]%3) ){cnt++;step^=1;}
      step^=1;
    }
    if(cnt<num)num=cnt;
    cout<<num<<endl;
  }
}

Measured memory_bytes: 1140
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int a[100002],b[100002],c[100002];
int dp[100002][4];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d%d",&a[i],&b[i],&c[i]);
	}
	if(n==1){
		printf("%d",max(max(a[1],b[1]),c[1]));
		return 0;
	}
	dp[1][1]=a[1];
	dp[1][2]=b[1];
	dp[1][3]=c[1];
	for(int i=2;i<=n;i++){
		dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a[i];
		dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b[i];
		dp[i][3]=max(dp[i-1][2],dp[i-1][1])+c[i];
	}
	printf("%d",max(max(dp[n][1],dp[n][2]),dp[n][3]));
	return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;

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

		int d = a / b;
		int r = a % b;
		double f = (double) a / b;

		System.out.printf("%d %d %10.10f", d, r, f);
	}
}

Measured memory_bytes: 17252
package main

import "fmt"

func f(x int) int {
	var sum int
	for {
		sum += x % 10
		x /= 10
		if x == 0 {
			break
		}
	}
	return sum
}

func main() {
	var N, A, B, sum int
	fmt.Scan(&N, &A, &B)
	for i := 1; i <= N; i++ {
		t := f(i)
		if A <= t && t <= B {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
n, p = map(int, input().split())
nodes = [x for x in range(n)]
answer = []

def get_root(idx) :
    if idx == nodes[idx] :
        return idx
    else :
        # nodes[idx] = get_root(nodes[idx])
        return get_root(nodes[idx])
        
for i in range(p) :
    q, a, b = map(int, input().split())
    
    # union 
    if q == 0 :
        parent_min = min(get_root(a), get_root(b))
        nodes[get_root(a)] = nodes[get_root(b)] = parent_min
        
    # check
    else :
        if get_root(a) == get_root(b) : answer.append(1)
        else : answer.append(0)
            
for i in answer :
    print(i)


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k,n,sum=0,ma=-1;
	cin>>k>>n;
	vector<int>v(n);
	for(int i=0;i<n;i++) cin>>v.at(i);
	sort(v.begin(),v.end());
	for(int i=0;i<n-1;i++){
		sum+=v.at(i+1)-v.at(i);
		ma=max(v.at(i+1)-v.at(i),ma);
	}
	sum+=min(v.at(n-1)-v.at(0),abs(v.at(n-1)-(v.at(0)+k)));
	ma=max({min(v.at(n-1)-v.at(0),abs(v.at(n-1)-(v.at(0)+k))),ma});
	cout<<sum-ma<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <bitset>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100007
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int A[N], B[N], C[N], R[N][3];

int main() {
    int n, ans;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> A[i] >> B[i] >> C[i];
    }
    R[0][0] = A[0];
    R[0][1] = B[0];
    R[0][2] = C[0];
    for(int i = 1; i < n; i++) {
        R[i][0] = A[i] + max(R[i-1][1], R[i-1][2]);
        R[i][1] = B[i] + max(R[i-1][2], R[i-1][0]);
        R[i][2] = C[i] + max(R[i-1][0], R[i-1][1]);
    }
    ans = max(R[n-1][0], R[n-1][1]);
    ans = max(ans, R[n-1][2]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
{-# LANGUAGE BangPatterns #-}
import Control.Applicative((<$>))
import Control.Monad
import Data.Map ((!))
import qualified Data.Map as M
-- import Data.IntMap ((!))
-- import qualified Data.IntMap as M
import qualified Data.List as L
import Data.Maybe (catMaybes)
-- import qualified Data.Char as C
-- import qualified Data.IntSet as I
import Debug.Trace

--------------------------------------------
readInt    = read :: String -> Int
getInt     = readInt <$> getLine
getIntList = map readInt . words <$> getLine
main :: IO ()
main = do
  a <- getInt
  b <- getInt
  c <- getInt
  d <- getInt
  print $ a `min` b + c `min` d

Measured memory_bytes: 508
import sys

def convert(s):
    x = 0
    if s == "A":
        x = 0
    elif s == "B":
        x = 1
    elif s == "C":
        x = 2
    return x

def main():
    A = [0 for i in range(3)]
    A[0] = 1

    for line in sys.stdin:
        B = line.split(",")
        B[0] = convert(B[0])
        B[1] = B[1].replace("\n", "")
        B[1] = convert(B[1])

        tmp = A[B[0]]
        A[B[0]] = A[B[1]]
        A[B[1]] = tmp
    
    S = ["A", "B", "C"]
    for i in range(3):
        if A[i] == 1:
            print(S[i])


if __name__ == "__main__":
    main()


Measured memory_bytes: 5572
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		String A = "";
		
		for(int i=0;i<n;i++)
			A = A + Integer.toString(sc.nextInt());
		
		int m = sc.nextInt();
		
		String B = "";
		
		for(int i=0;i<m;i++)
			B = B + Integer.toString(sc.nextInt());
		
		int Ans = 0;
		
		if(A.compareTo(B) < 0) Ans = 1;
		
		else Ans = 0;
		
		
		System.out.println(Ans);
	}
}


Measured memory_bytes: 54304
using namespace std;

#include <cstdio>
#include <cstdint>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

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

    long long int X = 0;
    long long int A = 0;
    long long int B = 0;
    cin >> X;

    int i,j = 0;

    for(i = -121; i < 121; i++){
        for(j = -121; j < 121; j++){
            if(i*i*i*i*i- j*j*j*j*j == X){
                A = i;
                B = j;
                break;
            }
        }
    }
    cout << A << " " << B << "\n";
    return 0;
    
}

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

ll ebob(ll a, ll b){
	if(a == 0) return b;
	return ebob(b%a, a);
}
bool prime(int n){
	if(n == 0 || n == 1) return 0;
	if(n == 2 || n == 3) return 1;
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0) return 0;
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int x; cin>>x;
	for(int i = x;;i++){
		if(prime(i)){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * AtCoder Beginner Contest 131<br>
 * A - Security<br>
 * <br>
 * https://atcoder.jp/contests/abc131/tasks/abc131_a<br>
 */
public class Main {

    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            // 標準入力より入力を取得
            String[] input = sc.nextLine().split("");
            // 判定
            Result r = renzokuNum(input);
            // 結果出力
            System.out.println(r.toString());
        }
    }

    /**
     * 番号が連続しているかどうかの判定 
     */
    private static Result renzokuNum(String[] input) {
        for (int i = 0; i < input.length - 1; i++) {
            if (input[i].equals(input[i + 1])) {
                return Result.Bad;
            }
        }
        return Result.Good;
    }

    /**
     * 処理結果 
     */
    enum Result {
        Good("Good"), Bad("Bad"),
        ;

        private String kbn;

        private Result(String kbn) {
            this.kbn = kbn;
        }

        public String toString() {
            return this.kbn;
        }
    }
}

Measured memory_bytes: 21332
def main():
    n = int(input())
    a = input().rstrip()
    b = input().rstrip()
    c = input().rstrip()
    ans = 0
    for i in range(n):
        if a[i] == b[i] == c[i]:
            continue
        elif a[i] == b[i] or b[i] == c[i] or c[i] == a[i]:
            ans += 1
        else:
            ans += 2
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
using ll = long long;



int main() {
	int a, b,c=0;
	cin >> a >> b;
	c = a - 1;
	if (a <= b) c++;
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(void) {
  char R[256], S[108];
  scanf("%s\n", R); scanf("%s\n", S);
  strncat(R, R, strlen(S));
 
  if (strstr(R, S)) 
    printf("Yes\n");
  else              
    printf("No\n");
  return 0;
}


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

int main() {
    int h, w; cin >> h >> w;
    while (h != 0 && w != 0) {
        
        for (int height = 1; height <= h; ++height) {
            string rec = "";
            for (int width = 1; width <= w; ++width) {
              if (1 < height && height < h && 1 < width && width < w) rec += ".";
              else rec += "#";
            }
            cout << rec << endl;
        }
        cout << endl;
        
        cin >> h >> w;
    }
    return 0;
}


Measured memory_bytes: 3184
def main():
    s = input()
    dp = [0, 1]
    for c in s:
        x = int(c)
        a = dp[0] + x
        if a > dp[1] + 10 - x:
            a = dp[1] + 10 - x
        b = dp[0] + x + 1
        if b > dp[1] + 10 - x - 1:
            b = dp[1] + 10 - x - 1
        dp[0] = a
        dp[1] = b
    dp[1] += 1
    print(min(dp))

if __name__ == "__main__":
    main()


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

int main()
{
  string n;
  cin>>n;
  ll ans=0;
  for(int i=0;i<n.size();i++)
    ans+=(n[i]-48);
    if(ans%9==0)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
}

Measured memory_bytes: 3752
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))

left = [0] * n
left[0] = a[0]

right = [0] * n
right[n-1] = a[n-1]

for i in range(1, n-1):
    left[i] = gcd(left[i-1], a[i])

for i in range(n-2, 0, -1):
    right[i] = gcd(right[i+1], a[i])

b = [0] * n
b[0] = right[1]
b[n-1] = left[n-2]

for i in range(1, n-1):
    b[i] = gcd(left[i-1], right[i+1])

print(max(b))

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> vc;
  
  int n = N;
  while(n--){
   	int x;
   	cin >> x;
   	vc.push_back(x);
  }
  
  sort(vc.begin(), vc.end());
  
  int sum = accumulate(vc.begin(), vc.end(), 0);
  
  n = vc[N-M];
  if(4*n*M >= sum){
    cout << "Yes"<< endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
def put_queen(i)
  if i == N
    @row.each do |x|
      N.times do |i|
        print (x == i) ? "Q" : "."
      end
      puts
    end
    return
  end

  unless @input_set_queen.include?(i)
    N.times do |j|
      if @col[j] == NOT_FREE || @dpos[i+j] == NOT_FREE || @dneg[i-j+N-1] == NOT_FREE
        next
      end
      # put a queen at (i, j)
      @row[i] = j
      @col[j] = @dpos[i+j] = @dneg[i-j+N-1] = NOT_FREE
      # try the next row
      put_queen(i+1)
      #remove the queen at (i, j) for backtracking
      @col[j] = @dpos[i+j] = @dneg[i-j+N-1] = FREE
    end
  else
    put_queen(i+1)
  end
end



N = 8
FREE = "O"
NOT_FREE = "X"

@row = Array.new(N)
@col = Array.new(N,FREE)
@dpos = Array.new(N*2-1,FREE)
@dneg = Array.new(N*2-1,FREE)
@input_set_queen = []

gets.to_i.times do
  r, c = gets.split(" ").map{|x| x.to_i}
  @input_set_queen << r
  @row[r] = c
  @col[c] = @dpos[r+c] = @dneg[r-c+N-1] = NOT_FREE
end

put_queen(0)



Measured memory_bytes: 6888
A,B=map(int,input().split())
two=[2**i for i in range(2,41)]

def func(C):
	ret=''
	for t in two[::-1]:
		if (C%t)>=t//2 and (C%t)%2==0:
			ret+='1'
		else:
			ret+='0'
	if (C%4)==1 or (C%4)==2:
		ret+='1'
	else:
		ret+='0'
	return ret
print(int(func(A-1),2)^(int(func(B),2)))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=1;i<4;i++)
	{
		if(a[i]==a[i-1])
		{
			cout<<"Bad";
			return 0;
		}
	}
	cout<<"Good";
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int kai=INF;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            kai=min(kai,i+n/i-2);
        }
    }
    cout<<kai<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; string s;
    cin >> n >> s;
    int now = 0, ans = s.size();
    rep(i, 0, s.size()){
        if(s[i] == 'x'){
            now++;
            if(now == 2){
                ans = i;
                break;
            }
        }else{
            now = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iK = int.Parse(sS[0]);
            int iN = int.Parse(sS[1]);
            List<int> lstPos = new List<int>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++)
            {
                lstPos.Add(int.Parse(sS[i]));                                       // 各位置
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            List<int> lstDef = new List<int>();
            for (int i = 0; i < lstPos.Count - 1; i++)
            {
                lstDef.Add(lstPos[i + 1] - lstPos[i]);                              // 各間隔
            }
            lstDef.Add(lstPos[0] + (iK - lstPos[lstPos.Count - 1]));                // 最初と最後の間隔
            lstDef.Sort();                                                          // 小さい順にソート
            lstDef.RemoveAt(lstPos.Count - 1);                                      // 最大間隔除外
            iOut = lstDef.Sum();                                                    // 残りの合計

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}



Measured memory_bytes: 34932
# -*- coding: utf-8 -*-
# Input
list = [int(a) for a in input().split()]
 
#ソート
list.sort()
 
num = 0
if list[1] > list[0] + 1:
    num = list[1] * 2 - 1
else:
    num = sum(list)
 
print(num)

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

int ans, n;
string s;

bool cek(int k){
	bool isOne = false, isZero = false;
	// printf("Cek %d\n", k);
	for(int i = n-k; i < k; ++i){
		int dist = min(i, n-i-1);
		if(dist >= n-k){
			// printf("Get %d\n", i);
			if(s[i] == '1')
				isOne = true;
			else
				isZero = true;
		}
	}
	return !(isOne & isZero);
}

int main(){
	cin >> s;
	n = s.size();
	int l = 1, r = s.size();
	while(l < r){
		int mid = (l+r)/2+1;
		if(cek(mid))
			l = mid;
		else
			r = mid-1;
	}
	printf("%d\n", l);
}

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

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

    ll n;
    cin >> n;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<ll>> cnt(3, vector<ll>(n, -1));
    ll res = 1;
    const ll mod = 1000000007;
    rep(i, n){
        ll c = 0;
        rep(j, 3){
            if(a[i]==0 && cnt[j][a[i]] == -1) ++c;
            if(a[i]!=0 && (cnt[j][a[i]]==-1 && cnt[j][a[i]-1]==1)) ++c;
        }
        rep(j, 3){
            if(cnt[j][a[i]] == -1){
                cnt[j][a[i]] = 1;
                break;
            }
        }
        res = res*c%mod;
    }

    cout << res << endl;

    return 0;
}

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

vector<ll>divisor(ll n) {
	vector<ll>divisor;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divisor.push_back(i);
			if (i * i != n) divisor.push_back(n / i);
		}
	}
	sort(begin(divisor), end(divisor));
	return divisor;
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll>div = divisor(m);
    ll ans = 0;
    for(int i = 0 ; i < div.size() ; i++){
        if(n * div[i] <= m)ans = div[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline
INF = float("inf")


@nb.njit("i8(i8,i8,i8[:])")
def solve(N, K, h):
    dp = [0] * N
    for i in range(1, N):
        min_cost = INF
        for k in range(1, min(K + 1, i + 1)):
            cost = dp[i - k] + abs(h[i] - h[i - k])
            if cost < min_cost:
                min_cost = cost
        dp[i] = min_cost
    return dp[-1]


def main():
    N, K = map(int, input().split())
    h = np.array(input().split(), dtype=np.int64)

    ans = solve(N, K, h)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 121828
while(True):
    m,f,r=map(int,input().split())
    if(m==-1 and f==-1 and r==-1):
        break
    elif(m==-1 or f==-1):
        print("F")
    elif(m+f>=80):
        print("A")
    elif(m+f>=65):
        print("B")
    elif(m+f>=50 or r>=50):
        print("C")
    elif(m+f>=30):
        print("D")
    else:
        print("F")


Measured memory_bytes: 5592
import java.util.*;
public class Main {

	public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int sum = 0;
	for(int i=1;i<=N;i++){
		int ii = i;
		int iii = 0;
		int sum2 =0;
	for(int j=0;j<5;j++){
		iii = ii % 10;
		sum2+=iii;
		ii = ii / 10;
	}
	if(sum2>=A&&sum2<=B){
		sum+=i;
	}
	}
	System.out.println(sum);
	}
	}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdint>
using namespace std; // 575

const int MAX = 100000;
const int64_t MAX2 = 1099511627776; // 2^40
int main() {
	int N;
	int64_t K, A[MAX];
	cin >> N >> K;
	for (int i = 0;i < N;++ i) cin >> A[i];
	int64_t dp1 = 0, dp2 = 0; // bitDP, dp1は自明にKより小さい取り方、dp2はちょうどKに重なるような取り方
	for (int64_t i = MAX2;i > 0;i >>= 1) {
		int c = 0;
		for (int j = 0;j < N;++ j) if (A[j] & i) ++ c; // cは0を選ぶと増える数
		if (K >= i << 1) dp1 += max(c, N - c) * i; // dp1→dp1
		if (K & i) dp1 = max(dp1, dp2 + c * i); // dp2→dp1
		dp2 += (K & i ? N - c : c) * i; // dp2→dp2
	}
	cout << max(dp1, dp2);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、各bit独立に考えられるのでそうします
まず最初の1bitについて考えれば残りも同様に解けるので、それを考えます
サンプルの1, 6, 3だと1, 0, 1に等しいので、1とxorするより0とxorする方が1個分得です
以下同様に求めれば終了

dpの遷移について
dp1→dp1 : i=Kなら選ぶのは0のみ、それ以外は常に可能
dp1→dp2 : 常に不可能
dp2→dp1 : K&i>0かつ選ぶのは0としてみる
dp2→dp2 : 取るのが一意に定まる
*/

Measured memory_bytes: 1024
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each{|a| add(a)}
  end

  def add(element)
    @data.push(element)
    bottom_up
  end
  alias push add

  # @return Integer
  def peek
    @data[0]
  end

  # @return Integer
  def poll
    if size == 0
      return nil
    elsif size == 1
      return @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      return min
    end
  end
  alias pop poll

  # @return Integer
  def size
    @data.size
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def bottom_up
    idx = size - 1
    while(has_parent?(idx))
      parent_idx = parent_idx(idx)
      if @data[parent_idx] > @data[idx]
        swap(parent_idx, idx)
        idx = parent_idx
      else
        return
      end
    end
  end

  def top_down
    idx = 0
    while (has_child?(idx))
      a = left_child_idx(idx)
      b = right_child_idx(idx)
      if @data[b].nil?
        c = a
      else
        c = @data[a] <= @data[b] ? a : b
      end
      if @data[idx] > @data[c]
        swap(idx, c)
        idx = c
      else
        return
      end
    end
  end


  # @param Integer
  # @return Integer
  def parent_idx(idx)
    (idx - (idx.even? ? 2 : 1)) / 2
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end

  def has_parent?(idx)
    idx > 0
  end
end

def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

n, m = input_a
a = input_a

q = PriorityQueue.new

a.each do |num|
  q.push(-num)
end

m.times do |i|
  max = q.pop
  max = -(-max / 2)
  q.push(max)
end

sum = 0
while q.size != 0
  sum += -q.pop
end
puts sum

Measured memory_bytes: 11932
using System;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var n = nk[0];
            var k = nk[1];
            List<int> d = new List<int>();
            List<int[]> a = new List<int[]>();
            for (int i = 0; i < k; i++)
            {
                d.Add(int.Parse(Console.ReadLine()));
                var aa = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
                a.Add(aa);
            }
            var b = a.SelectMany(s=>s).Distinct().Count();
            int ans = n-b;

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 28496