akhauriyash/Code-Regression huggingface dataset:
from pprint import pprint
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for _ in range(n)]
dp[0]=l[0]
for i in range(1,n):
    for j in range(3):
        dp[i][j]=max(dp[i-1][(j+1)%3]+l[i][j],dp[i-1][(j+2)%3]+l[i][j])
print(max(dp[n-1]))
# pprint(dp)

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

int main(){
    int n;
    cin >> n;
    vector<int> t(n), tmp(n);
    for(int i=0; i<n; i++){cin >> t[i];}
    tmp = t;

    int m;
    cin >> m;
    vector<int> p(m), x(m);
    for(int i=0; i<m; i++){cin >> p[i] >> x[i];}

    for(int i=0; i<m; i++){
        tmp = t;
        int sum=0;
        tmp[p[i]-1] = x[i]; 
        for(int j=0; j<n; j++){
            sum += tmp[j];
        }
        cout << sum << endl;
    }
    
    return 0;
}

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

int main(){
  int K,S;
  cin>>K>>S;
  
  int count=0;
  for(int x=0;x<=K;x++){
    for(int y=0;y<=K;y++){
      if(S-(x+y)>=0 && S-(x+y)<=K){
        count++;
      }
    }
  }
  cout<<count<<endl;
  
  return 0;
}

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

typedef long long ll;

int main(){
  int a,b;
  cin >> a >> b;
  int c = b - a;
  vector<int> d(999);
  vector<int> e(999);
  d[0] = 1;
  for(int i=1;i<999;i++) d[i] = d[i-1]+i+1;
  for(int i=1;i<999;i++){
    if(d[i]-d[i-1] == c){
      cout << d[i-1]-a << endl;
    }
  }
}

Measured memory_bytes: 256
import heapq
N, M, init_silver = map(int, input().split())
MAX_COST = 2500
init_silver = min(init_silver, MAX_COST)

G = [[] for _ in range(N)]
for i in range(M):
    u, v, silver_cost, time_cost = map(int, input().split())
    u, v = u - 1, v - 1
    G[u].append([v, silver_cost, time_cost])
    G[v].append([u, silver_cost, time_cost])

change_rate, change_cost = [], []
for i in range(N):
    rate, cost = map(int, input().split())
    G[i].append([i, -rate, cost])  # これを追加！
    change_rate.append(rate)
    change_cost.append(cost)


# dp[i][silver] := 頂点iにいて銀貨をsilver枚持っているような状況を作るために必要な最小時間
dp = [[float('inf')] * (MAX_COST + 1) for _ in range(N)]
dp[0][init_silver] = 0

# 優先度付きキュー: (time, node, silver)
hq = [(0, 0, init_silver)]
while hq:
    time, node, silver = heapq.heappop(hq)

    for to, silver_cost, time_cost in G[node]:
        remain_silver = min(silver - silver_cost, MAX_COST)
        if remain_silver < 0:
            continue

        dp_next_value = time + time_cost
        if dp[to][remain_silver] <= dp_next_value:
            continue

        dp[to][remain_silver] = dp_next_value
        heapq.heappush(hq, (dp_next_value, to, remain_silver))

print(*[min(d) for d in dp[1:]], sep="\n")

Measured memory_bytes: 24260
#include<bits/stdc++.h> 
using namespace std; 
  
int main()
{
    int n,k;
    cin>>n>>k;
    
    int a[n];
    double expec[n],sum=0,max=0;
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    
    for(int i=0;i<n;i++)
    {
        expec[i]=double((a[i]+1)/2.0);
    }
    
    for(int i=0;i<n;i++)
    {
        if(i<k)
        {
            sum+=expec[i];
        }
        
        else
        {
            sum+=expec[i] - expec[i-k];
        }
        
        if(sum>max)
        {
            max=sum;
        }
    }
    
    cout<<fixed<<setprecision(12)<<max<<endl;

}   


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A[3];
    rep(i, 3) cin >> A[i];
    sort(A, A + 3);
    int ans = 0;
    while(A[0] != A[2]) {
        ans++;
        if (A[2] - A[0] >= 2) A[0] += 2;
        else if (A[0] == A[1]) {
            A[0]++; A[1]++;
        }
        else if (A[1] == A[2]) {
            A[1]++; A[2]++;
        }
        sort(A, A + 3);
    }
    cout << ans << endl;
    

    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 all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    rep(i,n){
        cin>>v[i+1];
    }
    long ans=0;
    for (int i=0;i<k+1;i++){
        //何回回収する？
        long ans1=0;
        for (int j=0;j<min(n,i)+1;j++){
            //左からいくつまで取る
            int left=j;
            int right=min(n,i)-j;
            long s=0;
            vector<int> v1;
            for (int k1=1;k1<j+1;k1++){
                s+=v[k1];
                v1.push_back(v[k1]);
            }
            for (int k1=n;k1>n-min(n,i)+j;k1--){
                s+=v[k1];
                v1.push_back(v[k1]);
            }
            sort(all(v1));
            int sss=v1.size();
            for (int k1=0;k1<min(k-i,sss);k1++){
                if (v1[k1]>=0){
                    break;
                }
                else{
                    s-=v1[k1];
                }
            }
            ans1=max(ans1,s);

        }
        ans=max(ans1,ans);

    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
k,s = gets.chomp.split(' ').map(&:to_i)
ans = 0
x = 0
while x <= k
  y = 0
  while y <= k
    z = s - x - y
    if z >= 0 && z <= k
      ans += 1
    end    
    y += 1
  end
  x += 1
end
puts ans

Measured memory_bytes: 14328
#include <iostream>

int main() {
  std::string S;
  std::cin >> S;

  const char a = S[0];
  const char b = S[1];
  const char c = S[2];
  const char d = S[3];

  if ((a == b && c == d && a != c) || (a == c && b == d && a != b) || (a == d && b == c && a != b)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


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

int main() {
  int N;
  int sum=0;
  cin>>N;
  for(int i=0;i<N;i++){
	int l,r;
    cin>>l>>r;
    sum+=r-l+1;
  }
  cout<<sum<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    ll a[100002] {0};
    for(int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[i] / 2;
        a[i] %= 2;
        if(a[i] == 1 && a[i + 1] > 0){
            ans++;
            a[i + 1]--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

X,N=map(int,input().split())

if(N==0):
    ans=X
else:
    ListP=list(map(int,input().split()))

    min = 999999
    for i in range(-200,200):
        if(min > abs(X-i)):
            if(i not in ListP):
                min=abs(X-i)
                ans=i


print(ans)

Measured memory_bytes: 9916
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {

	string s; cin >> s;
	int l = s.size();
	
	LL ans = 0;
	//仕切り線の部分集合を全列挙
	for (int bit = 0; bit < (1 << l-1); ++bit) {

		LL num = s[0] - '0';
		
		for (int j = 0; j < l-1; j++) {
			//仕切りが立ってれば、そこで数字が切れるので精算
			if (bit&(1 << j)) {
				ans += num;
				num = 0;
			}

			//現在の値を加える
			num = num * 10 + s[j + 1] - '0';
		}

		//残ってるのを回収
		ans += num;
	}

	cout << ans << endl;


	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template <class _A, class _B, class _Compare=less<_A> >
class MMap : public set < pair< _A, _B >, _Compare >
{
        public :
                MMap():set< pair< _A, _B >, _Compare >(){};
                ~MMap(){};
};

template< typename InPair >
struct MMapComp{
        bool operator() (InPair a , InPair b){
                if( a.first == b.first ) return a.second > b.second;
                else
                        return a.first < b.first;
        }
};

void Main() {
    ll N; cin >> N;
    MMap<string, ll, MMapComp< pair<string , ll> > > x;
    map<pair<string, ll>, ll> y;
    rep(i, N){string s; ll p; cin >> s >> p; x.insert(make_pair(s, p)); y[make_pair(s, p)] = i + 1;}
    for( MMap<string, ll >::iterator it = x.begin(); it != x.end(); it++ ){
        // cout << (*it).first << "\t" << (*it).second << endl;
        cout << y[make_pair((*it).first, (*it).second)] << endl;
    }

    // auto cmp = [](std::pair<string, ll> const & a, std::pair<string, ll> const & b) {
    //     return a.first != b.first?  a.first < b.first : a.second < b.second;
    // };
    // std::sort(x.begin(), x.end(), cmp);
    // for (auto a: x){cout << a.first << " " << a.second << endl;}
}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			boolean flg = (n % 2 == 0);
			int[] a = in.nextIntArray(n);
			Arrays.sort(a);

			int sumA = 0;
			int sumB = 0;

			for (int i = n-1; i >= 0; i--) {
				// 偶数の場合
				if (flg) {
					if (i % 2 == 1) {
						sumA += a[i];
					} else {
						sumB += a[i];
					}
				// 奇数の場合
				} else {
					if (i % 2 == 0) {
						sumA += a[i];
					} else {
						sumB += a[i];
					}
				}

			}

			out.println(Math.abs(sumA - sumB));

		}

	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

 
int main() {
  int N,K;
  cin >> N >> K;
  string s;
  cin >> s;
  vi nums;
  int now = 1;
  int cnt = 0;
  rep(i,N) {
    if(s[i] == (char)(now + '0')) {
      cnt++;
    } else {
      nums.push_back(cnt);
      cnt = 1;
      now = 1 - now;
    }
  }
  if(cnt != 0) nums.push_back(cnt);
  if(sz(nums) % 2 == 0) nums.push_back(0);
  int len = sz(nums);
  int ans = 0;
  for(int i = 0;i < len;i += 2) {
    int left = i;
    int right = min(i + 2 * K + 1,len);
    int tmp = 0;
    srep(k,left,right) {
      tmp += nums[k];
    }
    ans = max(ans,tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int w,h;
  while(cin>>h>>w, h+w){
    char data[h][w+3];
    bool f[h][w];
    memset(f, 0, sizeof(f));
    REP(i,h) cin>>data[i];
    int x, y;
    x = y = 0;
    while(true){
      if(f[y][x]){
        puts("LOOP");
        break;
      }
      if(data[y][x] == '.'){
        printf("%d %d\n",x,y);
        break;
      }
      f[y][x] = true;
      switch(data[y][x]){
      case '>': x++; break;
      case '<': x--; break;
      case '^': y--; break;
      case 'v': y++; break;
      default: break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int left = A+B;
    int right = C+D;
    string ans = "";
    if(left>right) ans = "Left";
    else if(left<right) ans = "Right";
    else ans = "Balanced";
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h> 
int main()
{
	int a,b,c,n=0,i;
	char grade[99999];
	scanf("%d %d %d",&a,&b,&c);
	while(a!=-1 || b!=-1 || c!=-1)
	{
		n++;
		if(a==-1 || b==-1)
			grade[n]='F';
		else
		{
			if(a+b>=80)
				grade[n]='A';
			else
			{
				if(a+b>=65 && a+b<80)
					grade[n]='B';
				else
				{
					if(a+b>=50 && a+b<65)
						grade[n]='C';
					else
					{
						if(a+b>=30 && a+b<50 && c>=50)
							grade[n]='C';
						else
						{
							if(a+b>=30 && a+b<50 && c<50)
								grade[n]='D';
							else
								grade[n]='F';
						}
					}
				}
			}
		}
		scanf("%d %d %d",&a,&b,&c);
	}
	
	for(i=1;i<=n;i++)
		printf("%c\n",grade[i]);
	return 0;
}


Measured memory_bytes: 2056
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final BigDecimal result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int T = sc.nextInt();
        int X = sc.nextInt();

        sc.close();
        return new TestCase(T, X);
    }

    public static BigDecimal process(TestCase testCase) {
        int T = testCase.T;
        int X = testCase.X;

        return new BigDecimal(T).divide(new BigDecimal(X), 10, BigDecimal.ROUND_HALF_UP);
    }

    private static void output(BigDecimal result) {
        System.out.println(result.toString());
    }

    public static class TestCase {
        final int T;
        final int X;

        public TestCase(int t, int x) {
            T = t;
            X = x;
        }
    }
}


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

class P
{
    static void Main()
    {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(s[1] - s[0] == s[2] - s [1] ? "YES" : "NO");
    }
}

Measured memory_bytes: 13268
#include<cstdio>
#define ll long long
#define mod 1000000007
#define maxn 100010
char s[2*maxn];
int a[2*maxn];
int n;
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	int flag=0;
	for(int i=1;i<=2*n;i++){
		if((s[i]=='B')==flag)a[i]=-1;
		else a[i]=1;
		flag^=1;
	}
	int sum=0;
	for(int i=1;i<=2*n;i++)
		sum+=a[i];
	if(sum){
		puts("0"); return 0;
	}
	ll ans=1,cnt=0;
	for(int i=1;i<=2*n;i++)
		if(a[i]==1)++cnt;
		else ans=ans*cnt%mod,--cnt;
	for(int i=1;i<=n;i++)
		ans=ans*i%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int n,m;
    cin >> n >> m;

    vector<bool> ac(n + 1);
    vector<int>  wa(n + 1);

    int w = 0;

    rep(i,m){
        int p;
        string s;

        cin >> p >> s;

        if(s == "AC"){
            ac[p] = true;
        }else{
            if(!ac[p]){
                wa[p]++;
            }
        }
    }

    int a = 0;

    rep(i, n){
        if(ac[i + 1]) a++;
        if(ac[i + 1]){
            w += wa[i + 1];
        }
    }

    cout << a << " " << w << endl;

    return 0;
}


Measured memory_bytes: 640
import Control.Monad

listCandidates :: Int -> [[Int]] -> [Int]
listCandidates _ []           = []
listCandidates upperTime (x@[cost, time]:xs)
  | time <= upperTime = [cost] ++ listCandidates upperTime xs
  | otherwise         =           listCandidates upperTime xs

main :: IO ()
main = do
  [number, upperTime] <- map read . words <$> getLine
  costs <- replicateM number $ map read . words <$> getLine
  let candidates = listCandidates upperTime costs
  putStrLn $ if null candidates then "TLE" else show $ minimum candidates

Measured memory_bytes: 1020
package main

import (
	"fmt"
)

func ketawa(n int) int {
	ans := 0
	for {
		if n/10 == 0 {
			ans += n % 10
			return ans
		} else {
			ans += n % 10
			n /= 10
		}
	}
}

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	sum := 0
	for i := 0; i <= n; i++ {
		ketawa := ketawa(i)
		if ketawa >= a && ketawa <= b {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
/* ****VIKRAM ADITYA**** */
#include<bits/stdc++.h>

#define ll          long long
#define F           first
#define S           second
#define pb          push_back
#define mp          make_pair
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	freopen ("o1.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		string a,b;
		cin>>a>>b;
		ll n=a.size();
		ll m=b.size();
		// vector<vector<string>>s(n+1,vector<string>(m+1,""));
		vector<vector<ll>>v(n+1,vector<ll>(m+1,0));

		for (int i = 1; i <= n; ++i)
		{
			for (int j = 1; j <= m; ++j)
			{
				if(a[i-1]==b[j-1])
				{
					v[i][j]=v[i-1][j-1]+1;
					// s[i][j]=s[i-1][j-1]+a[i-1];
				}
				else
				{
					if(v[i][j-1]>v[i-1][j])
					{
						v[i][j]=v[i][j-1];
						// s[i][j]=s[i][j-1];
					}
					else
					{
						v[i][j]=v[i-1][j];
						// s[i][j]=s[i-1][j];
					}

				}
			}
		}
		ll l=v[n][m];
		int i=n;
		int j=m;
		string s="";
		while(l>0)
		{
			if(a[i-1]==b[j-1])
			{
				s=s+a[i-1];
				l--;
				i--;
				j--;
			}
			else 
			{
				if(v[i-1][j]>v[i][j-1])
				{
					i--;
				}
				else
					j--;
			}
		}

		

		reverse(s.begin(), s.end());
		cout<<s;
		
	}

	
	time
	return 0;
}

Measured memory_bytes: 74040
MOD = 10**9+7

MAXN = 2000
fact = [1]
ifact = [1]
for i in range(MAXN):
    fact.append(fact[-1] * (i+1) % MOD)
    ifact.append(pow(fact[-1], MOD-2, MOD))
def nCr(n, r):
    return fact[n] * ifact[r] * ifact[n-r] % MOD
def nPr(n, r):
    return fact[n] * ifact[n-r] % MOD

s = int(input())
n = s//3

ans = 0
for i in range(1,n+1):
    r = s - 3*i
    ans += nCr(r+i-1, i-1)
ans %= MOD
print(ans)

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

l = 0
r = 10 ** 9

while r-l > 1:
  m = (r+l) // 2
  count = 0
  for i in A:
    if i > m:
      count += i // m
      
  if count > K:
    l = m
  else:
    r = m
    
print(r)

Measured memory_bytes: 30988
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int n, k, x, y, p = 0;
	cin >> n >> k >> x >> y;
	for (int i = 1; i <= n; i++) {
		if (i <= k) {
			p += x;
		}
		else {
			p += y;
		}
	}
	cout << p;
	return 0;
}

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

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] aa = new int[n];
        int[] bb = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = aa[i] = sc.nextInt();
        }
        for(int i=0; i<n; i++) {
            b[i] = bb[i] = sc.nextInt();
        }
        Arrays.sort(bb);
        Arrays.sort(aa);
        for(int i=0; i<n; i++) {
            if(aa[i]>bb[i]) {
                System.out.println("No");
                return;
            }
        }
        for(int i=0; i<n; i++) {
            int p = Arrays.binarySearch(aa, b[i]);
            if(p == n) {
                b[i] = aa[n-1];
            } else if (p >= 0) {
                b[i] = aa[p];
            } else {
                b[i] = aa[-2-p];
            }
            bb[i] = b[i];
        }
        Arrays.sort(bb);

        for(int i=1; i<n; i++) {
            if(bb[i-1]==bb[i]) {
                System.out.println("Yes");
                return;
            }
        }
        for(int i=0; i<n; i++) {
            if(a[i] == b[i]) {
                System.out.println("Yes");
                return;
            }
        }
        int[] aaa = new int[n];
        int[] bbb = new int[n];

        P[] pa = new P[n];
        for(int i=0; i<n; i++) {
            pa[i] = new P(Arrays.binarySearch(aa, a[i]),  Arrays.binarySearch(aa, b[i]));
        }
        Arrays.sort(pa);
        boolean[] v = new boolean[n];
        v[0] = true;
        int q = 0;
        while(true) {
            int next = pa[q].b;
            if(v[next]) break;
            v[next] = true;
            q = next;
        }
        for(int i=0; i<n; i++) {
            if(!v[i]) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

    static class P implements Comparable<P> {
        int a;
        int b;
        public P(int a, int b) {
            this.a = a;
            this.b = b;
        }
        @Override public int compareTo(P o) {
            return a - o.a;
        }
    }
}


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

using namespace std;

int main() {
	int N;
	cin >> N;

	vector<int64_t> B(N - 1);
	for (int i = 0; i < N - 1; i++) {
		cin >> B.at(i);
	}

	vector<int64_t> A(N,0);
	int64_t s = 0;
	A.at(0) = B.at(0);
	for (int i = 1; i < N - 1; i++) {
		A.at(i) = min(B.at(i), B.at(i - 1));
	}
	A.at(N - 1) = B.at(N - 2);

	for (int i = 0; i < N; i++) {
		s += A.at(i);
	}
	cout << s << endl;
}

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

int main()
{
  int n;
  cin >> n;
  int a[n], b[n], m = -1;
  rep(i, n){
    cin >> a[i];
    b[i] = a[i];
    m = max(m, a[i]);
  }
  sort(a, a + n);
  rep(i, n){
    if(b[i] == m) cout << a[n - 2] << endl;
    else cout << a[n - 1] << endl;
  }

  return 0;
}

Measured memory_bytes: 5072
import sys

input = sys.stdin.readline

N = int(input().strip())
As = list(map(int, input().strip().split(' ')))
candidates = list(set(As))

if len(candidates) == 1:
    if candidates[0] == 0:
        print('Yes')
    else:
        print('No')
elif len(candidates) == 2:
    a, zero = candidates
    if a < zero:
        a, zero = zero, a

    if zero == 0:
        count_a = 0
        count_zero = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == zero:
                count_zero += 1
        else:
            if count_a == count_zero * 2:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
elif len(candidates) > 3:
    print('No')
else:
    a, b, c = candidates[0], candidates[1], candidates[2]
    if a ^ b != c:
        print('No')
    else:
        count_a = 0
        count_b = 0
        count_c = 0
        for element in As:
            if element == a:
                count_a += 1
            elif element == b:
                count_b += 1
            elif element == c:
                count_c += 1
        else:
            if count_a == count_b == count_c:
                print('Yes')
            else:
                print('No')


Measured memory_bytes: 14212
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            for (var i = 0; i < N; ++i)
            {
                if (i + 1 < N && S[i] == S[i + 1])
                {
                    WriteLine($"{i + 1} {i + 1 + 1}");
                    return;
                }
                if (i + 2 < N && S[i] == S[i + 2])
                {
                    WriteLine($"{i + 1} {i + 2 + 1}");
                    return;
                }
            }
            WriteLine("-1 -1");
        }
    }
}

Measured memory_bytes: 13280
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define N 100010
#define LL long long
#define M 1000000007
using namespace std;
int n,m,f[N]; LL A,B,s[N],w[N<<2];
void change(int p,int l,int r,int a,int b){
    if (l==r){
        (w[p]+=b)%=M;
        return;
    }
    int mid=(l+r)/2;
    if (a<=mid) change(p*2,l,mid,a,b);else change(p*2+1,mid+1,r,a,b);
    w[p]=(w[p*2]+w[p*2+1])%M;
}
int query(int p,int l,int r,int a,int b){
    if (a>b) return 0;
    if (l==a&&r==b) return w[p];
    int mid=(l+r)/2;
    if (b<=mid) return query(p*2,l,mid,a,b);
    else if (a>mid) return query(p*2+1,mid+1,r,a,b);
    else return (query(p*2,l,mid,a,mid)+query(p*2+1,mid+1,r,mid+1,b))%M;
}
main(){
	scanf("%d%lld%lld",&n,&A,&B);
	if(A<B) swap(A,B); f[0]=1; 
	for(int i=1;i<=n;++i) scanf("%lld",s+i);
	*s=-A; s[n+1]=A+s[n]; int l=0,r=0; change(1,0,n,0,f[0]);
	for(int i=1;i<=n+1;++i){
		while(s[i]-s[r+1]>=A) ++r;
		if(i>=2 && s[i-1]-s[i-2]<B) l=i-2;
		if(s[i]-s[i-1]>=A) f[i]=f[i-1];
		f[i]=(f[i]+query(1,0,n,l,min(r,i-2)))%M;
		if(s[i+1]-s[i-1]>=B) change(1,0,n,i,f[i]);
	}
	printf("%lld\n",(f[n+1]+M)%M);
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

int get_random(int l, int r) {
  int k = r - l + 1;
  return l + rng() % k;
}

const int N = 365 + 7;
const int K = 26 + 7;
int n;
int c[K], s[N][K], t[N], last[K];

int get() {
  for (int j = 1; j <= 26; j++) {
    last[j] = 0;
  }
  int sol = 0, grow = 0;
  for (int i = 1; i <= n; i++) {
    sol += s[i][t[i]];
    grow += c[t[i]] * (i - last[t[i]]);
    last[t[i]] = i;
    sol += grow;
  }
  return sol;
}

void make_better(double seconds) {
  time_t bg = clock();
  int c = 0;
  int cur = get();
  while (1) {
    c++;
    if (c % 10 == 0) {
      time_t nd = clock();
      if ((double) (nd - bg) > seconds) {
        break;
      }
    }
    int i = get_random(1, n), x = get_random(1, 26);
    while (x == t[i]) {
      x = get_random(1, 26);
    }
    int init = t[i];
    t[i] = x;
    int after = get();
    if (after > cur) {
      cur = after;
    } else {
      t[i] = init;
    }
  }

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= 26; i++) {
    cin >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    t[i] = get_random(1, 26);
  }
  make_better(1);
  for (int i = 1; i <= n; i++) {
    cout << t[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 3724
#include<stdio.h>
#include<map>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

typedef long long ll;

namespace factorization{
	ll p[]={2,3,5,7,11,13,17,19,23,29,31};

	ll pw(ll a,ll b,ll c)
	{
		ll r = 1;
		while(b){
			if(b&1) r = (__int128)r * a % c;
			a = (__int128)a * a % c; b /= 2;
		}
		return r;
	}

	bool ML(ll x)
	{
		if(x==2)return true;
		if(x<2||!(x&1))return false;
		ll y = x-1;
		int s = 0;
		while(~y&1) y /= 2, s++;
		for(ll a : p){
			if(a >= x)return true;
			ll d = pw(a, y, x);
			if(d == 1)continue;
			for(int j = 0; j < s; j++){
				ll t = (__int128)d*d % x;
				if(t == 1 && d != 1 && d != x - 1) return false;
				d = t;
			}
			if(d != 1) return false;
		}
		return true;
	}

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

	ll div(ll x)
	{
		ll a=rand()%(x-1)+1, b=a, i=1, k=2;
		ll c=1;
		do{
			i++;
			ll d = gcd(b-a+x, x);
			if(d!=1 && d!=x)return d;
			if(i==k)b=a,k<<=1;
			a=((__int128)a*a + x-c) % x;
		}while(a!=b);
		return x;
	}

	void PR(ll x, vector<ll> &L)
	{
		if(x==1)return;
		if(ML(x)){
			L.push_back(x);
			return;
		}
		else{
			ll p = div(x);
			PR(p, L);
			PR(x/p, L);
		}
	}
};

map<__int128, __int128> D, E;

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		vector<ll> X;
		map<ll, int> L;
		ll a;
		scanf("%lld", &a);
		factorization::PR(a, X);
		for(ll c : X) L[c] += 1;

		__int128 op = 1, cur = 1;
		for(auto c : L){
			c.second %= 3;
			if( c.second == 1 ) op = op * c.first * c.first, cur = cur * c.first;
			else if( c.second == 2 ) op = op * c.first, cur = cur * c.first * c.first;
		}
		D[cur] += 1; D[op] = D[op];
		E[op] = cur; E[cur] = op;
	}
	ll ans = 0;
	for(auto c : D){
		if( c.first == 1 && c.second >= 1) ans += 2;
		else ans += max(D[c.first], D[E[c.first]]);
	}
	printf("%lld\n", ans / 2);
	return 0;
}


Measured memory_bytes: 31744
from decimal import *
A,B,C,D=list(map(int,input().split()))

def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    
    while True:
#         print(x,y)
        y_ = x % y
        if y_ == 0:
            return y
        x = y
        y = y_

def lcm(a,b):
    ans=Decimal(a*b)/Decimal(gcd(a,b))
    return ans.as_integer_ratio()[0]

CD=lcm(C,D)
len_all = B-A+1
len_c = B//C-(A-1)//C
len_d = B//D-(A-1)//D
len_c_and_d = B//CD-(A-1)//CD

ans=len_all-len_c-len_d+len_c_and_d 
print(int(ans))

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int T[2];
int A[2];
int B[2];

signed main()
{
  cin >> T[0] >> T[1];
  cin >> A[0] >> A[1];
  cin >> B[0] >> B[1];

  if(A[0]*T[0] + A[1]*T[1] < B[0]*T[0] + B[1]*T[1]) {
    swap(A[0], B[0]);
    swap(A[1], B[1]);
  }

  int AB0 = (A[0] - B[0]) * T[0];
  int AB1 = (A[1] - B[1]) * T[1];

  if((AB0 < 0 && AB1 < 0) || (AB0 > 0 && AB1 > 0)) {
    cout << 0 << endl;
    return 0;
  }

  int diff = abs(abs(AB0) - abs(AB1));

  if(diff == 0) {
    cout << "infinity" << endl;
    return 0;
  }

  if(A[0] >= B[0]) {
    cout << 0 << endl;
    return 0;
  } else {
    int diff2 = (B[0] - A[0]) * T[0];
    if(diff2%diff == 0) {
      cout << 1 + (diff2 / diff)*2 - 1 << endl;
    } else {
      cout << 1 + (diff2 / diff)*2 << endl;
    }
    return 0;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin>>n;
    ll ans=0;
  	for(int i=1;i<=n;i++){
    	for(int j=1;j<=n;j++){
        	for(int k=1;k<=n;k++){
            	ans+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3616
def input_n
  gets.to_i               # 単一整数
end

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

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

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

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

n = input_n
a = input_a

a = a.sort
max = a.max
bools = Array.new(max + 1, true)
old = 0
a.each do |i|
  num = 2
  bools[i] = false if i == old
  while num * i <= max
    bools[num * i] = false
    num += 1
  end
  old = i
end

cnt = 0
a.each do |i|
  cnt += 1 if bools[i]
end

puts cnt


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

const ll MOD = 1e9+7;

ll repsq(ll n,ll p){
    if(p == 0) return 1;
    if(p & 1) return (n * repsq(n,p-1)) % MOD;
    else {
        ll t = repsq(n,p/2) % MOD;
        return (t * t) % MOD;
    }
}

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll ans = (repsq(2,n) - 1) % MOD;

    ll x_a = 1,x_b = 1;
    ll y_a = 1,y_b = 1;
    ll dis_a = 1,dis_b = 1;

    for(ll i=0;i<a;i++){
        x_a *= (n-i);
        x_a %= MOD;
        y_a *= (1+i);
        y_a %= MOD;
    }
    dis_a = x_a * repsq(y_a,MOD-2) % MOD;

    for(ll i=0;i<b;i++){
        x_b *= (n-i);
        x_b %= MOD;
        y_b *= (1+i);
        y_b %= MOD;
    }
    dis_b = x_b * repsq(y_b,MOD-2) % MOD;

    ans = (ans - dis_a ) % MOD;
    ans = (ans - dis_b ) % MOD;

    cout<< (ans + MOD) % MOD <<endl;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var n = l[0]; var m = l[1];
        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var sum = line.Sum();
        line = line.Where(x => x * 4 * m >= sum).ToArray();
        if (m <= line.Length) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=2e5+5;
const int mod=1e9+7;
vector<int>g[maxn];
ll dp[maxn];
queue<int>q;
void dfs(int now,int pre){
    for(auto c:g[now]){
        if(c!=pre){
           dp[c]+=dp[now];
           dfs(c,now);
        }
    }
}
int main(){
    int n,Q,ai,bi,pj,xj;
    scanf("%d%d",&n,&Q);
    for(int i=1;i<n;i++){
        scanf("%d%d",&ai,&bi);
        g[ai].push_back(bi);
        g[bi].push_back(ai);
    }
    memset(dp,0,sizeof(dp));
    while(Q--){
        scanf("%d%d",&pj,&xj);
        dp[pj]+=xj;
    }
    dfs(1,-1);
    for(int i=1;i<=n;i++){
        printf("%lld%c",dp[i],(i == n) ? '\n' : ' ');
    }
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))

using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e9+1;

int a[100001];
int b[100001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    int n;
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        b[a[i]]++;
        b[a[i]+1]++;
        b[a[i]-1]++;
    }
    int mx=0, ans;
    for(int i=0; i<=100000; i++)
    {
        if(b[i]>mx)
        {
            mx=b[i];
        }
    }
    cout << mx;
}


Measured memory_bytes: 1024
S=input()
N=len(S)
count=0
for i in range(2**(N-1)):
  A=S
  for j in range(N):
    if ((i >> j) & 1):
      A=A[:N-j-1]+" "+A[N-j-1:]
  #print(i,A)
  count += sum(list(map(int,A.split())))
print(count)

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

int main() {
  string s;
  cin>>s;
  int a=s.size();
  int cnt=0;
  for(int i=0;i<a/2;i++){
    if(s[i]!=s[a-1-i])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
typedef long long ll;
const int xmax=1e5+7;
const int INF=1e9+7;
using namespace std;
int main()
{
    int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
    int ans=b/a;
    ans=min(ans,c);
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  int a[200000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  };
  int al=0;
  for(int i=0;i<n;i++){
    al=al^a[i];
  };
  for(int i=0;i<n;i++){
    printf("%d",al^a[i]);
    if(i!=n-1)printf("%c",' ');
  };
  return 0;
};

Measured memory_bytes: 3236
go = [2, 7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307,317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997, 1087, 1097, 1117, 1187, 1217, 1237, 1277, 1297]
n = int(input())
print(" ".join(map(str, go[:n])))


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

int main(){
  int n; cin >> n;
  double x, y;
  vector<vector<double>> hoge(n, vector<double>(2));
  rep(i, n){
    cin >> x >> y;
    hoge[i][0] = x;
    hoge[i][1] = y;
  }
  double sum = 0;
  vector<int> fuga(n);
  rep(i, n){
    fuga[i] = i;
  }

  do{
    rep(i, n - 1){
      // cout << fuga[0] << fuga[1] << fuga[2] << endl;
      // cout << (pow((hoge[fuga[i % n]][0] - hoge[fuga[(i + 1) % n]][0]), 2.0) + pow((hoge[fuga[i % n]][1] - hoge[fuga[(i + 1) % n]][1]), 2.0)) << endl;
      sum += pow((pow((hoge[fuga[i]][0] - hoge[fuga[(i + 1)]][0]), 2.0) + pow((hoge[fuga[i]][1] - hoge[fuga[(i + 1)]][1]), 2.0)), 0.5);
    }
  }while(next_permutation(fuga.begin(), fuga.end()));

  double kaijou = 1;
  r_rep(i, 1, n + 1){
    kaijou *= i;
  }

  // cout << sum << endl;
  // cout << kaijou << endl;
  cout << fixed << setprecision(10) << sum/kaijou << endl;
}

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

int n, s[393], l[393], p[393], m, w[393], dp[394];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d%d", &s[i], &l[i], &p[i]);
  for (int i = 1; i <= 393; i++) dp[i] = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 393; j++) {
      for (int k = s[i]; k <= l[i]; k++) if (j - k >= 0 && dp[j - k] != -1) dp[j] = max(dp[j], dp[j - k] + p[i]);
    }
  }
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &w[i]);
    if (dp[w[i]] == -1) {
      printf("-1\n");
      return 0;
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d\n", dp[w[i]]);
  }
}



Measured memory_bytes: 2764
#include <iostream>
using namespace std;
int main(void){
    int n,x;
    cin >> n;
    int array[n];
    for( int i=0;i<n;i++) cin >> array[i];
    int idx = 0;
    for(int i = 0;i<n;i++){ 
        int nexb = array[idx];
        if(nexb == 2) {
            cout << i + 1;
            return 0;
        }
        idx = nexb-1;
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAX=1500000;
int main(){

  for(int n,m;cin>>n>>m,n&&m;){
    int h[1500],w[1500],a0[MAX+10]={},a1[MAX+10]={};
    for(int i=0;i<n;i++) cin>>h[i];
    for(int i=0;i<m;i++) cin>>w[i];
    for(int i=1;i<=n;i++) for(int j=0;j<n-i+1;j++){
	int r=0;
	for(int k=0;k<i;k++) r+=h[j+k];
	a0[r]++;
      }
    for(int i=1;i<=m;i++) for(int j=0;j<m-i+1;j++){
	int r=0;
	for(int k=0;k<i;k++) r+=w[j+k];
	a1[r]++;
      }
    int r=0;
    for(int i=1;i<=MAX;i++) r+=a0[i]*a1[i];
    cout<<r<<endl;
  }
  return 0;
}

Measured memory_bytes: 14808
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    double N, D;
    cin >> N >> D;

    cout << ceil(N / (2 * D + 1)) << endl;
}

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

using namespace std;

int main() {
   int n;
   cin >> n;
   double x[n];
   string u;
   double ans =0;
   for(int i=0;i<n;i++){
       cin >> x[i] >> u;
       if(u[0]=='J'){
           ans+=x[i];
       }
       else {
           ans+=x[i]*380000.0;
       }
   }
   cout  << ans << endl;
    return 0;
}

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

class Edge
{
	public:
	int to,cost;
	Edge(int t,int c)
	{
		to=t;cost=c;
	}
};
map<string,int> mp;
int strong[41];
int rui[42];
vector<Edge> g[41];
int ans=0;
int saiki(int now,int power,ll dou,ll ng,int n)
{
	int ret=power;
	ans=max(ret,ans);
	if(ret+rui[n]-rui[now]<ans)
		return ret;
	//cerr<<now<<" "<<ret<<endl;
	//頂点nowにおいてngの更新をする
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		ng|=(1LL<<(ll)e.to);
	}
	if((dou|ng|1)==(1LL<<(ll)(n+1))-1)
		return ret;
	//全頂点について調べる
	for(int i=now+1;i<n+1;i++)
	{
		//すでに使われているor使えない頂点は飛ばす
		ll tmp=(1LL<<(ll)i);
		if((tmp&dou)>0 || (ng&tmp)>0)
			continue;
		ans=max(ans,saiki(i,power+strong[i],dou|tmp,ng,n));
	}
	return ret;
}

int main()
{
	while(1)
	{
		int n;
		int cnt=1;
		ans=0;
		cin>>n;
		for(int i=0;i<41;i++)
			g[i].clear();
		mp.clear();
		ll dou=(1<<1);//自国を含む同盟の国
		ll str=0;
		if(n==0)
			break;
		for(int i=0;i<n;i++)
		{
			string a;
			cin>>a;
			if(mp[a]==0)
			{
				mp[a]=cnt;
				cnt++;
			}
			cin>>strong[mp[a]];
			int c;
			cin>>c;
			if(mp[a]==1 || c==0)
			{
				//無条件に同盟に入れる
				str+=strong[mp[a]];
				dou|=(1LL<<(ll)mp[a]);
			}
			for(int j=0;j<c;j++)
			{
				string d;
				cin>>d;
				if(mp[d]==0)
				{
					mp[d]=cnt;
					cnt++;
				}
				g[mp[a]].push_back(Edge(mp[d],1));
			}
		}
		//input end
		rui[0]=0;
		for(int i=1;i<n+1;i++)
			rui[i]=rui[i-1]+strong[i];
		//cerr<<strong[mp["Qi"]]<<endl;
		saiki(1,str,dou,0,n);
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3188
N=int(input())
a = list(map(int,input().split()))
h = [0]*N
for i in range(N):
  if i%2==0:
    h[0] = h[0] + a[i]
  else:
    h[0] = h[0] - a[i]
for i in range(N-1):
  h[i+1] = 2*a[i]-h[i]
print(*h)

Measured memory_bytes: 64484
#include<stdio.h>
#include<cstring>
#include<algorithm> 
#include<iostream> 
#include<vector>
#include<queue>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
ll a[maxn];
map<ll,int>vis;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n;
	cin>>n;
	int num;
	ll sum=0;
	for(int i=1;i<=n;i++){
		cin>>num;
		vis[num+i-1]++;
		int now=vis[i-1-num];
		//cout<<"数字"<<num<<" "<<i-1-num<<" "<<now<<endl;
		sum+=now;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 26340