akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
	char s[200];
	cin >> s;
	int len = strlen(s);
	for (int i = len - 2; i; i -= 2) {
		if (strncmp(s, s + i / 2, i / 2) == 0) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k; cin >> n >> k;
    ll r, s, p; cin >> r >> s >> p;
    string t; cin >> t;
    ll ans = 0LL;
    map<char, ll> m;
    m['r'] = p; m['s'] = r; m['p'] = s;
    rep(i,n){
        if(i < k-1){
            ans += m[t[i]];
        }else{
            if(t[i-k] == t[i]) t[i] = 'o';
            else ans += m[t[i]];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '1') {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}

Measured memory_bytes: 35260
using namespace std;
#define mod 1000000007
#define pb push_back
#define eb emplace_back
#define mp make_pair
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define ll long long int

bool isprime(int x){ 
    for (int i=2; i*i<=x; i++) 
        if (x%i == 0) 
            return false; 
    return true; 
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int k;
    int a,b;
    int flag=0;

    cin >> k;
    cin >> a >> b;

    for(int i=a; i<=b; i++){

        if(i%k==0){
            flag=1;
            break;
        }

    }

    if(flag==0){
        cout << "NG" << endl;
    }else{
        cout << "OK" << endl;
    }

    return 0;
}



Measured memory_bytes: 3132
#include <stdio.h>
#define N 100
#define NIL -1

struct DATA{
  int u;
  int k;
  int v[N];
};

int main(){
  int n,i,j,A[N][N];

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

  struct DATA data[n];

  for(i=0;i<n;i++){
    scanf("%d%d",&data[i].u,&data[i].k);
    if(data[i].k==0) data[i].v[0]=NIL;
    else for(j=0;j<data[i].k;j++) scanf("%d",&data[i].v[j]);
  }

  for(i=0;i<n;i++) for(j=0;j<n;j++) A[i][j]=0;

  for(i=0;i<n;i++){
    for(j=0;j<data[i].k;j++){
      A[i][data[i].v[j]-1]=1;
    }
  }


  for(i=0;i<n;i++){
    printf("%d",A[i][0]);
    for(j=1;j<n;j++){
      printf(" %d",A[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



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

INF = 10**9

dp = [[0, 0] for i in range(N+1)]
dp[0][1] = -INF

for i in range(N):
    dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]-A[i])
    dp[i+1][1] = max(dp[i][0]-A[i], dp[i][1]+A[i])

print(dp[N][0])


Measured memory_bytes: 25572
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<edge>> G(n);
	vector<int> cnt(n + m);
	vector<int> a(n + m - 1), b(n + m - 1);
	for(int i = 0; i < n + m - 1; ++i){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		G[a[i]].push_back(edge(a[i], b[i], i));
		cnt[b[i]]++;
	}
	int root;
	for(int i = 0; i < n; ++i) if(cnt[i] == 0) root = i;
	queue<int> que;
	que.push(root);
	vector<int> ans(n);
	ans[root] = 0;
	while(!que.empty()){
		int r = que.front();
		que.pop();
		for(int i = 0; i < G[r].size(); ++i){
			if(cnt[G[r][i].to] == 1){
				ans[G[r][i].to] = r + 1;
				que.push(G[r][i].to);
			}
			cnt[G[r][i].to]--;
		}
	}
	for(int i = 0; i < n; ++i) cout << ans[i] << endl;
}

Measured memory_bytes: 8180
line = gets.split(' ').map(&:to_i)

A = line[0]
B = line[1]
K = line[2]

if K < A then
  tak = A - K
  aok = B
elsif K < A + B then
  tak = 0
  aok = B - (K - A)
else
  tak = 0
  aok = 0
end
  
print tak.to_s + " " + aok.to_s

Measured memory_bytes: 3836
<?php
$inp = fgets(STDIN);
$H = (int)explode(" ",$inp)[0];
$W = (int)explode(" ",$inp)[1];
$template = "";
$output_grid = [];
$error_position = [];

foreach(range(1,$W) as $num){
    $template .= ".";
}
foreach (range(1,$H) as $num){
    $row = trim(fgets(STDIN),"\n");
    if($row == $template){
        continue;
    }else{
        array_push($output_grid,$row);
        $error_position_per_row = [];
        foreach(str_split($row) as $key=>$letter){
            if($letter == "."){
                array_push($error_position_per_row,$key);
            }
        }
        array_push($error_position,$error_position_per_row);
    }
}
if(count($error_position) > 1){
    $error_position = array_intersect(...$error_position);
}else{
    $error_position = [];
    foreach($output_grid as $row){
        foreach(str_split($row) as $key=>$letter){
            if ($letter == "."){
                array_push($error_position,$key);
            }
        }
    }
}


foreach ($output_grid as $str_row){
    foreach (str_split($str_row) as $str_key=>$letter){
        if(in_array($str_key,$error_position)){
            continue;
        }else{
            echo $letter;
        }
    }
    echo "\n";
}

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  string tmp;
  int64_t ans=0;
  map<string,int>s;
  for(int i=0;i<n;i++){
    cin>>tmp;
    sort(tmp.begin(),tmp.end());
    if(s.count(tmp)){
      ans+=s.at(tmp);
      s.at(tmp)++;
    }
    else s[tmp]=1;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 11452
#include <iostream>

using namespace std;

int main() 
{
    int A, B;
    cin >> A >> B;

    if (A == 1 && B != 1) {
        cout << "Alice" << endl;
    }   
    else if (A != 1 && B == 1) {
        cout << "Bob" << endl;
    }   
    else if (A > B) {
        cout << "Alice" << endl;
    }   
    else if (A < B) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int res;
    if(a==b && b==c){
        res=1;
    }
    if(((a==b)&&(b!=c)) || ((a==c)&&(c!=b)) || ((c==b)&&(b!=a))){
        res=2;
    }
    if(a!=b && b!=c && a!=c){
        res=3;
    }
    cout << res;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

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

    ll x=n/(1.08);
    x++;
    
    if(floor(x*1.08)==n)
    	cout<<x<<endl;
    else 
    {
    	x--;
    	 if(floor(x*1.08)==n)
    	cout<<x<<endl;
    	else
    	{
    		x--;
    	 if(floor(x*1.08)==n)
    	cout<<x<<endl;
    	else
    		cout<<":("<<endl;
    	}
    }

   }

Measured memory_bytes: 256
from collections import Counter
def main():
  n = int(input())
  s = [input() for _ in range(n)]
  s_c = Counter(s)
  s_c_l = [c for c in s_c.items()]
  m = max([c[1] for c in s_c_l])
  s_c_l_max = [c[0] for c in s_c_l if c[1] == m]
  s_c_l_max_s = set(s_c_l_max)
  s_c_l_max_s = sorted(s_c_l_max_s)
  for ch in s_c_l_max_s:
    print(ch)
  
main()

Measured memory_bytes: 121424
#include<string>
#include <iostream>
using namespace std;
int n;
int main(){
	while(true){
		cin >>n;
		
		if(n==0){
			break;
		}
		int num=0;

		for(int k=1;2*n-k*(k+1)>0;k++){
			if((2*n-k*(k+1))%(2*(k+1))==0){
				num++;
			}
		}
		cout << num <<endl;

	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 998244353
#define EPS 1e-10
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

struct Combinations {
    
    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;
    
    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }
    
    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }
    
    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }
    
    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }
    
};
/*
 usage:
 O(N);
 Combination C(N,inf);//Nまでの全てのcombination, %inf;
 C.nCr(a,b); // aCbの値
 C.nPr,  C.nHrなどもある
 */

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


    Combinations C(212345, MOD);
    
    ll N,M,K;
    cin >> N >> M >> K;

    ll ans = 0;
    for(ll i = 0; i <= K; i++){
        // 最初の一つはM通り
        ll ret = M;

        // i個は重複しないといけない(前のと同じ)
        ret *= power(1, i);
        ret %= MOD;

        // (N - 1 - K)個は重複してはならない
        ret *= power(M - 1, N - 1 - i);
        ret %= MOD;

        // これは (N-1)のなか, K個選んで指定色
        ret *= C.nCr(N-1, i);
        ret %= MOD;

        ans += ret;
        ans %= MOD;
    }
    
    cout << ans << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 8144
s = input()
k = int(input())

S = []
for len_i in range(1,k+1):
	for left_j in range(len(s)-len_i+1):
		cur_s = s[left_j:left_j+len_i]
		if cur_s not in S:
			S.append(s[left_j:left_j+len_i])
S.sort()
# print(S)
print(S[k-1])

Measured memory_bytes: 3956
#include <iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    
    if (a>b){
        cout << "a > b" << "\n";
    } else if (a==b){
        cout << "a == b" << "\n";
    } else {
        cout << "a < b" << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 3060
X, N = map(int, input().split())
P = [int(i) for i in input().split()]

check = [0 for i in range(110)]
for i in range(N):
    check[P[i]-1] = 1
    
dx_ls = [1000 for i in range(110)]
ans = []
for i in range(110):
    if check[i] == 0:
        dx_ls[i] = abs(X-(i+1))
            
dx_min = min(dx_ls)
for i in range(110):
    if dx_ls[i] == dx_min:
        ans.append(i+1)
        
ans_plus = min(ans)

if abs(ans_plus-X) >= abs(X - 0):
    print(0)
else:
    print(ans_plus)

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

public class Main {

	private static Scanner scanner;

	public static void main(String[] args) {

		scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();

		while(a < 1 || 10000 < a);
		while(b < 1 || 10000 < b);
		while(c < 1 || 10000 < c);

		int[] list1 = {a,b,c};
		Arrays.sort(list1);
		System.out.println(list1[0]+" "+list1[1]+" "+list1[2]);
}

}



Measured memory_bytes: 26264
N, T = map(int, input().split())
t = list(map(int, input().split()))

X = 0
for i in range(N - 1):
    if t[i + 1] - t[i] >= T:
        X += T
    else:
        X += t[i + 1] - t[i]
X += T
print(X)

Measured memory_bytes: 30824
#include <bits/stdc++.h>                                                                              
using namespace std;                                                                                  
using ll = long long;                                                                                 
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }               
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }               
                                                                                                      
int main() {                                                                                          
  int n;                                                                                              
  cin >> n;                                                                                           
  bool approved = true;                                                                               
  int a;                                                                                              
  for (int i=0; i<n; i++) {                                                                           
    cin >> a;                                                                                         
    if (a%2==0) {                                                                                     
      if (a%3!=0 && a%5!=0) {                                                                         
        approved = false;                                                                             
        break;                                                                                        
      }                                                                                               
    }                                                                                                 
  }                                                                                                   
  if (approved) {                                                                                     
    cout << "APPROVED" << endl;                                                                       
  } else {                                                                                            
    cout << "DENIED" << endl;                                                                         
  }                                                                                                   
  return 0;                                                                                           
}                                                                                                     
                             

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

string s, t;
int main ()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    // I am Khanh Doan
    /*
    p[1] = 1;

    for (i = 2; i <= 5000; i++)
    {
        p[i] = i;
        for (j = 2; j <= i/2; j++)
        if (i % j == 0)
        {
            t = i / j;
            if (p[i] > p[j] + p[t] + 2)
                p[i] = p[j] + p[t] + 2;
        }
    }

    s[1] = 1;

    for (i = 2; i <= 5000; i++)
    {
        s[i] = p[i];
        for (j = 2; j <= i - 1; j++)
        {
            t = i - j;
            if (s[i] > s[j] + p[t] + 2)
                s[i] = s[j] + p[t] + 2;
        }
    }

    while (cin >> n)
        cout << s[n] << "\n";
    */
    /*
    cin >> s;
    cin >> t;
    for(ll i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            cout <<"No";
            return 0;
        }
    }
    cout <<"Yes";
*/
ll kd, a, b, c, j, res, k;
cin >> a >> b >> c >> k;kd = min(a, k);res = 1 * kd;k -= kd;k -= b;
    if(k > 0){
        kd = min(c, k);res = res - kd;
    }cout << res;
}



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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for(int i = 0; i < n ;i++) cout << s[i] << t[i];
    cout << "\n";
}

int main()
{
    solve();
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++ i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define pb push_back

template<typename T> T DUP(T x, T y) { return (x + y - 1) / y; };
template <typename A, size_t N, typename T>
void arrayFill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using setint = unordered_set<int32_t>;
using setstr = unordered_set<string>;
using qint = queue<int32_t>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  for (int i=0; i<H; i++) cin >> S.at(i);
  
  vector<int> dx = {  0, -1,  1,  0 };
  vector<int> dy = { -1,  0,  0,  1 };
  
  
  string res = "Yes";
  for (int y=0; y<H; y++) {
    for (int x=0; x<W; x++) { 
      if( S.at(y).at(x) == '#' ) {
        bool ck = false;
        for (int d=0; d<4; d++) {
          int sx = x + dx.at(d);
          int sy = y + dy.at(d);
          
          if( sx < 0 || W <= sx ) continue;
          if( sy < 0 || H <= sy ) continue;
          if( S.at(sy).at(sx) == '#' ) ck = true;
        }
        if(!ck) res = "No";
      }
    }
  }
  
  cout << res << endl;
  
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }
    static class TaskD {
        static  int[] count;
        static  boolean[] visited;
        static ArrayList<Integer>[] frinds;
        static int[] color ;
        public static void dfs(int v , int val){
            visited[v]=true;
            count[val]++;
            color[v]=val;
            if (frinds[v]!=null)for (int u: frinds[v]) {
                if (!visited[u]) dfs(u , val);
            }
        }
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int arr1[] = new int[n];
            int arr2[] = new int[n];
            arr1[0]=in.nextInt();
            for (int i = 1; i <n; i++) {
                arr1[i]=arr1[i-1]+in.nextInt();
            }
            for (int i = 0; i <n ; i++) {
                arr2[i]=in.nextInt();
            }
            for (int i = n-2; i >=0 ; i--) {
                arr2[i]+=arr2[i+1];
            }
            int ans = 0;
            for (int i = 0; i <n ; i++) {
                ans=Math.max(ans, arr1[i]+arr2[i]);
            }
            System.out.println(ans);





        }
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 21204
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := next()

	s := 0
	for i := range n {
		x := int(n[i] - '0')
		s += x
		s %= 9
	}

	if s == 0 {
		puts("Yes")
	} else {
		puts("No")
	}
}


Measured memory_bytes: 2472
#include<iostream>
#include<string>
using namespace std;
string a;
int main()
{
    cin>>a;
    int n=a.size();
    for(int i=0;i<n;i++)
        if(a[i]=='C')
            for(int j=n-1;j>i;j--)
                if(a[j]=='F')
                {
                    cout<<"Yes\n";
                    return 0;
                }
    cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M;
  cin >> N >> M;
  string s;
  cin >> s;
  vector<int> graph[N * 2];
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b + N);
    graph[b + N].push_back(a);
    if (a != b) {
      graph[b].push_back(a + N);
      graph[a + N].push_back(b);
    }
  }
  auto color = [&](int v) { return (v >= N ? s[v - N] : s[v]) - 'A'; };
  int used[N * 2][2];
  for (int i = 0; i < N * 2; i++) used[i][0] = used[i][1] = 0;
  function<bool(int, int, int)> dfs = [&](int v, int pc, int ts) {
    int clr = color(v);
    for (int u : graph[v]) {
      int uc = color(u);
      if (clr == pc && uc == clr) continue;
      if (pc != -1 && clr != pc && uc != clr) continue;
      if (used[u][clr] == ts) {
        return true;
      }
      if (used[u][clr]) continue;
      used[u][clr] = ts;
      if (dfs(u, clr, ts)) {
        return true;
      }
    }
    if (pc != -1) used[v][pc] = -1;
    return false;
  };
  bool isok = false;
  for (int i = 0; i < N; i++) {
    isok |= dfs(i, -1, i + 1);
  }
  cout << (isok ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 41000
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  int s=9999999;
  for(int i=1;i<=n;i++)
  {
    int m=0,b=0;
    for(int j=1;j<=i;j++)
      m+=a[j];
    for(int j=i+1;j<=n;j++)
      b+=a[j];
    if(fabs(m-b)<=s)
    {
    	s=fabs(m-b);
    }  
  }
  cout<<s;
}

Measured memory_bytes: 256
from itertools import combinations
import numpy as np
n,m,x=map(int, input().split())

S = []
for i in range(n):
    A=list(map(int, input().split()))
    S.append(A)

ans = 10**9
for i in range(1,n+1):
    for comb in combinations(S,i):
        #print(comb)
        tmp = np.array([0]*m)
        
        cost = 0
        for s in comb:
            tmp += np.array(s[1:])
            cost += s[0]
        #print(tmp)
        #print(cost)
        cnt = 0
        for t in tmp:
            if t >= x: cnt+=1
        #print(cnt,m)
        if cnt == m:
            ans = min(ans,cost)
if ans == 10**9:
    print(-1)
else:
    print(ans)
        
        

Measured memory_bytes: 27248
#include<bits/stdc++.h>
using namespace std;
int a[1000005];
int main()
{
    int n,i,j,k,f,p,d;
    cin >> n;
    k=1;
    for(i=1; i<=n; i++)
    {
        cin >> a[i];
        if(i>1 && a[i]==a[i-1])
            k++;
    }
    if(n==1 || k==n)
    {
        cout << "1" << endl;
        return 0;
    }
    for(i=2; i<=n; i++)
    {
        if(a[i]!=a[i-1])
        {
            if(a[i-1]>a[i])
                f=1;
            else
                f=2;
            break;
        }
    }
    p=1;
    d=1;
    for(i=2; i<=n; i++)
    {
        if(a[i-1]>=a[i] && f==1)
        {
            continue;
        }
        else if(a[i-1]<=a[i] && f==2)
        {
            continue;
        }
        else
        {
            if(a[i]==a[i-1])
            {
                continue;
            }
            if(d%2==1)
            {
                f=0;
                p++;
            }
            else
            {
                if(a[i-1]>a[i])
                    f=1;
                else
                    f=2;
            }
            d++;
        }
    }
    cout << p << endl;
    //main();
    return 0;
}


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

int main() {
  int N, ans = 0;
  cin >> N;
  string S;
  cin >> S;
  for (int i = 1; i < N; i++) {
    int cnt = 0;
    for (char c = 'a'; c <= 'z'; c++) {
      bool left = false, right = false;
      for (int j = 0; j < i; j++) {
        if (S[j] == c) left = true;
      }
      for (int j = i; j < N; j++) {
        if (S[j] == c) right = true;
      }
      if (left && right) cnt++;
    }
    if (ans < cnt) ans = cnt;
  }
  cout << ans << endl;
}

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

int main(){
	int a, b;
	cin >> a >> b;

	if(b == 1){
		cout << 0 << endl;
		return 0;
	}

	int sum = a;
	int ans = 1;
	while(sum < b){
		sum += (a-1);
		ans++;
	}
	cout << ans << endl;

	return 0;
}


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

int main()
{
    long n, T;
    cin >> n >> T;
    vector<long> t(n);
    for(int i=0;i<n;i++){cin >> t[i];}
    long ans = T+t[n-1];
    int tmp = T;
    for(int j=1;j<n;j++){
        if(t[j] >= tmp){
            tmp = T + t[j-1];
            if(tmp < t[j]){
                ans -= t[j]-tmp;
                tmp = t[j] + T;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
 
using namespace std;
 
int main()
{
    char str1[3];
    char str2[3];
        
    cin >> str1;
    cin >> str2;
    
    if(str1[0]==str2[2]&&str1[1]==str2[1]&&str1[2]==str2[0]){
        cout <<  "YES" << endl;
    }else{
    	cout << "NO" << endl;
    }
       return 0;
}

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

int main() {
    const int limit = 1e6 + 5;
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> v(limit), primes;
    fill(v.begin(), v.end(), 1);
    // v[1] = 0;
    for (int i = 2; i <= limit; i++) {
        if (!v[i]) continue;
        primes.push_back(i);
        for (int j = 2 * i; j < n; j += i) {
            v[j] = 0;
        }
    }
    vector<int> mark(limit);
    bool pairwise = true;
    for (int x : a) {
        int t = x;
        for (int p : primes) {
            if (p * p > t) break;
            if (t % p == 0) {
                if (mark[p]) {
                    pairwise = false;
                    break;
                }
                mark[p] = 1;
                while (t % p == 0)
                    t /= p;
            }
        }
        if (v[t] && t != 1) {
            if (mark[t])
                pairwise = false;
            mark[t] = 1;
        }
        if (!pairwise)
            break;
    }
    if (pairwise) {
        cout << "pairwise coprime\n";
        return 0;
    }
    int g = a[0];
    for (int x : a) {
        g = __gcd(g, x);
    }
    if (g == 1)
        cout << "setwise coprime\n";
    else
        cout << "not coprime\n";
}


Measured memory_bytes: 15212
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

MOD = 10**9 + 7


def main():
	# ans_ = []
	# ans_.append(ans)
	# print(("\n").join(map(str, ans_)))
	n = int(input()); arr = read()
	s = 0
	for i in range(1, n):
		s += max(0, arr[i-1]-arr[i])
		arr[i] += max(0, arr[i-1]-arr[i])

	print(s)






if __name__ == "__main__":
	main()

Measured memory_bytes: 94184
#include"iostream"
#include"algorithm"
#include"numeric"
using namespace std;

long long gcd(long a,long b)
{
	long long tmp,r;
	if (a < b)
	{
		tmp = a;
		a = b;
		b = tmp;
	}
	r = a % b;
	while (r != 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main()
{
	long long n, x;
	cin >> n >> x;
	long long a[100100], b[100100];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[i] = abs(a[i] - x);
	}
	b[0] = a[0];
	for (int i = 1; i < n; i++)b[i] = gcd(b[i - 1], a[i]);
	cout << b[n - 1] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
    ll i,j;
    ll n;
    cin>>n;
    ll a[n+1];
    ll b[n+1];
    vector<ll> v;
    ll ans=0;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=n;i>=1;i--){
        ll temp=0;
        for(j=2;i*j<=n;j++){
            temp+=b[i*j];
        }
        if((temp%2)!=a[i]) {
            b[i]=1;
            v.pb(i);
        }
        else b[i]=0;
    }

    cout<<v.size()<<endl;
    if(v.size()>0){
        cout<<v[0];
        for(i=1;i<v.size();i++) cout<<" "<<v[i];
    }
    cout<<endl;

    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;

int64 N, H, W, R, C;

int main(void){
	cin >> N >> W;
	Row dp = Row(W+1, 0);
	vector<int64> w(N), v(N);
	REP(i, N) cin >> w[i] >> v[i];
	REP(i, N){
		Row dp2 = dp;
		REP(j, W+1){
			if(j+w[i] <= W){
				chmax(dp2[j+w[i]], dp[j]+v[i]);
			}
		}
		swap(dp, dp2);
	}
	cout << *max_element(all(dp)) << endl;
}


Measured memory_bytes: 1804
MOD = 1_000_000_007
io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i)
ans=0
60.times do |i|
  bitcnt=a.count do |aa|
    aa[i]==1
  end
  ans+=bitcnt*(n-bitcnt)*(1<<i)
end
p ans % MOD


Measured memory_bytes: 36868
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    if(a+b<c+d){
        cout<<"Right"<<endl;
    }
    else if(a+b>c+d){
        cout<<"Left"<<endl;
    }
    else{
        cout<<"Balanced"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

#define EPS (1e-10)
#define equals(a,b) (fabs(a)-fabs(b)<EPS)

using namespace std;

class Point{
public:
    double x,y;

    Point(double x=0,double y=0):x(x),y(y){}

    Point operator + (Point &p) { return Point(x+p.x,y+p.y); }
    Point operator - (Point &p) { return Point(x-p.x,y-p.y); }
    Point operator * (double a) { return Point(x*a,y*a); }
    Point operator / (double a) { return Point(x/a,y/a); }

    double abs() { return sqrt(norm()); }
    double norm() { return x*x+y*y; }

    bool operator < (const Point &p) const {
        return x!=p.x?x<p.x:y<p.y;
    }

    bool operator == (const Point &p) const {
        return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
    }
};

typedef Point Vector;

///Program 16.3 表示线段的结构体
struct Segment{
    Point p1,p2;
};

///Program 16.4 表示直线的结构体
typedef Segment Line;

///内积
double dot(Vector a,Vector b){
    return a.x*b.x+a.y*b.y;
}
///外积
double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

int ccw(Point p0,Point p1,Point p2){
    Vector a=p1-p0;
    Vector b=p2-p0;
    if(cross(a,b)>EPS)  {//printf("COUNTER_CLOCKWISE\n");
            return 1;}///p2位于p0-->p1的逆时针方向
    if(cross(a,b)<-EPS) {//printf("CLOCKWISE\n");
        return -1;}///p2位于p0-->p1的顺时针方向
    if(dot(a,b)<-EPS)   {//printf("ONLINE_BACK\n");
        return 2;}///p2位于线段p0p1后方
    if(a.norm()<b.norm())  { //printf("ONLINE_FRONT\n");
        return -2;}///p2位于线段p0p1前方

  //  printf("ON_SEGMENT\n");///p2位于线段p0p1的中间
    return 0;
}

bool intersect(Point p1,Point p2,Point p3,Point p4){
    return (ccw(p1,p2,p3) * ccw(p1,p2,p4) <= 0&&
            ccw(p3,p4,p1) * ccw(p3,p4,p2) <= 0);
}

bool intersect(Segment s1,Segment s2){
    return intersect(s1.p1,s1.p2,s2.p1,s2.p2);
}

int main()
{
    Point p0,p1,p2,p3;
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;i++){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p0.x,&p0.y,&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y);
        printf("%d\n",intersect(p0,p1,p2,p3));
    }
    return 0;
}


Measured memory_bytes: 3244
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;if(n<0)pcu('-'),n*=-1;
	if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10; while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

template <typename T>
using V = vector<T>;

struct node {
	int n, w;
	bool operator < (const node &a) const { return w > a.w; }
};

struct graph {
	V<V<node>> nodes;

	int prim() {
		int w = 0;
		V<bool> v(nodes.size());
		priority_queue<node> q;
		q.push({0, 0});
		while (!q.empty()) {
			node n = q.top();
			q.pop();
			if (v[n.n])
				continue;
			w += n.w;
			v[n.n] = true;
			for (node &i: nodes[n.n])
				q.push(i);
		}
		return w;
	}
};

int main() {
	for (int n; (n = in());) {
		graph g;
		g.nodes.resize(n);
		for (int m = in(); m; m--) {
			int a = in(), b = in(), d = in();
			g.nodes[a].push_back({b, d});
			g.nodes[b].push_back({a, d});
		}
		outl(g.prim() / 100 - n + 1);
	}
}


Measured memory_bytes: 2680
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

using namespace std;

int main(void)
{
    long long X;
    cin >> X;
    long long money = 100, count = 0;
    while (true)
    {
        count++;
        money += 0.01 * money;
        if (money >= X)
            break;
    }
    cout << count << "\n";
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

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

int main(){
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        sum += x;
    }

    cout << sum - n << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

const int MAX_N = 300000;

vector<int> prime;
bool isPrime[MAX_N + 1];

void sieve(int n){
    rep(i, 0, n + 1){
        if((i % 7 == 1)||(i % 7 == 6)) isPrime[i] = true;
        else isPrime[i] = false;
    }
    isPrime[1] = false;
    rep(i, 6, n + 1){
        if(isPrime[i]){
            prime. push_back(i);
            for(int j = 2*i; j <= n; j += i) isPrime[j] = false;
        }
    }
}


signed main(){
    int n;
    sieve(300000);
    while(1){
        cin >> n;
        if(n == 1) break;
        vector<int> ans;
        rep(i, 0, prime.size()){
            if(n % prime[i] == 0){
                ans. push_back(prime[i]);
            }
            if(n < prime[i]) break; 
        }
        cout << n <<":";
        rep(i, 0 ,ans.size()){
            cout << " " << ans[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1884
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
counter = np.append(0, np.bincount(A, minlength=10**5 + 10))
# print(counter)
cumsum = counter.cumsum()
# print(cumsum)
# print((cumsum[3:] - cumsum[:-3]))
print((cumsum[3:] - cumsum[:-3]).max())


Measured memory_bytes: 23380
// AOJ 0227: Thanksgiving
// 2017.8.6 bal4u@uu
// 2017.10.29 retry

#include <stdio.h>
#include <stdlib.h>

int p[1002];

char buf[6105], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(int *a, int *b) { return *b - *a; }

int main()
{
	int n, m, i, ans;

	while (fgets(bp=buf, 32, stdin) && *buf != '0') {
		n = getint(), bp++, m = getint();
		fgets(bp=buf, 6100, stdin);
		for (i = 0; i < n; i++) p[i] = getint(), bp++;
		qsort(p, n, sizeof(int), cmp);

		for (ans = 0, i = 1; i <= n; i++) if (i % m) ans += p[i-1];
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1808
import java.util.*;

public class Main {
    public static void main(String[] args){
        
        Scanner scanner = new Scanner(System.in);
        int A[][] = new int[3][3];
        boolean hantei = false;
        
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
               
               A[i][j] = scanner.nextInt(); 
                
            }
        }
        
        int N = scanner.nextInt();
        int B[] = new int[N];
        
        for(int i=0; i<N; i++){
            
            B[i] = scanner.nextInt();
            
            for(int j=0; j<3; j++){
                for(int k=0; k<3; k++){
                    if(A[j][k]==B[i]){
                        
                        A[j][k] = 0;   
                        
                    }
                }
            }    
            
        }
        
        for(int i=0; i<3; i++){
            if(A[i][0]==A[i][1] && A[i][0]==A[i][2]){
                hantei = true;
            }
        }
        
        for(int i=0; i<3; i++){
            if(A[0][i]==A[1][i] && A[0][i]==A[2][i]){
                hantei = true;
            }
        }
        
        if((A[0][0]==A[1][1] && A[0][0]==A[2][2]) ||(A[0][2]==A[1][1] && A[0][2]==A[2][0]) ){
            hantei = true;
        }
        
        if(hantei){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 21972
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
ind=bisect.bisect_left(a,0)


if ind==0 :
  print(sum(a))
  
elif ind==n:
  if ind%2==1:
    print(-sum(a)+2*a[-1])
  else:
    print(abs(sum(a)))

elif ind%2==0:

  print(-sum(a[:ind])+sum(a[ind:]))
else:
  print(-sum(a[:ind])+sum(a[ind:])-2*min(abs(a[ind]),abs(a[ind-1])))

Measured memory_bytes: 14500
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll 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;
    }
}

// 二項係数計算
ll 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;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3132
import Control.Applicative

main :: IO ()
main = do
  [a,op,b] <- words <$> getLine
  print $ solve2 a op b

solve2 :: String -> String -> String -> Int
solve2 a op b
  | op == "+" = (read a :: Int) + (read b :: Int)
  | op == "-" = (read a :: Int) - (read b :: Int)

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

int a, b, c, d, e, k;

int main() {
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = list(input())
allnum = 0
foreign = 0

for i in S:
    if i == 'a' and allnum < (A+B):
        allnum += 1
        print("Yes")
    elif i == 'b' and allnum < (A+B) and foreign < B:
        allnum += 1
        foreign += 1
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 4736
n, k = map(int, input().split())
dak = []
for _ in range(k):
    temp = [int(input())]
    temp.append(list(map(int, input().split())))
    dak.append(temp)
snack = [0]*n
for da in dak:
    for i in da[1]:
        snack[i-1] = 1
print(snack.count(0))


Measured memory_bytes: 9212
import fractions

n = int(input())
a = list(map(int,input().split()))
b = a[:]

for i in range(1,n):
    a[i] = fractions.gcd(a[i],a[i-1])
    b[n-i-1] = fractions.gcd(b[n-i-1],b[n-i])
a = [0]+a #左に0を追加
b = b+[0] #右に0を追加
print(max(fractions.gcd(a[i],b[i+1]) for i in range(n)))

Measured memory_bytes: 16152
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
	int n, k, a, i, x, ans = -1, s;
	cin >> n >> k;
	for (i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			s = i;
	}
	for (int j = 0; j < k; j++) {
		x = s + k - 1 - j;
		for (i = 1; x < n - 1; i++) 
			x += k - 1;
		x = s - j;
		for (; x > 0; i++)
			x -= k - 1;
		if (ans > i || ans == -1)
			ans = i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256