akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
const int N = 1e4+5;
char s[N];

int main(){
    int k;
    scanf("%d%s",&k,s);
    int n = strlen(s);
    for(int i = 0; i < n; i++){
        int u = s[i]-'A';
        u = (u + k)%26;
        printf("%c",'A'+u);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
nx = [ int(x) for x in input().split(" ")]
ln = [ int(x) for x in input().split(" ")]
sum = 0
for i in range(nx[0]):
    sum += ln[i]
    if sum > nx[1]:
        break

if i == nx[0] - 1 and sum <= nx[1]:
    i += 1

print(i + 1)

Measured memory_bytes: 3060
from math import atan, pi
a, b, x = map(int, input().split())

if x > (a ** 2 * b / 2):
    print(atan(2 * (a ** 2 * b - x) / a ** 3) * 180 / pi)
else:
    print(atan((a * b ** 2) / (2 * x)) * 180 / pi)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define MOD 1000000007
#define N 5005
using namespace std;

int n,dp[N][N];
char s[N];

int dfs(int rem,int stl) {

  if(rem<stl) return 0;
  if(rem==stl) return 1;
  if(~dp[rem][stl]) return dp[rem][stl];
  return dp[rem][stl]=((2*dfs(rem-1,stl+1))%MOD+dfs(rem-1,stl-(stl>0)))%MOD;

}

int main() {

  memset(dp,-1,sizeof(dp));
  scanf("%d %s",&n,s+1);
  int len=strlen(s+1);
  printf("%d",dfs(n,len));

}


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


int main (void){
	long long int n,m,a[200001],b[200001],i,j,ans=0,min,x,y;
	char t[200005];
	cin >> n >> t;
	for(i=0;i<n;i++){
		if(t[i]!='#') ans++;
	}
	min=ans;
	for(i=0;i<n;i++){
		if(t[i]=='#') ans=ans+1;
		else ans=ans-1;
		if(min>ans) min=ans;
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 384
#include <queue>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

const int N=3e5+2;
int n,k,p[N],f[N];

template <typename _Tp> inline void IN(_Tp&x) {
    char ch;bool flag=0;x=0;
    while(ch=getchar(),!isdigit(ch)) if(ch=='-') flag=1 ;
    while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    if(flag) x=-x;
}

struct Segment_Tree {
    #define mid ((l+r)>>1)
    int Mi[N<<2],Mx[N<<2];
    void build(int x,int l,int r) {
        if(l==r) {Mi[x]=Mx[x]=p[l];return;}
        build(x<<1,l,mid),build(x<<1|1,mid+1,r);
        Mi[x]=min(Mi[x<<1],Mi[x<<1|1]),Mx[x]=max(Mx[x<<1],Mx[x<<1|1]);
    }
    int query_Mi(int x,int l,int r,int L,int R) {
        if(L==l&&r==R) return Mi[x];
        if(R<=mid) return query_Mi(x<<1,l,mid,L,R);
        else if(L>mid) return query_Mi(x<<1|1,mid+1,r,L,R);
        else return min(query_Mi(x<<1,l,mid,L,mid),query_Mi(x<<1|1,mid+1,r,mid+1,R));
    }
    int query_Mx(int x,int l,int r,int L,int R) {
        if(L==l&&r==R) return Mx[x];
        if(R<=mid) return query_Mx(x<<1,l,mid,L,R);
        else if(L>mid) return query_Mx(x<<1|1,mid+1,r,L,R);
        else return max(query_Mx(x<<1,l,mid,L,mid),query_Mx(x<<1|1,mid+1,r,mid+1,R));
    }
}T;

int main() {
    IN(n),IN(k);
    for(int i=1;i<=n;++i) IN(p[i]);
    T.build(1,1,n);
    int Mi=T.query_Mi(1,1,n,1,k),Mx=T.query_Mx(1,1,n,1,k),cnt=0;
    f[1]=1;
    bool flag=false;
    for(int i=2;i<=n;++i)
        f[i]=(p[i-1]<=p[i])?f[i-1]+1:1,
        flag|=((f[i]>=k)&&i>k);
    if(flag) ++cnt;
    if((f[k]==k&&!flag)||(f[k]<k)) ++cnt;
    for(int r=k+1;r<=n;++r) {
        int now_Mi=T.query_Mi(1,1,n,r-k+1,r),now_Mx=T.query_Mx(1,1,n,r-k+1,r);
        if(!(Mi==p[r-k]&&now_Mx==p[r])&&f[r]<k) ++cnt;
        Mi=now_Mi,Mx=now_Mx;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
using namespace std;
int main(){
    for(int i = 0; 4 > i; i++){
        int a,b;
        cin>>a>>b;
        if(a==1)cout << 6000*b << endl;
        else if(a==2)cout << 4000*b << endl;
        else if(a==3)cout << 3000*b << endl;
        else cout << 2000*b << endl;
    }
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      std::vector<Int> xs(n); scan(xs);
      Int m; scan(m);
      std::vector<Int> ys(m); scan(ys);
      std::sort(xs.begin(), xs.end());
      std::sort(ys.begin(), ys.end());
      bool fail = false;
      {
         Int i = 0, k = 0;
         for(;;) {
            if( k >= m ) break;
            if( i >= n ) {
               fail = true;
               break;
            }
            if( xs[i] == ys[k] ) {
               i += 1;
               k += 1;
            }
            else if( xs[i] > ys[k] ) {
               fail = true;
               break;
            }
            else if( xs[i] < ys[k] ) {
               i += 1;
            }
         }
      }
      puts(fail?"NO":"YES");
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

void Main()
{
	int N;
	cin >> N;
	vector<double> v(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N - 1; i++) {
		sort(v.begin() + i, v.end());
		double mixed = (v[i] + v[i + 1]) / 2;
		v[i + 1] = mixed;
	}
	cout << v[N - 1];
}
 
int main()
{
	Main();
	return 0;
}



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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> l(N);
    rep(i, N) {
        cin >> l.at(i);
    }

    sort(l.begin(), l.end(), greater<int>());

    int sum = 0;
    rep(i, K) {
        sum += l.at(i);
    }

    cout << sum << endl;

    return 0;
}

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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

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

  vector<int> v(n+1,0);
  vector<int> ans;
  for(int i = n; i >= 1; i--){
    if(a[i] == 1){
      if(v[i]%2 == 1) continue;
      ans.push_back(i);
      for(int j = 1; j*j <= i; j++){
        if(i%j == 0){
          v[j]++;
          if(j != i/j) v[i/j]++;
        }
      }
    }
    else {
      if(v[i]%2 != 0){
        ans.push_back(i);
        for(int j = 1; j*j <= i; j++){
          if(i%j == 0){
            v[j]++;
            if(j != i/j) v[i/j]++;
          }
        }
      }
    }
  }

  for(int i = 1; i <= n; i++){
    if(v[i]%2 != a[i]){
      cout << -1 << endl;
      return 0;
    }
  }

  sort(ans.begin(),ans.end());
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); i++){
    if(i == 0) cout << ans[i];
    else cout << " " << ans[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4980
using System;

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        string ans ="";
        foreach(char c in str)
        {
            if(c != 'B')
            {
                ans += c;
            }
            else
            {
                try
                {
                    ans = ans.Remove(ans.Length - 1);
                }catch { }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 2648
#include<stdio.h>

int solve(int,int);

int n,A[50];

int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i = 0;i <= n-1;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0;i <= q-1;i++){
    scanf("%d",&m);
    if(solve(0,m)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
    return 0;
}

int solve(int i,int m){
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  int res = solve(i + 1,m) || solve(i + 1,m - A[i]);
  return res;
}




Measured memory_bytes: 2044
n = gets.to_i

answers = Hash.new { |h, k| h[k] = 0 }

1.upto(100) do |x|
  1.upto(100) do |y|
    1.upto(100) do |z|
      answer = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      answers[answer] += 1
    end
  end
end

(1..n).each do |num|
  puts answers[num]
end


Measured memory_bytes: 16716
#include<bits/stdc++.h>
#define eps 1e-8
#define pr pair<int,int>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 4;
int a[maxx][maxx];
int b[101];
int c, d, e, f, g, h, k, m;
map<int, int> mp;
int main()
{
	int N, x;
	for(int i = 0; i < 3; i ++)
	{
		for(int j = 0; j < 3; j ++)
		{
			cin >> a[i][j];
			b[a[i][j]] = false;
			mp[a[i][j]] ++;
		}
	}
	cin >> N;
	for(int i = 0; i < N; i ++)
	{
		cin >> x;
		mp[x] ++;
		if(mp[x] == 2) b[x] = true;
		else b[x] = false;
	}
	for(int i = 0; i < 3; i ++)
	{
		for(int j = 0; j < 3; j ++)
		{
			if(i == 0 && b[a[i][j]])
				c ++;
			if(i == 1 && b[a[i][j]])
				d ++;
			if(i == 2 && b[a[i][j]])
				e ++;
			if(j == 0 && b[a[i][j]])
				f ++;
			if(j == 1 && b[a[i][j]])
				g ++;
			if(j == 2 && b[a[i][j]])
				h ++;
			if(j == i && b[a[i][j]])
				k ++;
			if(((i == 0 && j == 2) || (i == 1 && j == 1) || (i == 2 && j == 0)) && b[a[i][j]])
				m ++;
				
		}
	}
	if(c == 3 || d == 3 || e == 3 || f == 3 || g == 3 || h == 3 || k == 3 || m == 3) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int MAX=1046527;

int Hash[MAX];

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

int getChar(char s){
    int ans=0;
    if(s=='A')ans=1;
    else if(s=='C')ans=2;
    else if(s=='G')ans=3;
    else if(s='T')ans=4;
    return ans;
}

int getKey(char str[]){
    int ans=0,k=1;
    for(int i=0;i<strlen(str);i++){
        ans+=getChar(str[i])*k;
        k*=5;
    }
    return ans;
}
int h1(int key){return key%MAX;}

int h2(int key){return 1+key%(MAX-1);}

int hashselect(int key,int i){
    return (h1(key)+h2(key)*i)%MAX;
}

void insertkey(int key){
    int i=0;
    while(Hash[hashselect(key,i)]!=-1&&Hash[hashselect(key,i)]!=key){i++;}
    Hash[hashselect(key,i)]=key;
    return;
}

bool findkey(int key){
    int i=0;
    while(Hash[hashselect(key,i)]!=-1&&Hash[hashselect(key,i)]!=key){i++;}
    if(Hash[hashselect(key,i)]==key)return true;
    else return false;
}

int main(){
    init();
    int n,key;
    cin>>n;
    char str1[10],str2[15];
    for(int i=0;i<n;i++){
        scanf("%s %s",str1,str2);
        key=getKey(str2);
        if(str1[0]=='i')insertkey(key);
        else if(str1[0]=='f'){
            if(findkey(key))printf("yes");
            else printf("no");
            printf("\n");
        }
    }
}


Measured memory_bytes: 7320
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
	 ios::sync_with_stdio(false);
	 string str;
	 int flag;
	 int cnt,i;
	 while(cin>>str)
	 {
	 	 flag=0; cnt=0;
	 	 if(str.length()>=4 && str.length()<= 10)
	 	 {
	 	 	   for(i=0;i<str.length();i++)
	 	 	   {
		 	 	   	if(!(str.at(i)>='a'&&str.at(i)<='z'||str.at(i)>='A'&&str.at(i)<='Z'))
		 	 	   	{
		 	 	   		cout<<"WA\n";
		 	 	   	   return 0;
				    }
	 	 	   	
			   }
		 	 	 if(str.at(0)=='A')
		 	 	 {
					 	 	 	for(i=2;i<str.length()-1;i++)
					 	 	 	{
					 	 	 			if(str.at(i)=='C')
								 	 	 		 flag=1;
								 }
					 	 	 	for(i=0;i<str.length();i++)
			 	 	 	    {					 	 	 	
						 	 	 		 if(str.at(i)>='a'&&str.at(i)<='z')
						 	 	 		  cnt++;
			    			}	 
							    if(cnt+flag==str.length()-1&&flag==1)
							      cout<<"AC\n";
							    else cout<<"WA\n";							      
						   
			    }			
	 	    else cout<<"WA\n";
	   }
		 else cout<<"WA\n";
	 }
	 return 0;
}


Measured memory_bytes: 256
from collections import deque

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
move = [(1,0), (0,1), (-1,0), (0,-1)]

queue = deque()
visited = [[-1] * w for _ in range(h)]
for row in range(h):
    for col in range(w):
        if a[row][col] == "#":
            visited[row][col] = 0
            queue.append((row, col, 0))
dist = 0
while queue:
    row, col, dist = queue.popleft()
    for drow, dcol in move:
        if row+drow>=0 and row+drow<h and col+dcol>=0 and col+dcol<w and visited[row+drow][col+dcol] == -1 and a[row+drow][col+dcol] == ".":
            visited[row+drow][col+dcol] = dist + 1
            queue.append((row+drow, col+dcol, dist+1))


print(dist)


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

const long money[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

int main(){
    long N;
    long dp[100002] = {};
    for(long i=0;i<100002;i++) dp[i] = 1e9;
    cin >> N;
    dp[0] = 0;
    for(long i=1;i<=N;i++){
        for(int j=0;j<12;j++){
            if(i >= money[j]){
                dp[i] = min(dp[i], dp[i-money[j]]+1);
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input()) - 1
a = list(map(int, input().split()))

count = 0
flag  = 1

while flag:
    flag = 0
    j    = 0
    for i in range( n, j, -1 ):
        if a[i] < a[i-1]:
            t = a[i]
            a[i] = a[i-1]
            a[i-1] = t
            count += 1
            flag = 1
        j += 1

print(*a)
print(count)

Measured memory_bytes: 7720
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int num[] = new int[6];
		int answer = 0;
		int decTime = 0;
//		int up = -1;
		int frontBanti = 0;
		diceClass dice =new diceClass();
		for (int i=0;i<6;i++){
			num[i] = scan.nextInt();
			dice.pos[i] = num[i];
		}
		decTime = scan.nextInt();
		int upSide[] = new int[decTime];
		int frontSide[] = new int[decTime];
		for(int i=0;i<decTime;i++){
			upSide[i] = scan.nextInt();
			frontSide[i] = scan.nextInt();
			for(int ii=0;ii<6;ii++){
				if(frontSide[i] == num[ii]){
					frontBanti = ii;
				}
			}
			for(int ii=0;ii<6;ii++){
				if(upSide[i] == num[ii]){
					answer = dice.rightNumber(ii,frontBanti);
					System.out.println(num[answer]);
				}
			}
		}
	}
}
class diceClass{	//?????????????????¢?????????????????´?????????
	int pos[] = new int[6];
	int up0[] = {1,2,4,3};
	int up1[] = {0,3,5,2};
	int up2[] = {0,1,5,4};
	int up3[] = {0,4,5,1};
	int up4[] = {0,2,5,3};
	int up5[] = {1,3,4,2};
	public diceClass(){

	}

//	public int move(char direction){
//		int[] temp = (int[])pos.clone();
//		if(direction == 'N'){
//			pos[0] = temp[1];
//			pos[1] = temp[5];
//			pos[2] = temp[2];
//			pos[3] = temp[3];
//			pos[4] = temp[0];
//			pos[5] = temp[4];
//		}
//		else if(direction == 'E'){
//			pos[0] = temp[3];
//			pos[1] = temp[1];
//			pos[2] = temp[0];
//			pos[3] = temp[5];
//			pos[4] = temp[4];
//			pos[5] = temp[2];
//		}
//		else if(direction == 'W'){
//			pos[0] = temp[2];
//			pos[1] = temp[1];
//			pos[2] = temp[5];
//			pos[3] = temp[0];
//			pos[4] = temp[4];
//			pos[5] = temp[3];
//		}
//		else if(direction == 'S'){
//			pos[0] = temp[4];
//			pos[1] = temp[0];
//			pos[2] = temp[2];
//			pos[3] = temp[3];
//			pos[4] = temp[5];
//			pos[5] = temp[1];
//		}
//		return pos[0];
//	}
	public int rightNumber(int up,int ri){
		int[] temp = new int[4];
		int front = 0;
//		System.out.println("up "+up+"  "+"front "+ri);
		if(up == 0){
			temp = (int[])up0.clone();
		}
		else if(up == 1){
			temp = (int[])up1.clone();
		}
		else if(up == 2){
			temp = (int[])up2.clone();
		}
		else if(up == 3){
			temp = (int[])up3.clone();
		}
		else if(up == 4){
			temp = (int[])up4.clone();
		}
		else if(up == 5){
			temp = (int[])up5.clone();
		}
		for(int i =0;i<4;i++){
//			System.out.println("compare "+temp[i]+" "+ri);
			if(temp[i] == ri){
				front = i+1;
				if(front == 4){
					front = 0;
				}
				break;
			}
		}
		return temp[front];
	}
}

Measured memory_bytes: 26128
#include <stdio.h>
#include <string.h>
int main(void)
{
    int N, L;
    char s[100][200], tmp[200];
    scanf("%d %d", &N, &L);
    for (int i = 0; i < N; i++)
        scanf("%s", s[i]);
    for (int i = 1; i < N; i++) {
        for (int j = 1; j < N; j++) {
            if (strcmp(s[j - 1], s[j]) > 0) {
                strcpy(tmp, s[j - 1]);
                strcpy(s[j - 1], s[j]);
                strcpy(s[j], tmp);
            }
        }
    }
    for (int i = 0; i < N; i++)
        printf("%s", s[i]);
    return 0;
}

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    FOREACH(x, v) { cout << x << " "; }                                        \
    cout << "\n";

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
vector<pair<string, ll>> sp;
map<ll, ll> memo;

bool comp(const pair<string, ll> &a, const pair<string, ll> &b) {
    if(a.first != b.first)
        return a.first < b.first;
    else
        return a.second > b.second;
}

int main() {
    cin >> N;
    REP(i, N) {
        SCIN(S);
        LCIN(P);
        sp.emplace_back(S, P);
        memo[P] = i + 1;
    }
    sort(All(sp), comp);
    REP(i, N) { cout << memo[sp[i].second] << "\n"; }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;
long long gcd(long long a, long long b)
{
  return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main()
{
  int N;
  cin >> N;
  vector<long long> A(N), T(N);
  rep(i, N)
  {
    cin >> T[i] >> A[i];
  }
  long long sum_a = 1;
  long long sum_t = 1;

  rep(i, N)
  {
    long long n = max((sum_t + T[i] - 1) / T[i], (sum_a + A[i] - 1) / A[i]);
    sum_t = T[i] * n;
    sum_a = A[i] * n;
  }
  long long ans = sum_a + sum_t;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

int a[1000]={0};

int main(){
	int x,n;
	cin>>x>>n;
	int re;
	for(int i=0;i<n;i++){
	cin>>re;
	a[re]++;	
	}
	
	int ans,res,ans1=inf,res1;
	for(int i=x;i<=101;i++){
		if(a[i]==0){
		ans = i - x;
		res = i;
		break;	
		} 
	}
	for(int i=x-1;i>=0;i--){
		if(a[i]==0){
		ans1 = min(ans1,x - i);
		res1 = i;
		break;	
		}
	}
	if(ans < ans1) cout<<res<<endl;
	if(ans == ans1) cout<<res1<<endl;
	if(ans > ans1) cout<<res1<<endl;
	return 0;
}

Measured memory_bytes: 3192
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int n, m;
string s, t;
int dp[2][2002][2002];
bool S[2002], T[2002];

inline int rec(int I, int a, int b) // I := ???I????????????, a := s??????????????????, b := t??????????????????
{
    int &res = dp[I][a][b];

    if (~res) return res;

    res = 0;
    
    if (a < m && I != S[a]) {
        chmax(res, 1 + rec(S[a], a + 1, b));
    }

    if (b < n && I != T[b]) {
        chmax(res, 1 + rec(T[b], a, b + 1));
    }

    return res;
}

#define local 0

int main()
{
    if (!local) {
        m = in(), n = in();
        cin >> s >> t;
    } else {
        cin >> s >> t;
        m = s.size(), n = t.size();
    }

    rep(i, m) S[i] = s[i] == 'I';
    rep(i, n) T[i] = t[i] == 'I';

    memset(dp, -1, sizeof dp);

    int ma = 0;

    rep(i, m) rep(j, n) {
        chmax(ma, rec(S[i], i+1, j) + S[i]);
        chmax(ma, rec(T[j], i, j+1) + T[j]);
    }

    printf("%d\n", ma == 0 ? 0 : (ma - (ma % 2 == 0)));
}

Measured memory_bytes: 34948
import java.util.Scanner;

public class Main {

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

		int X = sc.nextInt();
		// 出力
		if(X >= 30) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	    // Scannerクラスのインスタンスをクローズ
		sc.close();
	}
}


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

using lint = long long int;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define REP(i, n) FOR(i, 0, n)

int main()
{
    lint n;
    cin >> n;
    lint a[n],x[n],asum=0;
    REP(i, n){
        cin >> a[i];
        asum += a[i];
    }
    x[0] = asum / 2;
    FOR(i,1,n-1){
        x[0] -= a[i];
        i++;
    }
    FOR(i,1,n){
        x[i] = a[i - 1] - x[i - 1];
    }
    REP(i, n)
    {
        cout << x[i]*2<<" ";
    }
    return 0;
}

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

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

Node *nil;

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

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

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

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

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

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

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

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

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


Measured memory_bytes: 32972
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
const int N=50+10;

char arr1[N];
int arr2[N];

int main()
{
    ll a,b,c;
    ll k;
    while(cin>>a>>b>>c){
        cin>>k;
        ll num=a-b;
        if(k%2==1){
            cout<<(num*(-1))<<endl;
        }
        else{
            cout<<num<<endl;
        }
    }


    return 0;
}


Measured memory_bytes: 256
while 1:
    try:
        s=input()
        a,b,c,d,e,f = [int(x) for x in s.split()]
        y = (d*c-a*f)/(b*d-a*e)
        x = (c-b*y)/a
        print('{:.3f} {:.3f}'.format(x,y))
    except:
        break

Measured memory_bytes: 5616
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x) cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) cerr << "  (L" << __LINE__ << ") " << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
template<typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << "," << d.second << ")";}

static const int INF = 100000000;

double width(const vector<PII>& P, double x) {
  double lb = INF;
  double ub = -INF;

  REP(i, P.size()) {
    int i_next = (i + 1) % P.size();
    int x1 = P[i].first;
    int x2 = P[i_next].first;
    if ((x1 - x) * (x2 - x) <= 0) {
      int y1 = P[i].second;
      int y2 = P[i_next].second;
      double y = y1;
      if (x2 - x1 != 0) {
        y = (y1 * (x2 - x) + y2 * (x - x1)) / double(x2 - x1);
      }
      lb = min(lb, y);
      ub = max(ub, y); 
    }
  }

  return ub - lb;
}

double solve(int M, int N, const vector<PII>& P_XY, const vector<PII>& P_XZ) {
  int min1 = INF, min2 = INF, max1 = -INF, max2 = -INF;
  vector<int> xs;
  REP(i, M) {
    min1 = min(min1, P_XY[i].first);
    max1 = max(max1, P_XY[i].first);
    xs.push_back(P_XY[i].first);
  }
  REP(i, N) {
    min2 = min(min2, P_XZ[i].first);
    max2 = max(max2, P_XZ[i].first);
    xs.push_back(P_XZ[i].first);
  }

  sort(ALL(xs));
  xs.erase(unique(ALL(xs)), xs.end());

  double res = 0.0;

  for (int i = 0; i+1 < xs.size(); i++) {
    if (xs[i] >= min1 && xs[i] <= max1 && xs[i] >= min2 && xs[i] <= max2 &&
        xs[i+1] >= min1 && xs[i+1] <= max1 && xs[i+1] >= min2 && xs[i+1] <= max2) {
      double a = xs[i];
      double b = xs[i+1];
      double c = (a + b) / 2.0;
      double fa = width(P_XY, a) * width(P_XZ, a);
      double fb = width(P_XY, b) * width(P_XZ, b);
      double fc = width(P_XY, c) * width(P_XZ, c);

      res += (b - a) * (fa + fb + 4 * fc) / 6.0;
    }
  }

  return res;
}

int main() {
  while (true) {
    int M, N; scanf("%d %d", &M, &N);
    if (M == 0 && N == 0) break;

    vector<PII> P_XY(M);
    vector<PII> P_XZ(N);
    REP(i, M) scanf("%d %d", &P_XY[i].first, &P_XY[i].second);
    REP(i, N) scanf("%d %d", &P_XZ[i].first, &P_XZ[i].second);

    double ans = solve(M, N, P_XY, P_XZ);
    printf("%.10f\n", ans);
  }
}

Measured memory_bytes: 0
#include <stdio.h>

#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )
#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define INTERSECT(A1,A2,B1,B2) \
  (  ( MAX(A1,A2) >= MIN(B1,B2) ) \
  && ( MIN(A1,A2) <= MAX(B1,B2) ) )

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;

  while ( scanf ( "%lf%lf%lf%lf%lf%lf%lf%lf",
            &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2 ) == 8 )
  {
    puts ( INTERSECT( xa1, xa2, xb1, xb2 )
        && INTERSECT( ya1, ya2, yb1, yb2 )
         ? "YES"
         : "NO" );
  }

  return ( 0 );
}

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

int main(){
    int i, j, r, c, x[101][101]={};
    cin >> r >> c;
    for (i = 0; i < r; i++){
        for (j = 0; j < c; j++){
        cin >> x[i][j];
        x[i][c] += x[i][j];
        x[r][j] += x[i][j];
        x[r][c] += x[i][j];
        }
    }

    for (i = 0; i < r+1; i++){
        cout << x[i][0];
        for (j = 1; j < c+1; j++){
            cout << " " << x[i][j];
        }
        cout << endl;
    }
        return 0;
}


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

int A[100005];
int B[100005];

int main(void){
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    long long ans = 0;
    int allowed_bits = K;
    for (int i = 0; i < N; i++) {
        if (((allowed_bits | A[i]) ^ allowed_bits) == 0) ans += B[i];
    }
    for (int i = 0; i < 30; i++) {
        if (((1 << i) & K) == 0) continue;
        allowed_bits = (K - (1 << i)) | ((1 << i) - 1);
        
        long long sum = 0;
        for (int j = 0; j < N; j++) {
            if (((allowed_bits | A[j]) ^ allowed_bits) == 0) sum += B[j];
        }
        ans = max(sum, ans);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    s = r.readLine();

    int c = 0;
    for(int i = 0; i <= n - 3; i++)
    {
      if(s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C')
        c++;
    }

    System.out.println(c);
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}


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

int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////
    int P,Q,R,M;

    cin>>P>>Q>>R;

    cout<<P+Q+R-max({P,Q,R})<<endl;

    return 0;
}


Measured memory_bytes: 256
// Package main provides
//
// File:  main.go
// Author: ymiyamoto
//
// Created on Tue Feb  5 12:38:52 2019
//
package main

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

type graph [][]int

var N, K int

var sc = bufio.NewScanner(os.Stdin)

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

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

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

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

func in(x, y int) bool {
	return 0 <= x && x < 2*K && 0 <= y && y < 2*K
}

func inRect(x, y int) bool {
	return in(x, y) || in(x+K-1, y+K-1) || in(x-1, y+K-1) || in(x+K-1, y-1)
}

func rect(x, y int, g graph) int {
	if !inRect(x, y) {
		return 0
	}

	tx := min(x+K-1, len(g)-1)
	ty := min(y+K-1, len(g)-1)
	nums := g[tx][ty]
	if in(x-1, y-1) {
		nums += g[x-1][y-1]
	}

	if in(x-1, ty) {
		nums -= g[x-1][ty]
	}

	if in(tx, y-1) {
		nums -= g[tx][y-1]
	}
	return nums
}

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

	N, K = nextInt(), nextInt()

	g := make(graph, 2*K)
	for i := range g {
		g[i] = make([]int, 2*K)
	}

	for i := 0; i < N; i++ {
		x, y := nextInt(), nextInt()
		s := nextString()
		x %= 2 * K
		y %= 2 * K
		if s == "B" {
			x += K
			x %= 2 * K
		}
		g[x][y]++
	}

	for i := range g {
		for j := range g[i] {
			if j > 0 {
				g[i][j] += g[i][j-1]
			}
		}
	}

	for i := range g[0] {
		for j := range g {
			if j > 0 {
				g[j][i] += g[j-1][i]
			}
		}
	}

	ans := 0
	for i := 0; i < len(g); i++ {
		for j := 0; j < len(g); j++ {
			nums := rect(i, j, g)
			nums += rect(i-K, j+K, g)
			nums += rect(i+K, j-K, g)
			nums += rect(i+K, j+K, g)
			nums += rect(i-K, j-K, g)
			nums += rect(i-2*K, j, g)
			nums += rect(i, j-2*K, g)
			nums += rect(i-2*K, j-2*K, g)
			ans = max(ans, nums)
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 37120
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  string a,b;
  cin >> a;
  cin >> b;
  
  int ans=0;
  
  for (int i=0; i<a.length(); i++) {
  	if (a[i] != b[i]) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main()
{
    //freopen("test.in","r",stdin);
    //freopen("test.ok","w",stdout);
    int h;
    int n;
    int b=0;
    cin >> h >> n;
    int a[n];
    for (int i=0;i<n;i++) 
    {
        cin >> a[i];
        b=b+a[i];
    }
    if (b>=h) cout << "Yes";
    else  cout << "No";
}


Measured memory_bytes: 640
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // exit()
#define N_LIST 1000000

typedef struct list_tbl
{
	int key;
	int prev;
	int next;
} list_t;

int lineno;
list_t list[N_LIST];
int ix;
int head;
int tail;
int room;

void
cleanup(int ecode)
{
	exit(ecode);
}

void
insert(int key)
{
	int l;

	if (room == 0)
	{
		if (ix >= N_LIST)
		{
			fprintf(stderr, "line %d: List overflow. size%d\n", lineno, N_LIST);
			cleanup(1);
		}

		l = ix++;
	}
	else
	{
		l = room;
		room = list[l].next;
	}

	list[l].key = key;
	list[l].next = head;
	int next = head;
	head = l;

	if (next == -1)
	{
		list[l].prev = tail;
		tail = l;
	}
	else
	{
		list[l].prev = list[next].prev;
		list[next].prev = l;
	}
}

void
delete(int key)
{
	int next;
	int* pnext;
	int l;

	pnext = &head;
	for (l = head; l != -1 && list[l].key != key; l = list[l].next)
		pnext = &list[l].next;

	if (l == -1)
		return;

	next = list[l].next;
	*pnext = next;

	if (next == -1)
		tail = list[l].prev;
	else
		list[next].prev = list[l].prev;

	list[l].next = room;
	room = l;
}

void
delete_first()
{
	int t = head;
	head = list[head].next;
	if (head == -1)
		tail = -1;
	else
		list[head].prev = -1;

	list[t].next = room;
	room = t;
}

void
delete_last()
{
	int t = tail;
	tail = list[tail].prev;
	if (tail == -1)
		head = -1;
	else
		list[tail].next = -1;

	list[t].next = room;
	room = t;
}

int
main(int argc, char** argv)
{
	char command[15];
	int x = 0;
	int n = 0;
	int l;
	int i;

	head = -1;
	tail = -1;
	room = 0;
	ix = 0;

	scanf("%d", &n);
	lineno = 0;
	for (i = 0; i < n; ++i)
	{
		lineno++;
		scanf("%s", command);
		switch (command[0])
		{
		case 'i':
			scanf("%d", &x);
			insert(x);
			break;

		case 'd':
			if (command[6] == 'F')
				delete_first();

			else if (command[6] == 'L')
				delete_last();

			else
			{
				scanf("%d", &x);
				delete(x);
			}

			break;
		}
	}

	const char* sep = "";
	for (l = head; l != -1; l = list[l].next)
	{
		printf("%s%d", sep, list[l].key);
		sep = " ";
	}

	printf("\n");
	return 0;
}

Measured memory_bytes: 12320
S = gets.chomp.split('')
ans = []
n = S.size
S.each_with_index do |e, i|
  if i + 1 < n && e == S[i + 1]
    (ans = [i + 1, i + 2]) && break
  elsif i + 2 < n && e == S[i + 2]
    (ans = [i + 1, i + 3]) && break
  end
end
puts (ans.empty? ? '-1 -1' : ans.join(' '))


Measured memory_bytes: 6908
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws Exception {
		FastScanner scanner = new FastScanner(System.in);
		PrintWriter printWriter = new PrintWriter(System.out);

		int size = (int) scanner.nextInt();
		int kinds = (int) scanner.nextInt();

		int[] numsArr = scanner.nextIntArray(size);
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < numsArr.length; i++) {
			if (!map.containsKey(numsArr[i])) {
				map.put(numsArr[i], 1);
			} else {
				map.put(numsArr[i], map.get(numsArr[i]) + 1);
			}
		}

		int difference = map.size() - kinds;
		if (difference <= 0) {
			printWriter.printf("%d\n", 0);
		}else{
			Object[] arr = map.values().toArray();
			Arrays.sort(arr);
			int sum = 0;
			for (int i = 0; i < difference; i++) {
				int tmp = (int) arr[i];
				sum +=tmp;
			}
			printWriter.printf("%d\n", sum);
		}
		printWriter.close();
	}

	static class FastScanner {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public long nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = (int) nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}


Measured memory_bytes: 55192
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x[5];
    int ans;
    for(int i =0;i<5;i++){
   		cin>>x[i];
        if(x[i]==0)
        ans=i;
    }   
    cout<<ans+1<<"\n";
	return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>


using namespace std;

int main(){
    long count = 0, pre_count = 0, answer = 0;
    char inequality;
    string S;
    cin >> S;
    int N = (int)(S.length());
    inequality = S[0];
    for(int i = 1; i < N; i++){
        if(S[i] == inequality){ 
            count++;
            answer += count;
        }
        else {
            if(inequality == '>') answer += max(pre_count, count)+1;
            pre_count = count;
            count = 0;
            inequality = S[i];
        }
    }
    if(inequality == '>') answer += max(pre_count, count)+1;
    else answer += count+1;
    cout << answer << endl;
}

Measured memory_bytes: 900
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

struct edge {
    int m_to;
    ll m_s;
    edge(int to, ll s) : m_to(to), m_s(s) {}
};

int N, M;
vector<vector<edge> > G;
vll K;
bool Bi;
bool OK;
vi Co;
ll Dif;

void execute(int i) {
    for (int j = 0; j < G[i].size(); ++j) {
        if (Co[G[i][j].m_to] == -1) {
            Co[G[i][j].m_to] = 1 - Co[i];
            K[G[i][j].m_to] = G[i][j].m_s - K[i];
            execute(G[i][j].m_to);
        } else {
            if (Co[G[i][j].m_to] != 1 - Co[i]) {
                Bi = false;
            }
            if (K[G[i][j].m_to] != G[i][j].m_s - K[i]) {
                OK = false;
                Dif = G[i][j].m_s - K[i] - K[G[i][j].m_to];
                if (Co[i] == 1) {
                    Dif *= -1;
                }
            }
        }
    }
}

int main(int argc, const char * argv[]) {
    cin >> N >> M;
    G = vector<vector<edge> >(N);
    for (int m = 0; m < M; ++m) {
        int u, v;
        ll s;
        cin >> u >> v >> s;
        u--; v--;
        G[u].push_back(edge(v, s));
        G[v].push_back(edge(u, s));
    }
    
    Bi = true;
    OK = true;
    K = vll(N);
    Co = vi(N);
    fill(Co.begin(), Co.end(), -1);
    
    K[0] = 0;
    Co[0] = 0;
    
    execute(0);
    
    if (Bi) {
        if (!OK) {
            cout << 0 << endl;
        } else {
            ll min[2] = {INFLL, INFLL};
            for (int i = 0; i < N; ++i) {
                if (min[Co[i]] > K[i]) min[Co[i]] = K[i];
            }
            if (min[1] + min[0] - 1 >= 1) {
                cout << min[1] + min[0] - 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    } else {
        OK = true;
        if (Dif % 2 != 0) {
            cout << 0 << endl;
            return 0;
        }
        fill(Co.begin(), Co.end(), -1);
        K[0] = Dif / 2;
        Co[0] = 0;
        execute(0);
        if (OK) {
            for (int i = 0; i < N; ++i) {
                if (K[i] <= 0) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}


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


//typedef  long long ll;
using ll = long long;
using ld = long double;
using uint = unsigned int ;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define endl "\n"
#define ioss ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
//#define all(x) x.begin(),x.end();
//#define fi first
//#define se second

double startTime;
double getCurrentTime()
{
    return ((double)clock()-startTime)/CLOCKS_PER_SEC;
}

int gcd(int a,int b)
{
 if(a==1||b==1)return 1;
  else if(b==0)return a;
  else if(a==0)return b;
  else return gcd(b%a,a);

}

void solve()
{
    int n;cin>>n;int flag=0;ll ans=0;
 for(int i=1;i<=n;i++)
 {
   for(int j=1;j<=n;j++)
   {
     for(int k=1;k<=n;k++)
     {
       int temp=gcd(i,j);
       temp=gcd(temp,k);
       ans=ans+temp;
     }
   }
 }
  cout<<ans<<endl;
}


int main()
{
    startTime=(double)clock();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt,"w",stdout);

    ioss
    //int t;scanf("%d",&t);
   // while(t--)
            solve();
    return 0;
}


Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.1415926535897932384626;
int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double S = x / a;
	double ans;
	if (S <= (a*b) / 2) {
		double c = (2 * S) / b;
		ans = atan(b / c);
	}
	else {
		ans = atan((2 * b - (2 * S) / a) / a);
	}
	printf("%.15lf\n", ans / (2 * PI) * 360);
}

Measured memory_bytes: 256
L = input()
n = len(L)
onecnt = 0
ans = 0

MOD = 10 ** 9 + 7
for i in range(n):
    if(L[i] == '0'):continue
    onecnt += 1
    rest = n - i - 1
    ans += pow(2, onecnt-1, MOD) * pow(3, rest, MOD) % MOD
    ans %= MOD

ans += pow(2, onecnt, MOD)
    
print(ans % MOD)

Measured memory_bytes: 3316
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> adj(N);
  REP(i, N) { adj[i].reserve(M); }
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  deque<tuple<int, int, int>> q;
  q.emplace_back(0, 0, -1);
  int INF = N + 10;
  vector<int> dist(N, INF);
  vector<int> prev(N, -1);
  int cnt = 0;
  while (!q.empty()) {
    auto [l, node, pnode] = q.front();
    q.pop_front();
    if (dist[node] <= l) continue;
    dist[node] = l;
    prev[node] = pnode;
    ++l;
    for (auto&& nxt : adj[node]) {
      if (dist[nxt] > l) {
        q.emplace_back(l, nxt, node);
      }
    }
  }
  cout << "Yes\n";
  for (int i = 1; i < N; ++i) {
    cout << (prev[i] + 1) << "\n";
  }
}


Measured memory_bytes: 559492
q,h,s,d=map(int,input().split())
n=int(input())
l=min(q*n*4,h*n*2,s*n,d*n//2)
if l != d*n//2:
    print(l)
else:
    m=min(q*4,h*2,s)
    print(int((d*(n-1)//2)+m) if n%2==1 else int(l))

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vll a(3*n);
  vll su(3*n);
  ll sum = 0;
  REP(i, 3*n) {
    cin >> a[i];
  }

  sort(ALL(a), greater<ll>());
  for(int i = 1;i <= 2*n-1;i += 2) {
    sum += a[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 4992