akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric> 
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1e9 + 5;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
///////////////////////////////////////////////////////////////////////

int n;
string str;

int main() {
    scanf("%d", &n);
    cin >> str;
    int res = 0;

    for (int i = 0; i < str.length() - 2; ++i) {
        if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C') ++res; 
    }
    printf("%d\n", res);
}

Measured memory_bytes: 888
import sys

while 1:
    H,W = map(int, raw_input().split())

    if H == 0 and W == 0:
        break

    for i in range(H):
        for j in range(W):

            if i%2 == 0:
                if j%2 == 0:
                    sys.stdout.write("#")
                else:
                    sys.stdout.write(".")

            if i%2 != 0:
                if j%2 != 0:
                    sys.stdout.write("#")
                else:
                    sys.stdout.write(".")

            if j == W-1:
                print ""

    print ""

Measured memory_bytes: 6452
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	set<int> st;
	for(int i = 0; i < s.size(); ++i) {
		st.insert(s[i] - 'A');
	}
	
	if( st.size() == 2 ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


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

int main()
{
  int N; cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++)
  {
    int A; cin >> A;
    ans += 1 / (double)A;
  }

  printf("%.12f\n", 1/ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {


        //size [n+1, n+1]
        public static int[,] path = new int[0, 0];
        //len = n+1
        public static int[] cost = new int[0];


        public static int dijkstra(int start , int end) {
            cost = Enumerable.Repeat(int.MaxValue, cost.Length).ToArray();
            bool[] visited = new bool[cost.Length];
            cost[start] = 0;

            while (true) {
                //Search min cost. and checked.
                int minC = int.MaxValue;
                int minNode = -1;
                for (int i = 1; i < cost.Length; i++) {
                    if (visited[i]) { continue; }
                    if (minC > cost[i]) { minC = cost[i]; minNode = i; }
                }
                if (minNode == -1 || minNode == end) { break; }
                //Console.WriteLine(minNode + " -cost" + minC);
                visited[minNode] = true;

                //cost reload.
                for (int i = 1; i < cost.Length; i++) {
                    if (visited[i]) { continue; }
                    if (path[minNode, i] > 0) {
                        cost[i] = Math.Min(cost[i], cost[minNode] + path[minNode, i]);
                    }
                }
            }
            return cost[end];
        }
        



        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                //int n = int.Parse(line);
                int n = ints[0]; int k = ints[1];
                if (n == 0) { break; }
                cost = new int[n + 1];
                path = new int[n + 1, n + 1];

                for (int i = 0; i < k; i++) {
                    line = Console.ReadLine();
                    if (line.StartsWith("1")) {
                        ints = line.Split(' ').Select(int.Parse).ToArray();
                        if (path[ints[1], ints[2]] != 0 && path[ints[1], ints[2]] < ints[3]) {
                            continue;
                        }
                        path[ints[1], ints[2]] = ints[3];
                        path[ints[2], ints[1]] = ints[3];
                    }
                    else {
                        ints = line.Split(' ').Select(int.Parse).ToArray();
                        int c = dijkstra(ints[1], ints[2]);
                        if (c == int.MaxValue) {
                            Console.WriteLine(-1);
                        }
                        else {
                            Console.WriteLine(c);
                        }
                    }
                }

            }
            
        }

        
    }

    

    
}

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

void trace(vector<int> A, int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << ' ';
    cout << A[i];
  }
  cout << endl;
}

void bubbleSort(vector<int> A, int N) {
  int flag = 1;
  int count = 0;
  while (flag) {
    flag = 0;
    for (int i = 1; i < N; i++) {
      if (A[i-1] > A[i]) {
        int temp = A[i];
        A[i] = A[i-1];
        A[i-1] = temp;
        flag = 1;
        count++;
      }
    }
  }
  trace(A, N);
  cout << count << endl;
}
  
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  bubbleSort(A, N);
}



Measured memory_bytes: 3144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        sc.close();
        if(x==3 || x==5 || x==7){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
    
}

Measured memory_bytes: 20692
#include <bits/stdc++.h>
using namespace std;
int H, W; string s[109];
int main() {
	cin >> H >> W;
	for(int i = 0; i < H; i++) cin >> s[i];
	int ret = 0;
	for(int i = 1; i < H; i++) {
		for(int j = 0; j < W; j++) {
			if(s[i][j] != '-') continue;
			bool flag = true;
			if(j != 0 && s[i][j - 1] != '-') flag = false;
			if(j + 1 != W && s[i][j + 1] != '-') flag = false;
			for(int k = -1; k <= 1; k++) {
				for(int l = -1; l <= 1; l++) {
					int ty = i + k, tx = j + l;
					if(0 <= tx && tx < W && 0 <= ty && ty < H && s[ty][tx] == 'x') flag = false;
				}
			}
			if(flag) ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    
    int a,b;
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int x, y;
  scanf("%d %d", &x, &y);
  if(4*x < y){
    printf("No");
  }else if(2*x > y){
    printf("No");
  }else if(y%2 != 0){
    printf("No");
  }else{
    printf("Yes");
  }
}

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

struct dat {
  int x, y;
  dat(int _x, int _y) : x(_x), y(_y) {}
  bool operator==(const dat& r) { return x == r.x && y == r.y; }
};

int d[4] = {0, 1, 0, -1};
int h, w;
vector<string> s;
queue<dat> qu;

bool isvalid(dat& now) {
  return now.x >= 0 && now.x < h && now.y >= 0 && now.y < w &&
         s[now.x][now.y] == '.';
}
bool solve();

int main() {
  while (1) {
    cin >> h >> w;
    if (h + w == 0) break;
    s.resize(h);
    for (int i = 0; i < h; ++i) cin >> s[i];
    if (solve())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

bool solve() {
  for (int x = 0; x < h; ++x)
    for (int y = 0; y < w; ++y) {
      dat ng = {x, y};
      vector<dat> v = {dat(0, 0), dat(h - 1, 0), dat(h - 1, w - 1),
                       dat(0, w - 1)};
      for (int t = 0; t < 4; ++t) {
        dat st = v[t], go = v[(t + 1) % 4];
        if (st == ng || go == ng) continue;
        vector<vector<bool>> reached(h, vector<bool>(w, 0));
        qu.push(st);
        reached[st.x][st.y] = 1;
        while (qu.size()) {
          dat now = qu.front();
          qu.pop();
          for (int i = 0; i < 4; ++i) {
            dat nextp = now;
            nextp.x += d[i];
            nextp.y += d[1 ^ i];
            if (!isvalid(nextp) || reached[nextp.x][nextp.y] || nextp == ng)
              continue;
            reached[nextp.x][nextp.y] = 1;
            qu.push(nextp);
          }
        }
        if (!reached[go.x][go.y]) return 0;
      }
    }
  return 1;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prarr(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 1e16+10;
const int MOD = 1e9+7;
const int MAXN = 2e5+10;

int main(){
    int k,x;
    cin>>k>>x;
    for(int i=-k+1;i<k;i++){
        cout<< x+i<<" ";
    }

    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void check()
{
    if(false)
    cout<<"C"<<endl;
}
#define ll long long
int main() {
   long long  i, x, j;
   long long y, 	z, k, n;
	string s, t;
	cin >> s >> t;
	z = s.size();
 check();
	for(i=0;i<s.size();i+= 1) {
		if (i + t.size() > s.size())
		{
		     check();
		break;
		}
		else
		{
		    check();
		}
		k = 0;
		for(j=0;j<t.size(); j+=1) { check();
			k = k+(s[i + j] != t[j]);
		}
		z = min(z, k);
	}
  check();
	cout<<z<<"\n";
}

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

int32_t main(){
	int n;
	cin>>n;
	int arr[n];
	for(int& i:arr) cin>>i;

	vector<vector<int>>dp(n,vector<int>(n,LONG_MAX)) ;

	auto sum = [&](int l,int r){
		int res = 0 ;
		for(int i=l;i<=r;i++) res += arr[i] ;
		return res ;
	};

	for(int l=n-1;l>=0;l--){
		for(int r=l;r<n;r++){
			if(l==r) dp[l][r] = 0 ;
			int s = sum(l,r) ;
			for(int k=l;k<r;k++){
				dp[l][r] = min(dp[l][r],dp[l][k]+dp[k+1][r]+s);
			}
		}
	}

	cout << dp[0][n-1] << endl ;

	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    int D, G;
    cin >> D >> G;
    vector<long long> p(D), c(D);

    for(int i=0; i<D; i++)
        cin >> p[i] >> c[i];

    long long ans = 1LL<<60;
    for(int i=0; i<(1<<D); i++){
        vector<int> vec;
        long long sc = 0;
        long long cnt = 0;
        for(int j=0; j<D; j++){
            if(i & (1<<j)){
                sc += 100 * p[j] * (j+1) + c[j];
                cnt += p[j];
            }else vec.push_back(j);
        }
        vector<long long> vec2;
        for(auto j : vec){
            for(int k=0; k<p[j]; k++){
                vec2.push_back(j+1);
            }
        }
        sort(vec2.begin(), vec2.end(), greater<long long>());
        for(int j=0; j<vec2.size(); j++){
            if(sc >= G) break;
            sc += 100 * vec2[j];
            cnt++;
        }
        if(sc >= G) ans = min(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int a,b,c; cin >> a >> b >> c;
	cout << max(a+10*b+c,max(10*a+b+c,10*c+a+b)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b ;
  cin >> a >> b ;
 
  	if(a % 2 == 0 || b % 2 ==0) {
      cout << "Even" ;
    }
  else{
  	cout << "Odd" ;
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int a, b;

    cin >> a >> b;

    if(a % 2 != b % 2){
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n,x,sum=0,ans=1;
	scanf("%d%d",&n,&x);
	int l[n];
	for(int i=0;i<n;i++){
		scanf("%d",&l[i]);
		sum+=l[i];
		if(sum<=x)
			ans+=1;
	}
	printf("%d",ans);
	return 0;
}


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

int main()
{
	vector<int>a(2);
	while (1) 
	{
		vector<int>a(2);
		cin >> a[1] >> a[0];
		if (a[0] == 0 && a[1] == 0)break;
		int o = 0;
		sort(a.begin(), a.end());
		while (1)
		{
			sort(a.begin(), a.end());
			if (a[1] % a[0] == 0)break;
			a[1] = a[1] % a[0];
			o++;
		}
		cout << a[0]<<" "<<o+1<<endl;
	}
}

Measured memory_bytes: 3084
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//
        int A, B, K;
        cin >> A >> B >> K;

        int ans;
        vector<int> vec;
        for (int i = 1; i < A + 1; i++)
        {
                if (A % i == 0)
                {
                        vec.push_back(i);
                }
        }
        sort(vec.begin(), vec.end(), greater<int>());
        int cnt = 0;
        for (auto itr : vec)
        {
                if (B % itr == 0)
                {
                        cnt++;

                        if (cnt == K)
                        {
                                cout << itr << endl;
                                return 0;
                        }
                }
        }

        return 0;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

template <typename T>
T extgcd(T a, T b, T &x, T &y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    T d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

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

    int a, b, x, y; cin >> a >> b;
    extgcd(a, b, x, y);
    cout << x << ' ' << y << endl;
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> value(30);
  vector<int> cost(30);
  for(int i = 0; i < N; i++){
    cin >> value.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> cost.at(i);
  }
  vector<int> ans(30);
  for(int i = 0; i < N; i++){
    ans.at(i) = value.at(i) - cost.at(i);
  }
  
  int res;
  res = 0;
  for(int i = 0; i < N; i++){
    if(ans.at(i) > 0){
      res = res + ans.at(i);
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 256
using System;

namespace abc160_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            int happy = 0;
            if (x >= 500)
            {
                happy = x / 500 * 1000;
                x = x % 500;
                happy = happy + (x / 5 * 5);
                Console.WriteLine(happy);
            }
            else
            {
                Console.WriteLine(x / 5*5);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<queue>
#include<string>
using namespace std;

int main(){
  int n,q;cin >> n >> q;
  queue<pair <string,int> > nt;
  for(int i=0;i<n;i++){
    string s;int t;cin >> s >> t;
    nt.push(make_pair(s,t));
  }
  int tim=0;
  while(nt.size()!=0){
    if(nt.front().second<=q){
      tim+=nt.front().second;
      cout << nt.front().first << ' ' << tim << endl;
      nt.pop();
    }else{
      pair <string,int> p;p=nt.front();p.second-=q;
      tim+=q;
      nt.pop();nt.push(p);
    }
  }
}



Measured memory_bytes: 6228
#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int n,i,ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
	for(i=30;i>=1;i--)
	{
		int p=0;
		int q=n-1;
		int k=1<<i;
		while(p<q)
		{
			if(a[p]+a[q]==k)
			{
				ans++;
				a[p++]=0;
				a[q--]=0;
			}
			else if(a[p]+a[q]<k)
				p++;
			else
				q--;
		}
    	int len=0;
    	for(p=0;p<n;p++)
		{
			if(a[p])
				a[len++]=a[p];
		}
		n=len;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>  P;
int w,h,n,ix,iy,ox,oy;

bool kab[60][60][4];

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

int cal(){
  queue<P> q;

  int cost[60][60];

  for(int i=0;i<60;i++)
    for(int j=0;j<60;j++)cost[i][j]=1e9;
  cost[iy][ix]=0;
  q.push(P(ix,iy));
  
  while(!q.empty()){
    int x=q.front().first,y=q.front().second;
    q.pop();
    if(x==ox&&y==oy)return cost[y][x];
    
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx<0||w<=nx||ny<0||h<=ny||kab[y][x][i]||cost[ny][nx]!=1e9)continue;
      q.push(P(nx,ny));
      cost[ny][nx]=cost[y][x]+1;
    }
      
  }
  
  return 0;
}


int main(){
  cin>>w>>h>>n;
  for(int i=0;i<n;i++){
    int sx,sy,ddx,ddy;
    cin>>sx>>sy>>ddx>>ddy;

    if(sx==ddx)
      for(int i=min(sy,ddy);i<max(ddy,sy);i++){
	if(0<=sx-1)kab[i][sx-1][0]=1;
	if(sx<w)kab[i][sx][2]=1;
      }
    else
      for(int i=min(sx,ddx);i<max(ddx,sx);i++){
	if(0<=sy-1)kab[sy-1][i][1]=1;
	if(sy<h)kab[sy][i][3]=1;
      }
  }
  cin>>ix>>iy>>ox>>oy;
  
    for(int i=0;i<w;i++){
      kab[0][i][3]=1;
      kab[h-1][i][1]=1;
    }
    
    for(int i=0;i<h;i++){
      kab[i][0][2]=1;
      kab[i][w-1][0]=1;
    }		  

    int d=cal(),ans=0;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	for(int k=0;k<4;k++){
	  if(kab[i][j][k])continue;
	  kab[i][j][k]=1;
	  ans=max(ans,cal()-d);
	  kab[i][j][k]=0;
      }    
  
  cout<<ans<<endl;

  return 0;  
}

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

int main()
{
  int N;
  string s;
  int Rcount=0;
  int Bcount=0;
  cin>>N>>s;
  for(int i;i<N;i++){
    if(s.at(i)=='R')
      Rcount++;
    else
      Bcount++;}
  if(Rcount>Bcount)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

void main() {
	auto N = to!int( split(readln())[0] );
	real result = 0;
	foreach (i; 0 .. N) {
		auto data = split(readln());
		auto x = to!real(data[0]), u = data[1];
		u == "JPY" ? (result += x) : (result += 380000.0 * x);
	}
	writeln(result);
}

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


int a[100004];
int b[100004];
int main() {
	int i, n;
	cin>>n;
	for(i=1;i<=n+1;i++) cin>>a[i];
	for(i=1;i<=n;i++) cin>>b[i];
	long long ans = 0;
	for(i=1;i<=n;i++){
		ans += min(b[i], a[i] + a[i+1]);
		if(b[i] > a[i])
			a[i+1]-=min(a[i+1], b[i] - a[i]);
	}
	cout<<ans<<"\n";
}

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

int main(){
  vector<char> station(52);
  for(int i = 0;i < 26;i++){
	station[i] = 'a'+i;
  }
  for(int i = 26;i < 52;i++){
	station[i] = 'A'+i - 26;

  }
  
  int n;
  while(cin >> n && n){
	vector<int> key(n,0);
	for(int i = 0;i < n;i++){
	  cin >> key[i];
	}
	string str;
	cin >> str;
	int key_cnt = 0;
	for(int i = 0;i < str.size();i++){
	  if(key_cnt == key.size())key_cnt = 0;
	  int c = 0;
	  for(int j = 0;j < station.size();j++){
		if(station[j] == str[i]){
		  c = j;
		  break;
		}
	  }

	  if(c-key[key_cnt] < 0)cout <<  station[c-key[key_cnt]+52];
	  else cout << station[c-key[key_cnt]];
	  key_cnt++;
	}
	cout << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 1212
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

class Book:

    def __init__(self, info):
        self.cost = info[0]
        self.alg = info[1:]


class Solver:

    def __init__(self, books, x, m):
        self.books = books
        #print('self.books') # debug
        #print(self.books) # debug
        #print('self.books[0].cost') # debug
        #print(self.books[0].cost) # debug
        self.x = x
        self.m = m
        self.cost = 0
        self.skills = []
        self.ans = math.inf

    def run(self):
        for buy_book_bit in range(2 ** 12):
            self.shopping(buy_book_bit)
            if self.check():
                #print('self.cost') # debug
                #print(self.cost) # debug
                self.ans = min(self.ans, self.cost)
                #print('self.ans') # debug
                #print(self.ans) # debug
        return self.ans

    def check(self):
        for s in self.skills:
            if not (s >= self.x):
                return False
        return True

    def shopping(self, buy_book_bit):
        self.reset()
        for i, book in enumerate(self.books):
            #print('book') # debug
            #print(book) # debug
            key = 1 << i
            if key & buy_book_bit:
                self.buy(book)

    def reset(self):
        self.cost = 0
        self.skills = [0] * self.m

    def buy(self, book):
        self.cost += book.cost
        for i, a in enumerate(book.alg):
            self.skills[i] += a





if __name__ == '__main__':
    n, m, x = list(map(int, input().split()))
    books = []
    for i in range(n):
        info = list(map(int, input().split()))
        books.append(Book(info))
    ans = Solver(books, x, m).run()
    #print('ans') # debug
    if ans == math.inf:
        print(-1)
    else:
        print(ans)


    #print('\33[32m' + 'end' + '\033[0m') # debug


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

int main()
{
	int n, t;
	cin >> n >> t;
	map<int, int> m;
	vector<vector<int>> v(n, vector<int>(2));
	for (int i = 0; i < n; i++) {
		cin >> v[i][0] >> v[i][1];
		m[v[i][0]] = v[i][1];
	}
	bool f = false;
	int cost = 0;
	for (auto itr = m.begin(); itr != m.end(); itr++) {
		if (itr->second <= t) {
			cost = itr->first;
			f = true;
			break;
		}
	}
	if (f) {
		cout << cost << endl;
	}
	else {
		cout << "TLE" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long dp[1<<17];
 
int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);

  int n, W; cin >> n >> W;
  fill(dp + 1, dp + W + 1, -(1LL<<50));

  for (int i = 0; i < n; ++i) {
    int w, v; cin >> w >> v;
    for (int j = W; j >= w; --j) {
      dp[j] = max(dp[j], dp[j - w] + v);
    }
  }
  cout << *max_element(dp, dp + W + 1) << '\n';
}



Measured memory_bytes: 1024
#include<cstdio> 
#include<algorithm>
#include<map>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
map<int,int> f;
int a[maxn],b[maxn],c[maxn],d[maxn],fa[maxn*2];
int i,j,k,l,t,n,m,tot,ans;
int getfa(int x){
    return fa[x]==x?x:fa[x]=getfa(fa[x]);
}
int main(){
    scanf("%d",&n);
    fo(i,1,n) scanf("%d",&a[i]);
    fo(i,1,n) scanf("%d",&b[i]);
    t=0;
    fo(i,1,n) t^=a[i];
    a[n+1]=t;
    t=0;
    fo(i,1,n) t^=b[i];
    b[++n]=t;
    fo(i,1,n) c[i]=a[i],d[i]=b[i];
    sort(c+1,c+n+1);
    sort(d+1,d+n+1);
    fo(i,1,n+1)
        if (i>n||c[i]!=d[i]) break;
    if (i<=n){
        printf("-1\n");
        return 0;
    }
    fo(i,1,n)
        if (a[i]!=b[i]||i==n){
            if (i<n) ans++;
            if (!f[a[i]]) f[a[i]]=++tot;
            if (!f[b[i]]) f[b[i]]=++tot;
        }
    if (!ans){
        printf("0\n");
        return 0;
    }
    fo(i,1,tot) fa[i]=i;
    fo(i,1,n)
        if (a[i]!=b[i]) fa[getfa(f[a[i]])]=getfa(f[b[i]]);
    fo(i,1,tot)
        if (fa[i]==i) ans++;
    printf("%d\n",ans-1);
}

Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
set<ll> sll;
//set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
map<ll,ll> mp;
//deque<ll> deq;
vector<ll> vll;
//ll num[ten52];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    ll m,n,i,j,k=0,d,pre=0,now;
    string s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>m;
        if(sll.find(m)==sll.end())
        {
            sll.insert(m);
            vll.pb(m);
        }
        mp[m]++;
        if(mp.size()>3)
        {
            cout<<"No";
            return 0;
        }
    }
    sort(all(vll));
    if(sll.size()==1)
    {
        if(vll[0]!=0) cout<<"No";
        else cout<<"Yes";
    }
    else if(sll.size()==2 && n%3==0)
    {
        if(sll.find(0)==sll.end())
            cout<<"No";
        else
        {
            if(mp[vll[1]]==2*mp[vll[0]]) cout<<"Yes";
            else cout<<"No";
        }
    }
    else if(sll.size()==3 && n%3==0)
    {
        if(((vll[0]^vll[1])^vll[2])!=0)
        {
            cout<<"No";
            return 0;
        }
        if(mp[vll[0]]==mp[vll[1]]&&mp[vll[0]]==mp[vll[2]])
            cout<<"Yes";
        else
            cout<<"No";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=29,INF=1<<30;

int V,cmp[MAX];
vector<int> G[MAX],rG[MAX],vs;//vsがトポソの逆順になってる
bool used[MAX];

void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(used[G[v][i]]==0) DFS(G[v][i]);
    }
    vs.push_back(v);
}

void rDFS(int v,int k){
    used[v]=1;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(used[rG[v][i]]==0) rDFS(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(used[v]==0) DFS(v);
    }
    
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(used[vs[i]]==0) rDFS(vs[i],k++);
    }
    return k;
}

void init(){
    for(int i=0;i<26;i++){
        G[i].clear();
        rG[i].clear();
    }
    V=26;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        init();
        vector<string> S(N);
        for(int i=0;i<N;i++) cin>>S[i];
        
        bool ok=true;
        
        for(int i=1;i<N;i++){
            if(S[i-1].size()==S[i].size()){
                for(int j=0;j<S[i].size();j++){
                    if(S[i-1][j]!=S[i][j]){
                        add_edge(S[i-1][j]-'a',S[i][j]-'a');
                        break;
                    }
                }
            }else if(S[i-1].size()<S[i].size()){
                for(int j=0;j<S[i-1].size();j++){
                    if(S[i-1][j]!=S[i][j]){
                        add_edge(S[i-1][j]-'a',S[i][j]-'a');
                        break;
                    }
                }
            }else{
                for(int j=0;j<S[i].size();j++){
                    if(S[i-1][j]!=S[i][j]){
                        add_edge(S[i-1][j]-'a',S[i][j]-'a');
                        break;
                    }
                    
                    if(j+1==S[i].size()) ok=false;
                }
            }
        }
        
        int k=scc();
        
        if(k==26&&ok) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}




Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>

char a[55], b[55];
int lena, lenb;

bool chk(int det) {
	for(int i=0;i<lenb;i++)
		if(a[det+i] != '?' && a[det+i] != b[i]) return false;
	return true;
}

int main() {
	scanf("%s%s", a, b);
	lena = strlen(a); lenb = strlen(b);
	int p=-1;
	for(int i=lena-lenb;i>=0 && p<0;i--) {
		if(chk(i)) p = i;
	}
	if(p<0) puts("UNRESTORABLE");
	else {
		for(int i=0;i<lenb;i++)
			a[p+i] = b[i];
		for(int i=0;i<lena;i++)
			if(a[i]=='?') a[i] = 'a';
		printf("%s\n", a);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  cpp_int sum{};
  for (int a = 1; a <= N; ++a) {
    for (int b = 1; b <= N; ++b) {
      for (int c = 1; c <= N; ++c) {
        auto d = boost::gcd(a, b);
        auto e = boost::gcd(d, c);
        sum += e;
      }
    }
  }
  auto ans = sum;
  cout << ans << CRLF;
  return;
}

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

  gErr = 0;

  solve();

  return gErr;
}


Measured memory_bytes: 3692
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
import java.util.Random;
import java.util.Map;
import java.util.HashMap;
 
class Main{
        public static void main(String args[]){
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int K = sc.nextInt();
                int n;
                
                Map<Integer,Integer> map = new HashMap<Integer,Integer>();
                for(int i=0; i<N; i++){
                    n = sc.nextInt();
                    if(map.containsKey(n)){
                        map.put(n,map.get(n)+1);
                    }else{
                        map.put(n,1);
                    }
                }
                ArrayList<Integer> value = new ArrayList<Integer>(map.values());
                Collections.sort(value);
                int c=0;
                if(value.size()>K){
                    for(int i=0; i<value.size()-K; i++){
                        c += value.get(i);
                    }
                }
                
                
                
                /*
                ArrayList<Integer> list = new ArrayList<Integer>();
                for(int i=0; i<N; i++){
                    n = sc.nextInt();
                    if(list.indexOf(n)==-1){
                        list.add(n);
                    }
                }
                Collections.sort(list);
                */
                System.out.println(c);
        }
}

Measured memory_bytes: 103000
use std::io::*;

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines().map(|l| l.unwrap());

  let n: u32 = {
    let line = lines.next().unwrap();
    let mut iter = line.split_whitespace().map(|s| s.parse().unwrap());

    iter.next().unwrap()
  };

  let sum_p: u32 = {
    let line = lines.next().unwrap();
    line.split_whitespace().map(|s| s.parse::<u32>().unwrap()).sum()
  };

  let got = (sum_p as f64 / (n + 1) as f64).ceil();

  println!("{}", got);
}



Measured memory_bytes: 5132
D, G = map(int, input().split())
p = [0] * D
c = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())

ans = 1001
import math
for i in range(2**D):
    pp = 0
    t = 0
    b = format(i, "0" + str(D) + "b")
    #print(b)
    for j in range(D):
        pp += (100 * (j + 1) * p[j] + c[j]) * int(b[j])
        t += p[j] * int(b[j])
    if pp >= G:
        ans = min(ans, t)
        continue
    for k in range(D-1, -1, -1):
        if b[k] == "0":
            a = math.ceil((G - pp)//100/(k+1))
            if a < p[k]:
                t += a
                ans = min(ans, t)
                break
            else:
                t += p[k]-1
                pp += 100* (k + 1) *(p[k] - 1)

print(ans)


Measured memory_bytes: 9260
use std::collections::*;
use std::io::*;
use std::*;
macro_rules! get {
    ($($t:tt),*; $n:expr) => {
        {
            let stdin = std::io::stdin();
            let ret = std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
                let line = line.unwrap();
                let mut it = line.split_whitespace();
                _get!(it; $($t),*)
            }).collect::<Vec<_>>();
            ret
        }
    };
    ($($t:tt),*) => {
        {
            let mut line = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut it = line.split_whitespace();
            _get!(it; $($t),*)
        }
    };
}
macro_rules! _get {
    // iterator(splitted input-string) => iterator(output-type)
    ($it:ident; [char]) => {
        _get!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; usize1) => {
        $it.next().unwrap().parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap().parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:ty),+) => {
        ($(_get!($it; $t)),*)
    };
}

fn main() {
    let n = get!(i32);
    let mut v = get!([i32]);
    v.sort_unstable();
    let v: Vec<f64> = v.into_iter().map(|x| x as f64).collect();
    let mut ans: f64 = (v[0] + v[1]) / 2.0;
    for i in 2..n {
        ans = (ans + v[i as usize]) / 2.0;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2140
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n,k,p,d,ans=0;
    cin >>n>>k;
    bool sunuke[100000]={false};
    rep(i,k){
        cin >>d;
        rep(i,d){
            cin >> p;
            sunuke[p-1]=true;
        }
    }
    rep(i,n){
        if(!sunuke[i]){
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3292
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n == 0) return 0;
		int v = -1,x = -1;
		for(int i=0;i<n;i++)
		{
			int a,b,c; cin >> a >> b >> c;
			if(b+c > x)
			{
				v = a; x = b+c;
			}
		}
		cout << v << " " << x << endl;
	}
}

Measured memory_bytes: 1160
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    rep(i, S.size())
    {
        if (S[i] != S[S.size() - 1 - i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[100010];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        ans+=a[i]/2;
        a[i]%=2;
        if(i<n&&a[i]&&a[i+1])
        {
            ans++;
            a[i]--;
            a[i+1]--;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(int argc, char *argv[]) {
    /*     int n = 0;
        int x = 0;
        int i;
        int temp;

        scanf("%d", &n);

        for (i = 0; n > 0; i++) {
            temp += n % 10;
        }

        if(temp % 9 == 0){
            printf("Yes\n");
        }else{
            printf("No\n");
        }
     */

    char s[200010];
    scanf("%s", s);
    int len = strlen(s);
    int sum = 0;

    for (int i = 0; i < len; i++){
        sum += s[i] - '0'; //文字コードで数字の'0'を引いて文字コードのオフセットを除去して数字の差だけ得る
        //printf("%d\n", sum);
    }

    if (sum % 9 == 0) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;
}


Measured memory_bytes: 1832
S = input()

num_5 = ["dream", "erase"]
num_6 = ["eraser"]
num_7 = ["dreamer"]
while len(S) != 0:
    if S[0:7] in num_7:
        if S[5:11] in num_6:
            S = S[5:]
        elif S[5:10] in num_5:
            S = S[5:]
        else:
            S = S[7:]
    elif S[0:6] in num_6:
        if S[5:10] in num_5:
            S = S[5:]
        else:
            S = S[6:]
    elif S[0:5] in num_5:
        S = S[5:]
    else:
        print("NO")
        exit()

print("YES")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    size_t n;
    string s, t;
    cin >> n >> s >> t;

    for(size_t i = 0; i < n + 1; ++ i)
        if(s.substr(i) == t.substr(0, n - i))
        {
            cout << n + i << '\n';
            break;
        }

    return EXIT_SUCCESS;
}


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

using namespace std;

void math_slove()
{
    long long n, negative_cnt = 0;
    cin>>n;
    long long A[n], a_min = LLONG_MAX, sums = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>A[i];
        if(A[i] < 0) negative_cnt++;
        sums += abs(A[i]);
        a_min = min(a_min,abs(A[i]));
    }
    if(negative_cnt%2 == 0) printf("%lld\n", sums);
    else printf("%lld\n", sums - 2ll*a_min);

}

int main()
{
    math_slove();
    //dp_slove();
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <queue>
#include <vector>
#include <utility>
#define INF 0x3FFFFFFF

using namespace std;

typedef pair<int,int> P;
typedef pair<pair<double,int>,P> PP;

int main(void){
	int n, m, s, g, x, y, l, c, i, j, dist[30][30], mspeed[30][30];
	double t[30/*city*/][31/*speed*/][30/*U-turn*/],ans;
	priority_queue<PP,vector<PP>,greater<PP> > que;
	while(1){
		scanf("%d%d",&n,&m);
		if(!n && !m) break;
		scanf("%d%d",&s,&g);
		s--,g--;
		memset(dist,-1,sizeof(dist));
		memset(mspeed,-1,sizeof(mspeed));
		for(i = 0;i < m;i++){
			scanf("%d%d%d%d",&x,&y,&l,&c);
			--x,--y;
			dist[x][y] = l, mspeed[x][y] = c;
			dist[y][x] = l, mspeed[y][x] = c;
		}
		for(i = 0;i < n;i++)
			for(j = 0;j <= 30;j++) for(l = 0;l < n;l++) t[i][j][l] = INF;
		t[s][0][s] = 0;
		que.push(PP(pair<double,int>(0,s),P(0,s)));
		while(que.size()){
			// city speed prev
			x = que.top().first.second,y = que.top().second.first,c = que.top().second.second;
			que.pop();
			for(i = 0;i < n;i++){
				for(j = -1;j <= 1;j++){ // 加減速
					if(dist[x][i] != -1 && mspeed[x][i] >= y + j && y + j > 0 && i != c && t[i][y + j][x] > t[x][y][c] + (double)dist[x][i] / (y + j)){
						t[i][y + j][x] = t[x][y][c] + (double)dist[x][i] / (y + j);
						que.push(PP(pair<double,int>(t[i][y + j][x],i),P(y + j,x)));
					}
				}
			}
		}
		ans = INF;
		for(i = 0;i < n;i++)
			ans>t[g][1][i]?ans=t[g][1][i]:0;
		if(ans != INF)
			printf("%f\n",ans);
		else
			printf("unreachable\n");
	}
	return 0;
}

		

Measured memory_bytes: 1780
import math

menus = [int(input()) for i in range(5)]
m = [math.ceil(k / 10) * 10 for k in menus]


re0 = menus[0] + m[1]+ m[2]+ m[3]+ m[4]
re1 = m[0] + menus[1]+ m[2]+ m[3]+ m[4]
re2 = m[0] + m[1]+ menus[2]+ m[3]+ m[4]
re3 = m[0] + m[1]+ m[2]+ menus[3]+ m[4]
re4 = m[0] + m[1]+ m[2]+ m[3]+ menus[4]
print(min(re0,re1,re2,re3,re4))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s.back() << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define of(i,a,b) for(register int (i)=(a);(i)>=(b);--(i))
#define rd read()
#define maxn 500001
#define ll long long
#define fre(a) freopen("a.in","r",stdin);freopen("a.out","w",stdout);
const int p=998244353;
int read() {int x=0,f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*f;}
void print(int x) { if(x<0){putchar('-');x=-x;}if(x>9)print(x/10);putchar(x%10+'0');}
int qp(int a, int  b) {int ans = 1;for(; b; b >>= 1, a *= a, a %= p) if(b & 1) ans *= a, ans %= p;return ans % p;}
int main() {
    int a=rd,b=rd,ok=0;
    if(a<=8&&b<=8)ok=1;
    puts(ok?"Yay!":":(");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>

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

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

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    int r;
    cin >> r;
    string ans = "AGC";
    if (r < 1200) {
        ans = "ABC";
    } else if (r < 2800) {
        ans = "ARC";
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> v(n,0);
	for(int &i:v){
		scanf("%d",&i);
	}
	vector<int> freq_odd(1e5+3,0);
	vector<int> freq_even=freq_odd;
	vector<int> mx_freq_odd(2,0);
	vector<int> mx_freq_even=mx_freq_odd;
	vector<int> num(2,0);
	for(int i=0;i<n;i++){
		if(i%2){
			if(++freq_odd[v[i]]>mx_freq_odd[0]){
				if(v[i]!=num[0]){
					mx_freq_odd[1]=mx_freq_odd[0];
				}
				mx_freq_odd[0]=freq_odd[v[i]];
				num[0]=v[i];
			}
			else if(freq_odd[v[i]]>mx_freq_odd[1]){
				mx_freq_odd[1]=freq_odd[v[i]];
			}
		}
		else{
			if(++freq_even[v[i]]>mx_freq_even[0]){
				if(v[i]!=num[1]){
					mx_freq_even[1]=mx_freq_even[0];
				}
				mx_freq_even[0]=freq_even[v[i]];
				num[1]=v[i];
			}
			else if(freq_even[v[i]]>mx_freq_even[1]){
				mx_freq_even[1]=freq_even[v[i]];
			}
		}
	}
	if(num[1]!=num[0]){
		printf("%d\n",n-mx_freq_odd[0]-mx_freq_even[0]);
	}
	else{
		printf("%d\n",n-max(mx_freq_odd[1]+mx_freq_even[0],mx_freq_even[1]+mx_freq_odd[0]));
	}
	return 0;
}

Measured memory_bytes: 1408