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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	string s; cin >> s;
	int ans = 1000000;
	set<char> al;
	for(int i = 0; i < s.size(); i++) al.insert(s[i]);
	if(al.size() == 1) {
		cout << 0 << endl;
		return 0;
	}
	for(auto i = al.begin(); i != al.end(); i++) {
		int cnt = 0; string t = s;
		while(true){
			for(int j = 1; j < t.size(); j++) {
				if(t[j] == *i) t[j - 1] = *i;
			}
			t.pop_back();
			cnt++;
			bool flag = true;
			for(int j = 0; j < t.size(); j++){
				if(t[j] != *i) flag = false;
			}
			if(flag){
		 	 ans = min(ans, cnt);
		 	 break;
			}
			
		}
	}
	cout << ans << endl;
	return 0;	
}
  

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

int main(){
  string S;
  vector<string> weekdays = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> S;
  for(int i=0;i<7;i++){
    //cout << weekdays[i] << endl;
    if(weekdays[i] == S) cout << 7-i << endl;
  }
  return 0;
}

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

int main(){
  string S, C;
  int Q, T, F;
  cin >> S >> Q;
  bool rev = false;
  string fr = "", ba = "";
  rep(i, Q){
    cin >> T;
    if(T == 1){
      swap(ba, fr);
      rev = !rev;
    }
    else{
      cin >> F >> C;
      if(F == 1){
        fr += C ;
      }
      else{
        ba += C ;
      }
    }
  }
  if(rev)reverse(S.begin(),S.end());
  reverse(fr.begin(),fr.end());
  cout << fr << S  << ba << endl;

}


Measured memory_bytes: 1088
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long price = sc.nextLong();
        long happy = 0;
        
        happy += price / 500 * 1000;
        price = price % 500;
        happy += price / 5 * 5;
        System.out.println(happy);
    }
}

Measured memory_bytes: 35828
import itertools,numpy as np,sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
sum_A = sum(A)
accumulate_A = np.array(list(itertools.accumulate(A)))
sub_A1 = sum_A-accumulate_A
sub_A2 = sum_A-sub_A1
print(np.abs(sub_A1-sub_A2).min())


Measured memory_bytes: 34220
MODE = "stdio"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '500
  0 933 743 262 529 700 508 752 256 256 119 711 351 843 705 108 393 330 366 169 932 917 847 972 868 980 223 549 592 164 169 551 427 190 624 635 920 944 310 862 484 363 301 710 236 876 431 929 397 675 491 190 344 134 425 629 30 727 126 743 334 104 760 749 620 256 932 572 613 490 509 119 405 695 49 327 719 497 824 596 649 356 184 93 245 7 306 509 754 352 665 783 738 801 690 330 337 195 656 963 11 427 42 106 968 212 1 510 480 658 571 331 814 847 564 197 625 438 931 18 487 151 187 913 179 995 750 750 913 562 134 273 547 521 830 140 557 678 726 503 597 408 893 988 238 85 93 188 720 211 746 387 710 209 887 668 103 473 900 674 105 183 952 370 787 302 410 905 110 400 996 142 585 860 47 924 731 158 386 219 400 415 55 682 874 61 6 602 268 365 470 518 723 89 106 319 130 655 732 993 974 595 810 673 55 730 95 245 705 694 948 873 353 474 760 741 756 644 143 640 737 679 135 149 529 210 607 417 255 787 373 626 445 112 172 595 153 53 183 717 655 17 176 77 776 399 654 728 2 161 455 870 316 694 381 930 480 604 386 359 207 954 79 702 365 453 732 836 432 563 17 107 583 910 467 116 546 719 528 71 107 256 520 353 528 154 430 477 48 520 204 414 810 719 925 298 131 701 709 751 22 817 652 924 695 471 153 625 978 616 142 597 88 732 917 404 743 395 749 407 936 302 767 45 563 340 398 896 51 807 767 997 978 650 809 330 360 716 161 293 209 753 98 130 634 543 889 88 31 692 401 674 294 693 165 949 765 737 458 841 48 943 229 215 389 209 388 754 243 501 271 516 564 277 912 5 611 212 782 92 123 201 324 4 437 602 804 363 391 273 575 906 759 626 896 859 763 358 577 484 747 156 948 605 454 194 359 430 323 883 24 447 202 847 876 49 792 588 304 133 558 842 414 567 728 506 391 0 992 118 398 718 868 975 579 119 363 596 379 916 466 840 232 430 414 155 571 311 179 796 300 216 903 993 55 728 481 905 29 37 897 286 657 377 682 554 506 757 529 580 641 866 852 933 660 490 616 732 606 114 185 647 227 435 58 183 110 742 374 604 671 872 605 480 671 979 717 481 680 791
  30
  0 9 18 30 31 42 48 49 59 74 85 115 121 153 165 168 181 195 205 207 220 228 248 252 255 270 274 289 291 300
  '.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n = line[0].to_i
arr1 = line[1].split.map(&:to_i)
m = line[2].to_i
arr2 = line[3].split.map(&:to_i)


puts (arr1&arr2).size

Measured memory_bytes: 20608
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

const ll MOD = 1e9 + 7;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }

ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128

ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}



void __sol(){
    ll n; cin >> n;
    cout << add(add( power(10,n) , mul( -2LL , power(9,n) )) , power(8,n));
    return;
}


int main(){
    fastio
    ll tc=1;// cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 3664
n,k=map(int, input().split())
r,s,p=map(int,input().split())
T=input()
score=0
A=[]
for i in range(k):#1-k回目
    if T[i]=='r':
        score+=p
        A.append('p')
    if T[i]=='s':
        score+=r
        A.append('r')
    if T[i]=='p':
        score+=s
        A.append('s')
for i in range(k,n):#k,k+1,...n-1回までの合計n-k回
    if T[i]=='r':
        if A[i-k]!='p':
            score+=p
            A.append('p')
        else:
            A.append('o')
    if T[i]=='s':
        if A[i-k]!='r':
            score+=r
            A.append('r')
        else:
            A.append('o')
    if T[i]=='p':
        if A[i-k]!='s':
            score+=s
            A.append('s')
        else:
            A.append('o')
print(score)

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

int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<int> q;
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		q.push(a);
	}
	for (int i = 0; i < m; i++) {
		int a = q.top();
		q.pop();
		q.push(a / 2);
	}
	long x = 0;
	for (int i = 0; i < n; i++)
		x += q.top(), q.pop();
	cout << x << endl;
	return 0;
}


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

using  namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v;

    for(int i=0;i<n-1;i++){
        int in;
        cin>>in;
        v.push_back(in);
    }
    v.push_back(1000000);
    int summ =0;

    for(int i=n-1;i>=1;i--){
        summ=summ+min(v[i],v[i-1]);
        
    }
    summ=summ+v[0];

    cout << summ<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


int a[200000];
signed main(){
  int n, k;
  scanf("%lld%lld", &n, &k);
  rep(i,n)scanf("%lld", &a[i]);
  sort(a, a+n);
  int ans = inf;
  rep(i,n-k+1){
    ans = min(ans, a[i+k-1]-a[i]);
  }
  // PRINTF(a, n);
  printf("%lld\n", ans);
  return 0;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

map<ll, ll> factorize(ll N)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; i++)
    {
        if (N % i != 0)
            continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % i == 0)
        {
            ++ex;
            N /= i;
        }

        res[i] = ex;
    }

    // 最後に残った数
    if (N != 1)
        res[N] = 1;
    return res;
}

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

    auto devA = factorize(A);
    auto devB = factorize(B);

    ll ans = 0;
    for (auto f : devA)
    {
        if (devB.count(f.first))
        {
            ans++;
        }
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int x=9999,y=0;
	int flag=0;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C'&&flag==0) 
		{
			flag=1;
			x=i;
		}
		if(a[i]=='F') y=i;
	}
	if(x<y) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int A = Integer.parseInt(st.nextToken());
         int B = Integer.parseInt(st.nextToken());
         int C = Integer.parseInt(st.nextToken());
         int D = Integer.parseInt(st.nextToken());
         ArrayList<Integer> ls = new ArrayList<Integer>();
         ls.add(A);
         ls.add(B);
         if(A <= 1 && B >= 1)
            ls.add(1);
         if(A <= -1 && B >= -1)
            ls.add(-1);
         ArrayList<Integer> ls2 = new ArrayList<Integer>();
         ls2.add(C);
         ls2.add(D);
         if(C <= 1 && D >= 1)
            ls2.add(1);
         if(C <= -1 && D >= -1)
            ls2.add(-1);
         long res = Long.MIN_VALUE;
         if(A <= 0 && B >= 0 || C <= 0 && D >= 0)
            res = 0L;
         for(int a=0; a < ls.size(); a++)
         {
            long temp = ls.get(a);
            for(int b=0; b < ls2.size(); b++)
               res = Math.max(res, temp*ls2.get(b));
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 32592
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

typedef struct _cross {
  int h, p, q;
} cross;

class GreaterCross {
public:
  bool operator()(const cross& left, const cross& right) const {
    return left.h > right.h;
  }
};

int main(void) {
  int n, m, a;
  while (cin >> n >> m >> a, n||m||a) {
    vector<int> nums(n);
    for (int i = 0; i < n; i++) nums[i] = i+1;
    vector<cross> amida(m);
    for (int i = 0; i < m; i++) {
      cin >> amida[i].h >> amida[i].p >> amida[i].q;
    }
    sort(amida.begin(), amida.end(), GreaterCross());

    for (int i = 0; i < m; i++) {
      swap(nums[amida[i].p-1], nums[amida[i].q-1]);
    }

    auto iter = find(nums.begin(), nums.end(), a);

    cout << distance(nums.begin(), iter)+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x1,x2,x3,x4,x5;cin>>x1>>x2>>x3>>x4>>x5;
  if(x1 == 0)cout<<1<<endl;
  else if(x2 == 0)cout<<2<<endl;
  else if(x3 == 0)cout<<3<<endl;
  else if(x4 == 0)cout<<4<<endl;
  else cout<<5<<endl;
}

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

int main(){
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for(int i = 0; i < N; i++){
     if((ans * 2) < (ans + K)) ans *= 2;
     else ans += K;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3148
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int n, W, a, b;
vector<int> v;
vector<int> w;
 
int memo[101][10001];
int fun(int i, int sw){
    int temp;
    if(memo[i][sw] >= 0) return memo[i][sw];
    if(i == n){
        temp = 0;
    }else if(w[i]>sw) {
        temp = fun(i+1, sw);
    }else{
        temp = max(fun(i+1, sw), fun(i+1, sw-w[i])+v[i]);
    }
    return memo[i][sw] = temp;
}
     
 
int main(){
    cin >> n >> W;
    for(int i=0; i<n; ++i){
        cin >> a >> b;
        w.push_back(b); v.push_back(a);
    }
    for(int i=0; i<n+1; ++i){
        for(int j=0; j<W+1; ++j){
            memo[i][j] = -1;
        }
    }
    cout << fun(0, W) << endl;
    return 0;
}


Measured memory_bytes: 7124
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

string answer(string t, int a, int b[]){
	string r="";
	char station[53];
	for(int i=0; i<26; ++i) station[i]='a'+i;
	for(int i=26; i<53; ++i) station[i]='A'+(i-26);
	
	for(int i=0; i<t.size(); ++i){
		if('a'<=t[i])	 r+=station[ (t[i]-'a'-b[i%a]+52)%52 ]; //小文字の時
		else r+=station[ (t[i]-'A'+26-b[i%a]+52)%52 ]; //大文字の時	
	}
	return r;	
}

int main(){
	while(1){
		int n, k[100];
		string s;
		
		//入力
		scanf(" %d", &n);
		if(n==0) break;
		for(int i=0; i<n; ++i) scanf(" %d", &k[i]);
		cin >> s;
		
		cout << answer(s, n, k) << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
const int MAXN=300;
int n;
char c[MAXN];
int main () {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (int i=1;i<=n;i++) {printf("x");}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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);

    int n, a, b;
    cin >> n >> a >> b;

    int one = 0;
    int two = 0;
    int three = 0;

    rep(i, n){
        int p;
        cin >> p;

        if(p <= a) ++one;
        if(a<p && p<=b) ++two;
        if(b < p) ++three;
    }

    cout << min(one, min(two, three)) << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
lst = ["dreamer", "dream", "eraser", "erase"]
lst = [ "".join(list(reversed(k))) for k in lst]
S = "".join(list(reversed(S)))

i  = 0
while i < len(S):
    found = False
    for k in lst:
        try:
            if S[i:].index(k) == 0:
                found = True
                i += len(k)
                break
        except:
            continue

    if not found:
        print("NO")
        exit(0)
print("YES")


Measured memory_bytes: 3956
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;
 
int main(void){
  int h,w;
  cin>>h>>w;
  string s;
  for(int i=1;i<=h;i++){
    char c='A';
    for(int j=1;j<=w;j++){
      cin>>s;
      if(s=="snuke"){
        cout<<c<<i<<endl;
      }
      c++;
    }
  }
  return 0;
}

Measured memory_bytes: 256
import sys
import collections
input = sys.stdin.readline

n, m = map(int, input().split())
h = list(map(int, input().split()))
g = collections.defaultdict(list)
good = [True] * n
for i in range(m):
	a, b = map(int, input().split())
	a -= 1
	b -= 1
	g[a].append(b)
	g[b].append(a)
for i in range(n):
	found = False
	for j in g[i]:
		if h[j] >= h[i]:
			found = True
			break
	if found:
		good[i] = False
res = sum(good)
print(res)

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



int main(){
    ll N,K;
    string S,T;
    cin >> S >> T ;
    ll ans = 0;

    for(int i = 0; i < S.size(); i++){
        if(S[i] != T[i]){
            ans++;
        }
    }
    cout << ans << endl;

}


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

int main(){
    int n,k,s,i;
    scanf("%d%d%d",&n,&k,&s);
    for(i=0;i<k;i++)
        printf("%d ",s);
    for(;i<n;i++)
    {
        if(s==1)
            printf("2 ");
        else
            printf("%d ",s-1);
    }
}


Measured memory_bytes: 1280
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    
    
    else:
        for i in range(H):
            for j in range(W):
                if (i+j)%2==0:
                    print("#",end="")
                else:
                    print(".",end="")
               
            print()
        print()
                
      



Measured memory_bytes: 7004
#AGC023 A: [1]任意の部分和は先頭からの長さの違う2つの部分和の差をとると構成できる[2]かっこいいコードを書くと逆に計算が遅くなることがある
#AGC025 A: 文字列をlist()に入れると1文字ずつ格納できる
#ABC113 B: NumPyの絶対値はnp.abs()


#AGC017 A
'''
問題
i番目の袋にビスケットがAi個入っている
i=1,2,...,N
0個以上の袋をえらび袋の中のビスケットをすべて食べる
食べるビスケットの総数を2で割った余りがPになるような袋の選び方は?
ただしNは1以上50以下

考察
Aiのうち偶数がa個で奇数がN-a個あったとすると
偶数のものは何個えらんでもよい: 2**a通り
奇数のものは2で割った余りがPになるように選べばよい
N-aが奇数のときP=0,1両方に対して2**(N-a-1)通り
N-aが偶数のときもパスカルの三角形を考えるとP=0,1両方に対して2**(N-a-1)通り
よって...
N-a=0のときはP=1なら答えは0
N-a=0のときはP=0なら答えは2**N
N-a>0のときはPによらず答えは2**(N-1)
'''

N,P = map(int,input().split(' '))
odds = [int(x)%2 for x in input().split(' ')].count(1)

if odds > 0:
	print(str(int(2**(N-1))))
elif P == 1:
	print('0')
elif P == 0:
	print(str(int(2**(N))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    vector<vector<ll>> A(N,vector<ll>(N));
    ll ans=0;
    rep(i,N){
        rep(j,N){
            cin >> A[i][j];
            if (j>i){
                ans+=A[i][j];
            }
        }
    }
    bool can=false;
    rep(i,N){
        for (int j=i+1;j<N;j++){
            bool checked=true;
            rep(k,N){
                if (k!=i&&k!=j&&A[i][j]==A[i][k]+A[k][j]&&checked){
                    ans-=A[i][j];
                    checked=false;
                }
                if (A[i][j]>A[i][k]+A[k][j]){
                    ans=-1;
                    can=true;                    
                }
            }
            if (can){
                break;
            }
        }
        if (can){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    string s;
    int k;
    cin >> s >> k;

    REP(i, s.size() - 1)
    {
        if (s[i] == 'a')
            continue;

        int d = 'z' - s[i] + 1;

        if (d > k)
            continue;

        s[i] = 'a';
        k -= d;
    }

    s[s.size() - 1] = char('a' + (s[s.size() - 1] - 'a' + k) % 26);

    cout << s << endl;

    return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {

            var str = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            if (str[0] < str[1])
            {
                Console.WriteLine(str[1] * 2 - 1);
            }
            else if(str[0] == str[1])
            {
                Console.WriteLine(str[1] * 2);
            }

            else
            {
                Console.WriteLine(str[0] * 2 - 1);
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> g;
	g.resize(N + 1);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	vector<int> v;
	for (int i = 1; i <= N; i++)
		v.push_back(i);

	int ans = 0;
	do {
		if (v[0] == 1) {
			bool canGo = true;
			for (int i = 0; i < v.size() - 1; i++) {
				if (find(g[v[i]].begin(), g[v[i]].end(), v[i + 1]) == g[v[i]].end())
					canGo = false;
			}
			if (canGo)
				ans++;
		}
	} while (next_permutation(v.begin(), v.end()));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>

using namespace std;
 
int cnt;
string l,r;
 
void check(){
    int x = atoi(l.c_str()) ,y = atoi(r.c_str());
    if(l.size() > r.size() || x > y || l[0] == '0' || r[0] == '0') return;  
    if((x + y) % 2 == 0 || (x - y) % 2 == 0) cnt++;
}
 
int main(){
    string a;
 
    cin >> a;
    int size = a.size();
    int z = atoi(a.c_str());
 
    if(z % 2 == 0) cnt++;
 
    for(int i = 1 ; i < size ; i++){
	l = a.substr(0,i);
	r = a.substr(i);
	check();
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3172
N,A,B = map(int,input().split())
cnt = N % (A+B)
if cnt == 0:
    print(N // (A+B) * A)
    exit()
else:
    if cnt - A >= 0:
        print(N // (A+B) * A + A)
        exit()
    else:
        print(N // (A+B) * A + cnt)
        exit()

Measured memory_bytes: 3188
require 'prime'
# n = gets.chomp.to_i
a, b = gets.chomp.split().map(&:to_i)

a_prime = a.prime_division.map{|x,y| x}
b_prime = b.prime_division.map{|x,y| x}
nums = a_prime & b_prime

puts nums.size + 1

Measured memory_bytes: 2172
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let s = iter.next().unwrap();
    println!("{}", if s <= "2019/04/30" { "Heisei" } else { "TBD" } );
}


Measured memory_bytes: 4352
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        xu: [(f64, String); n],
    }
    let mut ans = 0.0;
    for &(x, ref u) in xu.iter() {
        if u == &"JPY".to_string() {
            ans += x;
        } else {
            ans += x * 380000.0
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto A = readln.split.map!(to!long).array;

    auto B = new real[](N+1);
    B[] = 0;
    foreach (i; 0..N) B[i+1] = B[i] + (A[i] + 1) / 2.0L;
    real ans = 0;

    foreach (i; 0..N-K+1) {
        auto v = B[i+K] - B[i];
        ans = max(ans, v);
    }

    writefln("%.15f", ans);

}


Measured memory_bytes: 16040
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int N;
    int a[25], b[25], c[25];

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        a[i]--;
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
    }
    for(int i = 0; i < N-1; i++){
        cin >> c[i];
    }

    int res = 0;
    for(int i = 0; i < N; i++){
        res += b[a[i]];
        if(i < N-1 && a[i+1] - a[i] == 1){
            res += c[a[i]];
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
typedef long long ll;
//プロトタイプ宣言
int gcd(int , int);


int main(){
  int a,b;
  cin >> a >> b;
  a--;
  b--;
  cout << ((b%a == 0) ? b/a : b/a + 1) << endl;
}








































//以下、ライブラリ
//ユークリッドの互除法

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}



Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    a = LI()

    ac = [0]
    ap = [0]
    for x in a:
        ac.append(ac[-1]+x)
        ap.append(ap[-1]+(x if x>0 else 0))

    ans = -INF
    for i in range(N-K+1):
        bw = max(ac[i+K] - ac[i],0)
        l = ap[i]
        r = ap[N] - ap[i+K]
        ans = max(ans,bw+l+r)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 74324
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int ai[105],bi[105];
int main()
{
    int a,b,c;
    cin>>ai[0]>>ai[1]>>ai[2];
    int sum = 10000000;
    for(int i=0;i<3;i++)
    {
        int min1 = abs(ai[i] - ai[0]) + abs(ai[i] - ai[1]) + abs(ai[i] - ai[2]);
        sum = min(sum,min1);
    }
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
vector<pair<int,int>> v;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int sx, sy, tx, ty, n, x, y;
    cin >> sx >> sy >> tx >> ty >> n;
    for(int i=0; i<n; i++){
        cin >> x >> y;
        if( min(sx,tx) <= x && max(sx,tx) >= x && min(sy,ty) <= y && max(sy,ty) >= y )
            v.push_back({x,y});
    }
    if( sx < tx && sy < ty || tx < sx && ty < sy ) sort(v.begin(),v.end());
    else sort(v.rbegin(),v.rend());
    vector<int> u;
    for(int i=0; i<v.size(); i++){
        if( i == 0 || v[i].second >= u.back() )
            u.push_back(v[i].second);
        else{
            *lower_bound(u.begin(),u.end(),v[i].second) = v[i].second;
        }
    }
    double delta = 20 - 5*acos(-1.0);
    long long s = 100*(LL)abs(sx-tx) + 100*(LL)abs(sy-ty);
    cout.precision(15);
    if( min(abs(sx-tx), abs(sy-ty)) == u.size()-1 ) cout << s - (u.size()-1)*delta + (u.size()!=0)*(10*acos(-1.0)-20) << "\n";
    else cout << s - u.size()*delta << "\n";
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    vector<int>d(N);
    for(int i = 0; i < N; i++) {
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    cout << d[N/2]-d[N/2-1] << endl;
}


Measured memory_bytes: 4052
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
ans = 0
for i in range(m):
    visited = [0] * n

    graph = defaultdict(list)
    for j in range(m):
        if j != i:
            graph[ab[j][0] - 1].append(ab[j][1] - 1)
            graph[ab[j][1] - 1].append(ab[j][0] - 1)

    stack = [0]
    while stack:
        start = stack.pop()
        for target in graph[start]:
            if visited[target] == 0:
                visited[target] = 1
                stack.append(target)

    if sum(visited) != n:
        ans += 1

print(ans)


Measured memory_bytes: 3316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        m: usize,
        k: usize
    }
    let d = 1000000007;
    let mut st = vec![0; n + m + k];
    st[0] = 1;
    for i in 1..n + m + k {
        st[i] = st[i - 1] * i % d;
    }
    let sti: Vec<usize> = st.iter().cloned().map(|x| inv_m(x, d)).collect();
    let mut pow3 = vec![0; m + k + 1];
    pow3[0] = 1;
    for i in 0..m + k {
        pow3[i + 1] = pow3[i] * 3 % d;
    }
    let m1 = min(m, k);
    let k1 = max(m, k);
    let mut ans = pow3[m + k];
    let mut s = 1;
    for i in 1..m + k + 1 {
        if i <= m1 {
            s = s * 2 % d;
        } else if i <= k1 {
            s = (s * 2 + d - st[i - 1] * sti[i - 1 - m1] % d * sti[m1] % d) % d;
        } else {
            s = (s * 2 + 2 * d - st[i - 1] * sti[i - 1 - m1] % d * sti[m1] % d - st[i - 1] * sti[i - 1 - k1] % d * sti[k1] % d) % d;
        }
        ans = (ans + st[i + n - 1] * sti[n - 1] % d * sti[i] % d * pow3[m + k - i] % d * s) % d;
    }
    println!("{}", ans);
}

fn pow_m(n: usize, mut p: usize, d: usize) -> usize {
    let mut r = n;
    let mut ret = 1;
    while p > 0 {
        if p % 2 == 0 {
            r = r * r % d;
            p /= 2;
        } else {
            ret = ret * r % d;
            p -= 1;
        }
    }
    ret
}

fn inv_m(n: usize, d: usize) -> usize {
    pow_m(n, d - 2, d)
}


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

void koch( int d , double p1[] , double p2[] ){
	
	if( d == 0 ){
		return;
	}
	
	double rad = 60 * M_PI / 180;
	double s[2] , t[2] , u[2];
	s[0] = ( 2 * p1[0] + p2[0] ) / 3;
	s[1] = ( 2 * p1[1] + p2[1] ) / 3;
	t[0] = ( p1[0] + 2 * p2[0] ) / 3;
	t[1] = ( p1[1] + 2 * p2[1] ) / 3;
	u[0] = ( t[0] - s[0] ) * cos(rad) - ( t[1] - s[1] ) * sin(rad) + s[0];
	u[1] = ( t[0] - s[0] ) * sin(rad) + ( t[1] - s[1] ) * cos(rad) + s[1];
	
	koch( d-1 , p1 , s );
	printf( "%.8f %.8f\n" , s[0] , s[1] );
	koch( d-1 , s , u );
	printf( "%.8f %.8f\n" , u[0] , u[1] );
	koch( d-1 , u , t );
	printf( "%.8f %.8f\n" , t[0] , t[1] );
	koch( d-1 , t , p2 );
	
	
}

int main( void ){
	
	int n;
	double p1[2] = { 0 , 0 };
	double p2[2] = { 100 , 0 };
	
	scanf( "%d" , &n );
	
	printf( "%.8f %.8f\n" , p1[0] , p1[1] );
	koch( n , p1 , p2 );
	printf( "%.8f %.8f\n" , p2[0] , p2[1] );
	
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 

int main(){
   IOS;

   long int n;
   cin>>n;

   vector<long int> v(n);
   for(long int i = 0; i  < n; i++)
 		cin>>v[i];
 	
 	long int ans = 0;
 	for(long int i = 0; i < n; i++)
 		for(long int j = i+1; j < n; j++)
 			ans += v[i]*v[j];

 	cout<<ans;

   return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.Frame;
import java.io.*;

public class Main {
	// static ArrayList<Integer>[] g;

	static pair[] a;
	static int[][] memo;

	static int dp(int l, int r) {
		if (l > r)
			return 0;
		if (memo[l][r] != -1)
			return memo[l][r];
		int ans = dp(l + 1, r);
		ans = Math.max(ans, dp(l, r - 1));
		for (int idx : startAt[l]) {
			if (a[idx].y >= r)
				continue;
			int inc = exist[a[idx].y + 1][r] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}
		for (int idx : endAt[r]) {
			if (a[idx].x <= l)
				continue;
			int inc = exist[l][a[idx].x - 1] ? 1 : 0;
			ans = Math.max(ans, 1 + dp(a[idx].x, a[idx].y) + inc + dp(a[idx].y + 1, r));
		}

		return memo[l][r] = ans;
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(br.readLine());
		long x = Long.parseLong(st.nextToken());
		long k = Long.parseLong(st.nextToken());
		long d = Long.parseLong(st.nextToken());
		long r = Math.abs(0 - x);
		long c = r / d;
		if (x > 0) {
			if (c > k) {
				x -= k * d;
			} else {
				x -= c * d;
				k -= c;
				if (k % 2 == 1)
					x -= d;
			}

		} else {
			if (c > k) {
				x += k * d;
			} else {
				x += c * d;
				k -= c;
				if (k % 2 == 1)
					x += d;
			}
		}
		pw.println(Math.abs(x));
		pw.flush();
		pw.close();

	}

	static int maxSize;
	static boolean[][] exist;
	static ArrayList<Integer>[] startAt, endAt;

	static void compress(pair[] arr) {
		TreeSet<Integer> tr = new TreeSet<>();
		for (int i = 0; i < arr.length; i++) {
			tr.add(arr[i].x);
			tr.add(arr[i].y);
		}
		tr.add(0);
		tr.add((int) 1e9);
		HashMap<Integer, Integer> hm = new HashMap<>();
		for (int x : tr)
			hm.put(x, hm.size());
		for (int i = 0; i < arr.length; i++) {
			arr[i].x = hm.get(arr[i].x);
			arr[i].y = hm.get(arr[i].y);
		}
		maxSize = hm.size();
	}

	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			int x1 = y - x;
			int x2 = o.y - o.x;
			return x1 - x2;
		}

	}

}

Measured memory_bytes: 32928
n = int(input())
S = input()
S = sorted([S[i] for i in range(len(S))])
for i in range(1, n):
    S_input = input()
    S_input = sorted([S_input[i] for i in range(len(S_input))])
    result = []
    j_start = 0
    for i in range(len(S)):
        for j in range(j_start, len(S_input)):
            if S[i] == S_input[j]:
                result.append(S[i])
                j_start = j + 1
                break
    S = result

print("".join(S))


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

string s;
string ans;

void Backtrack(int i, int total) {
    if (i==4) {
        if (total==7) {
            for (int j=0; j<ans.size(); ++j) {
                cout << ans[j];
            }

            cout << "=7";

            exit(0);
        }
        else {
            return;
        }
    }


    total+=(s[i]-'0');
    ans+='+';
    ans+=s[i];
    Backtrack(i+1, total);
    total-=(s[i]-'0');
    ans.pop_back();
    ans.pop_back();

    total-=(s[i]-'0');
    ans+='-';
    ans+=s[i];
    Backtrack(i+1, total);
    total+=(s[i]-'0');
    ans.pop_back();
    ans.pop_back();
}

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

    cin >> s;
    ans+=s[0];
    Backtrack(1, s[0]-'0');

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

int main() {

	string S;
	cin >> S;

	if (S == "Sunny") cout << "Cloudy" << endl;
	if (S == "Cloudy") cout << "Rainy" << endl;
	if (S == "Rainy") cout << "Sunny" << endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a == 1) {
			a=14;
		}
		if (b == 1) {
			b=14;
		}
		if(a > b){
			System.out.println("Alice");
		}else if(a == b){
			System.out.println("Draw");
		}else if(a < b){
			System.out.println("Bob");
		}
	}
}

Measured memory_bytes: 21844
n, k = map(int, input().split())
a = [-1] + list(map(int, input().split()))

visited = [0] * (1 + n)
curr = 1
while k:
    if visited[curr]:
        break
    else:
        visited[curr] = k
        curr = a[curr]
        k -= 1
        if k == 0:
            print(curr)
            exit()
repeat = visited[curr] - k
k = k % repeat
while k:
    curr = a[curr]
    k -= 1
print(curr)

Measured memory_bytes: 32356
#include<bits/stdc++.h>
#define ff(v,a,b) for(int v=a;v<=b;v++)
using namespace std;
int a[305][305];
int m,n;
bool ch[305];
int t[305];
int qu[305];
int ans=505;
int main() {
	//freopen("sport.in","r",stdin);
	//freopen("sport.out","w",stdout);
	cin>>n>>m;
	ff(i,1,n)ff(j,1,m)scanf("%d",&a[i][j]);
	ff(i,1,m) {
		ff(j,1,n) {
			int k=1;
			while(ch[a[j][k]])k++;
			t[a[j][k]]++;
		}
		int maxt=0,tt;
		ff(j,1,m)if(t[j]>maxt) {
			maxt=t[j];
			tt=j;
		}
		ch[tt]=true;
		ans=min(ans,maxt);
		ff(j,1,m)t[j]=0;
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
	long long n,i,p,q;
	while(cin>>n,n){
		vector<int> ids;
		map<int,long long> m;
		while(n--){
			cin>>i>>p>>q;
			if(!m.count(i))ids.push_back(i);
			m[i]+=p*q;
		}
		int na=1;
		for(int k=0;k<(int)ids.size();++k){
			if(1e6<=m[ids[k]]){
				cout<<ids[k]<<endl;
				na=0;
			}
		}
		if(na) cout<<"NA\n";
	}
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),m=read();
signed main(){
	if(n%2==1){
		fz(i,1,m)	cout<<i<<" "<<2*m+1-i<<endl;
	}
	else{
		fz(i,1,m){
			if(i<=m/2)	cout<<i<<" "<<2*m+2-i<<endl;
			else		cout<<i<<" "<<2*m+1-i<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <map>
using namespace std;
struct Tree{
        int parent;
        int sibling;
        int degree;
        int depth;
        int height;
        int left;
        int right;
};
map<int,Tree> tree;
int recursion(int now,int depth){
        int height1=0,height2=0;
        tree[now].depth=depth;
        if(tree[now].left!=-1)
                height1=recursion(tree[now].left,depth+1)+1;
        if(tree[now].right!=-1)
                height2=recursion(tree[now].right,depth+1)+1;
        if(height1>height2) tree[now].height=height1;
        else    tree[now].height=height2;
        return tree[now].height;
}
string Get_type(int now){
        if(tree[now].parent==-1)
                return "root";
        else if(tree[now].degree!=0)
                return "internal node";
        else
                return "leaf";
}
int main(){
        int N;
        cin >> N;
        for(int i=0 ; i<N ; i++ ){
                tree[i].parent=-1;
                tree[i].left=tree[i].right=-1;
                tree[i].sibling=-1;
                tree[i].degree=0;
        }
        for(int i=0 ; i<N ; i++){
                int node;
                cin >> node;
                cin >> tree[node].left >> tree[node].right;
                tree[tree[node].left].parent=node;
                tree[tree[node].right].parent=node;
                tree[tree[node].left].sibling=tree[node].right;
                tree[tree[node].right].sibling=tree[node].left;
                if(tree[node].left!=-1)
                        tree[node].degree++;
                if(tree[node].right!=-1)
                        tree[node].degree++;
        }int root;
        for(int i=0 ;i<N;i++)
                if(tree[i].parent==-1){
                        root=i;
                        break;
                }
        recursion(root,0);
        for(int i=0 ; i<N ; i++ ){
                cout<<"node "<<i<<": parent = "<<tree[i].parent;
                cout<<", sibling = "<<tree[i].sibling;
                cout<<", degree = "<<tree[i].degree;
                cout<<", depth = "<<tree[i].depth;
                cout<<", height = "<<tree[i].height;
                cout<<", "<<Get_type(i)<<endl;
        }
        return 0;
}


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

int main() {
	int n, m;
	int sn[100] = { 0 };
	int	 sm[100] = { 0 };
	int sum_n, sum_m, ofs;

	while (true) {
		int outn = 1000;
		int outm = 1000;
		int flag = 0;
		sum_n = 0;
		sum_m = 0;
		cin >> n >> m;
		if (n == 0 || m == 0) break;

		for (int i = 0; i < n; i++) {
			cin >> sn[i], sum_n += sn[i];
		}
		for (int i = 0; i < m; i++) {
			cin >> sm[i], sum_m += sm[i];
		}
		ofs = sum_n - sum_m;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (ofs == (sn[i] - sm[j]) * 2) {
					if (outn + outm > sn[i] + sm[j]) outn = sn[i], outm = sm[j], flag = -1;
				}
			}
		}
		if (flag == -1) cout << outn << " " << outm << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
# 0 = 青　1 = 赤
s = list(input())
if len(s) == 1:
    print(0)
    exit()

tmp1 = s.count('1')
tmp2 = s.count('0')
if tmp1 == 0 or tmp2 == 0:
    print(0)
else:
    print(min(tmp1, tmp2) * 2)


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

long long n, a[200005], suf[200005], mod = 1e9+7;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long sum = a[n-1];
    suf[n-1] = a[n-1];
    for (int i = n-2; i >= 0; i--){
        sum += a[i];
        sum %= mod;
        suf[i] = sum;
    }
    long long ans = 0;
    for (int i = 0; i < n-1; i++){
        ans += a[i]*suf[i+1];
        ans %= mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 6752
n = gets.to_i
s = []
n.times { |i|
    s.append(gets.chomp.to_s)
}
puts 'AC x '+ s.count('AC').to_s
puts 'WA x '+ s.count('WA').to_s
puts 'TLE x '+ s.count('TLE').to_s
puts 'RE x '+ s.count('RE').to_s

Measured memory_bytes: 20668
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++) {
    if(s.at(i)=='A') {
      s.at(i)='T';
    }
    else if(s.at(i)=='T') {
      s.at(i)='A';
    }
    else if(s.at(i)=='G') {
      s.at(i)='C';
    }
    else{
      s.at(i)='G';
    }
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256