akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int INF = 1e+9;
int n, m;
vector<int> et[100000];
int s, t;
int dp[100000][3];

signed main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		et[u].push_back(v);
	}
	cin >> s >> t;
	s--; t--;
	
	rep(i, n) {
		rep(j, 3) {
			dp[i][j] = INF;
		}
	}
	
	typedef tuple<int, int, int> T;	//(cost, pos, cost mod 3)
	queue<T> que;
	
	que.push(T(0, s, 0));
	dp[s][0] = 0;
	while (!que.empty()) {
		T now = que.front(); que.pop();
		int cst = get<0>(now);
		int pos = get<1>(now);
		int mo3 = get<2>(now);
		rep(i, et[pos].size()) {
			int npos = et[pos][i];
			if (dp[npos][(mo3 + 1) % 3] > cst + 1) {
				dp[npos][(mo3 + 1) % 3] = cst + 1;
				que.push(T(cst + 1, npos, (mo3 + 1) % 3));
			}
		}
	}
	
	if (dp[t][0] >= INF) cout << -1 << endl;
	else cout << dp[t][0] / 3 << endl;
	return 0;
}

Measured memory_bytes: 8064
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int t = scanner.nextInt();
        int ans = 0;
        int k = a;
        while (k <= t) {
            ans += b;
            k += a;
        }
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

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

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

#define HelloWorld std::cin.tie(0);std::ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 55;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

ll mypow(int x,int y){
    ll ret=1;
    for(int i;i<y;i++)ret=ret*x%MOD;
    return ret;
}

signed main(){
    CIN(N);
    map<int,int>mp;
    rep(i,N){
        int a;cin>>a;
        mp[a]++;
    }
    ll ans;
    if(N%2==1){
        int cnt=0;
        RepA(mp){
            if(item.second==2)cnt++;
        }
        if(mp[0]==1)cnt++;
        if(cnt==mp.size()){ans=mypow(2,N/2);}
        else ans=0;
    }else{
        int cnt=0;
        RepA(mp)if(item.second==2)cnt++;
        if(cnt==mp.size())ans=mypow(2,N/2);
        else ans=0;
    }
    COUT(ans);
    

    return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

class ele{
  public:
    llong cur;
    llong prev;
  ele(llong _cur, llong _prev){
    cur = _cur;
    prev = _prev;
  }
};

int main(){

  llong n, m;
  cin >> n >> m;
  vector<vector<llong>> v(n);
  REP(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    v[a].pb(b);
    v[b].pb(a);
  }

  queue<ele> que;
  que.push(ele(0, -1));
  
  vector<llong> ans(n);
  bool visited[100010] = {};
  
  visited[0] = true;
  while(!que.empty()){
    ele tp = que.front();
    que.pop();
    
    ans[tp.cur] = tp.prev;

    REPI(itr, v[tp.cur]){
      if(!visited[*itr]){
        que.push(ele(*itr, tp.cur));
        visited[*itr] = true;
      }
    }
  }

  REP(i,n){
    if(!visited[i]){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  FOR(i,1,n){
    cout << ans[i] + 1 << endl;
  }
  return 0;
}



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

int main()
{
  string s;cin>> s;
  string s1,s2;
  s1 = s.substr(0, s.length()/2);
  s2 = s.substr(s.length()/2 + s.length()%2, s.length());
  reverse(s2.begin(), s2.end());
  long long ans = 0;
  for (size_t i = 0; i < s.length()/2; i++)
  {
    if (s1[i] != s2[i])
    {
      ans++;
    }
    
  }
  
  cout << ans << endl;
}


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   string S;
   cin>>S;
   S[0]='2';
   S[1]='0';
   S[2]='1';
   S[3]='8';
   cout<<S;
   return 0; 
}


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

namespace ABC134D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] a = new int[N];
            a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int[] b = new int[N];
            int ansN = 0;
            for (int i = N - 1; i >= 0; i--)
            {
                int sum = a[i];
                for (int multiple = i; multiple < N; multiple += i + 1)
                {
                    sum += b[multiple];
                }
                b[i] = sum % 2;
                if (b[i] == 1) ansN++;
            }

            Console.WriteLine(ansN);
            for (int i = 0; i < N; i++)
            {
                if (b[i] == 1)
                {
                    Console.Write(i + 1); Console.Write(" ");
                }
            }
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 30684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<ll> V;
const ll mod=1e9+7;
ll GCD[maxn];
inline ll fpow(ll a,ll b){
    ll ans=1;
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
int main() {
    ll n,k,ans=0;cin>>n>>k;
    for(int i=k;i>=1;i--){
        GCD[i]=fpow(k/i,n);
        for(int j=2*i;j<=k;j+=i) GCD[i]=(GCD[i]-GCD[j]+mod)%mod;
        (ans+=GCD[i]*i)%=mod;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4352
def main():
    A, B, K = map(int, input().split())
    if 2*K > B - A:
        for j in range(A, B + 1):
            print(j)
    else:
        for i in range(A, A + K):
            print(i)
        for j in range(B-(K-1), B + 1):
            print(j)
main()

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int A, B, K; cin >> A >> B >> K;
  set<int> s;
  for (int i = A; i < min(A + K, B); ++i) s.insert(i);
  for (int i = max(A, B - K + 1); i <= B; ++i) s.insert(i);
  for (int v : s) cout << v << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N, K;
    vector<vector<int>> tree;
    vector<int> label;

    void input() {

    }

    void dfs(int v, int p = -1, int pn = 0, int pnn = 0) {
        label[v] = K - pn - pnn;
        int idx = 1;
        if (v == 0) idx = 0;
        for (auto e : tree[v]) {
            if (e != p) {
                dfs(e, v, 1, idx);
                idx++;
            }
        }
    }

    void solve() {
        input();
        cin >> N;
        cin >> K;
        tree.resize(N);
        label.resize(N);

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

        dfs(0);
        ll ans = 1ll;
        for (auto e : label) {
            ans *= e;
            ans %= MOD;
        }

        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 10752
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve(){
	long long int i, j, k, p, q, r, x, y, u, v, n, m,t;
    cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<endl;



}

int main() {
	ios_base::sync_with_stdio(0);
	int i,t=1;
	//cin>>t;
	for(i=1;i<=t;i++){
		solve();
	}
	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % mod;
		base = ((ll)base * base) % mod;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}




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

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  vector<string>s(h);
  rep(i,h)cin>>s[i];
  int ans=0;
  rep(is,1<<h)rep(js,1<<w){
    int cnt=0;
    rep(i,h)rep(j,w){
      if(is>>i&1)continue;
      if(js>>j&1)continue;
      if(s[i][j]=='#')cnt++;
    }
    if(cnt==k)ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] al = new int[n];
        for(int i = 0; i < n; i++){
            al[i] = sc.nextInt()-1;
        }
        int ans = 0;
        int ind = 0;
        HashSet<Integer> hs = new HashSet<Integer>();
        while(true){
            if(hs.contains(ind)){
                System.out.println(-1);
                break;
            }else if(ind == 1){
                System.out.println(ans);
                break;
            }else{
                ans++;
                hs.add(ind);
                ind = al[ind];
            }
        }
    }
}

Measured memory_bytes: 54956
#include<bits/stdc++.h>
	using namespace std;
	int main()
	{
		int n,a[30],b[30],c[30],i,m=0;
		cin>>n;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
		}
		for(i=0;i<n;i++)
		{
			cin>>b[i];
		}
		for(i=0;i<n-1;i++)
		{
			cin>>c[i];
		}
		for(i=0;i<n;i++){
		if((a[i]-a[i-1])==1 && a[i]!=1)
		{
			m=m+b[a[i]-1]+c[a[i]-2];
		}
		else
		{
			m=m+b[a[i]-1];
		}
		}
		cout<<m<<endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
int main()
{
	int n;
	cin >> n;

	int i = n/111;
	if(n%111 != 0) ++i;

	cout << i*111 <<endl;
	return 0;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("3");
            WillReturn.Add("1");
            WillReturn.Add("4");
            WillReturn.Add("3");
            //4
            //3
            //4
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("2");
            WillReturn.Add("5");
            WillReturn.Add("5");
            //5
            //5
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        var AList = new List<int>();
        foreach (string EachStr in InputList.Skip(1)) {
            AList.Add(int.Parse(EachStr));
        }

        //最大値
        int FirstMax = AList.Max();

        //最大値の個数
        int SecondMax = AList.OrderByDescending(X => X).ElementAt(1);

        for(int I=0;I<=AList.Count-1;I++){
            if (AList[I] == FirstMax) {
                Console.WriteLine(SecondMax);
            }
            else {
                Console.WriteLine(FirstMax);
            }
        }
    }
}


Measured memory_bytes: 35928
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace::std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define endl "\n"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto j:v)output(j);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define SUM(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
inline bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
inline lint mex(vector<lint> s){
    lint res=0;
    sort(all(s));
    while(binary_search(all(s),res))res++;
    return res;
}
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};

int main(){
    lint a,b;
    cin>>a>>b;
    cout<<(lint)ceil((b-1)*1./(a-1));
}

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

int N;
int A[110];
int B[110];
int C[110];

int main(){
   int i=0;
   cin >> N ;
   for (i=0; i<N; i++) A[i]=i+1;
   for (i=0; i<N; i++) C[i]=i+1;
  
for(i=0;i<N;i++){
   B[i]=0;
  
   while(A[i]%2==0){  
    A[i]/=2; 
    B[i]=B[i]+1;
    }
}//ここまでで2で割れる回数は計算できている

 
  int high=B[0];
  int answer=C[0];
  
  for(i=0;i<N;i++){
  if (i==N-1) break ;
  else if(high<B[i+1]) {
    high=B[i+1];
    answer=C[i+1] ;
  }
  }
  cout << answer << endl;
}

Measured memory_bytes: 3124
#include<iostream>
using namespace std;
int main(){
 int n,a,b;
 cin >> n >> a >> b;
 int ans = 0;
 for(int i = 1;i <= n;i++){
  int x = i/10000 + i/1000%10 + i/100%10 + i/10%10 + i%10;
  if(x >= a && x <= b){
   ans += i;
  }
 }
 cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;
	cin>>a>>b;
	if(a>9||b>9){
		cout<<"-1";
	}
	else cout<<(a*b);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

using vi = vector<int>;
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 IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
constexpr ll INF = 1LL<<62;

int sign(int n) {
  if (n == 0)
    return 0;
  if (n >= 1)
    return 1;
  return -1;
}
int main() {
  IN(N);

  vi A(N);
  ll sum = 0;
  REP(i, N) {
    cin >> A[i];
    sum += A[i];
  }
  sum = 0;
  ll ans = INF;
  REP(_s, 2) {
    ll res = 0;
    sum = 0;
    int s = 2 * _s - 1; // sign
    REP(i, N) {
      sum += A[i];
      if (sum == 0) {
        ++res;
        sum = -s;
      }
      if (sign(sum) ==  s) {
        res += abs(sum) + 1;
        sum = -sign(sum);
      }
      s = -s;
    }
    ans = min(ans, res);
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
N = int(input())
b = list(map(int, input().split()))

ans = []

for i in range(N):
    pop = -1
    for j, v in enumerate(b):
        if j+1 == v:
            pop = j
    if pop == -1:
        print(-1)
        exit()
    ans.append(b.pop(pop))
for i in ans[::-1]:
    print(i)

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

int main()
{
  long long a = 0;
  string str;

  cin >> str;

  for (int i = 0; i < str.length(); i++)
  {
    if (str[i] == '+')
      a++;
    else if (str[i] == '-')
      a--;
  }

  cout << a << endl;

}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	ll n, m;
	cin >> n >> m;
	if (n >= m) {
		swap(n, m);
	}
	if (n == 2 || m == 2) {
		cout << 0 << endl;
	}
	else if (n == 1) {
		if (m == 1) {
			cout << 1 << endl;
		}
		else {
			cout << m - 2 << endl;
		}
	}
	else {
		cout << (n - 2) * (m - 2) << endl;
	}
}

Measured memory_bytes: 256
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# MOD = 10**9+7
# MOD = 998244353

n, m = map(int, input().split())
E = [list(map(int, input().split())) for i in range(m)]
graph = [[] for _ in range(n)]
for e in E:
    graph[e[0]-1].append(e[1]-1)
    graph[e[1]-1].append(e[0]-1)

s = [-1]*n
que = deque([0])
while que:
    node = que.popleft()
    for nxt in graph[node]:
        if s[nxt] == -1:
            s[nxt] = node+1
            que.append(nxt)

print("Yes")
for i in range(1, n):
    print(s[i])


Measured memory_bytes: 130800
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

/*
nをb進表記したときに桁の総和がsとなるようなbが存在するかどうか
f(b,n)を満たすbが存在するか

s=n -> n+1が答え

2<=b<=sqrt(n) で全探索

sqrt(n) < b のときnは2桁になる
n = pb+q
p+q = s とb > sqrtn
より n = pb+q > pb > p^2 となり p < sqrtn
なので上位桁について全探索
*/
ll f(ll b, ll n) {
    ll s = 0;
    while (n > 0) {
        s += n % b;
        n /= b;
    }
    return s;
}

int main() {
    ll n, s; cin >> n >> s;
    if (s == n) {
        cout << n+1 << endl; return 0;
    }
    if (s > n) {
        cout << -1 << endl; return 0;
    }
    for (ll b = 2; b <= sqrt(n); b++) {
        if (f(b,n) == s) {
            cout << b << endl; return 0;
        }
    }
    ll res = 1e18;
    for (ll p = 1; p < sqrt(n); p++) {
        ll b = (n-s)/p+1;
        if ((p+n%b) == s) {
            chmin(res,b);
        }
    }
    if (res != 1e18) cout << res << endl;
    else cout << -1 << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;
const lint mod = 1e9 + 7;

lint n, a[50];

int main(){
    scanf("%lld", &n);
    rep(i, n) scanf("%lld", &a[i]);
    lint cnt = 0;
    while(true){
        sort(a, a+n, greater<lint>());
        if(a[0] < n) break;
        lint tmp = (a[0]-n) / n + 1;
        cnt += tmp;
        a[0] -= n * tmp;
        rep(i, n-1) a[i+1] += tmp;
    }
    printf("%lld\n", cnt);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <sstream>
#include <string>
#include <iomanip>

int main()
{
	while (true)
{
	int n;
	std::string line;
	std::getline(std::cin, line, '\n');
	n = std::stoi(line);
	
	if (n == 0) break;
	
	std::getline(std::cin, line, '\n');
	std::stringstream ss(line);
	
	long long A, B;
	A = B = 0;
	
	while (std::getline(ss, line, ' '))
	{
		long long x = std::stoll(line);
		A += x * x;
		B += x;
	}
	
	std::cout << std::fixed << std::setprecision(5);
	std::cout << std::sqrt((A / (double)n) - std::pow((B / (double)n), 2)) << std::endl;
}
	return 0;
}


Measured memory_bytes: 3252
#!/usr/bin/env perl
use strict;
use warnings;

sub is_prime {
  my $n = shift;
  for (my $i = 2; $i * $i <= $n; $i++) {
    if ($n % $i == 0) {
      return 0;
    }
  }
  return 1;
}

my %h;
my $n = <>; chomp $n;
for (my $i = 1; $i <= $n; $i++) {
  for (my $j = 2; $j <= $i; $j++) {
    if (is_prime($j) && $i % $j == 0) {
      my $m = $i;
      my $count = 0;
      while ($m % $j == 0) {
        $m /= $j;
        $count++;
      }
      $h{$j} += $count;
    }
  }
}
my $ans = 1;
while (my ($k, $v) = each(%h)) {
  $ans *= $v + 1;
  $ans %= 1000000007;
}
print $ans;


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
ll c[26],s[400][30],last[400][30],d,now = -100000000000;
vector<ll> ans,w;
ll score(int l, int r, vector<ll> &v){//[l,r)
    ll i,j,res = 0;
    for(i=l;i<r;i++){
        for(j=0;j<26;j++){
            last[i][j] = 0;
        }
    }
    for(i=l;i<r;i++){
        int x = v[i]; x--;
        if(x<0 || x>25){
            //cout << x << endl;
            exit(1);
        }
        res += s[i][x];
        if(i!=0){
            for(j=0;j<26;j++){
                last[i][j] = last[i - 1][j];
            } 
        }
        last[i][x] = i + 1;
        for(j=0;j<26;j++){
            res -= c[j]*(i + 1 - last[i][j]);
        }
    }
    return res;
}

void score2(int x){
    vector<ll> vv; vv.resize(d);
    vector<ll> st;
    int i,j;
    for(i=0;i<d;i++){
        ll k = -1,mx = -1000000000;
        for(j=0;j<26;j++){
            if(s[i][j]>mx){
                mx = s[i][j]; k = j + 1;
            }
        }
        if(k!=-1 && mx>x) vv[i] = k;
        else st.push_back(i);
    }
    for(i=0;i<d;i++){
        if(vv[i]==0){
            bool flag = true;
            for(int x:st){
                if(x==i) flag = false;
            }
            if(flag){
                cout << -1 << endl;
                exit(1);
            }
        }
    }
    for(j=1;j<=26;j++){
        int y = j;
        for(int x:st){
            vv[x] = y; y++;
            if(y==27) y = 1;
        }
        ll sc = score(0,d,vv);
        if(sc>now){
            swap(ans,vv); now = sc; 
        }
    }
}

/*vector<int> score3(){
    vector<int> vv; vv.resize(d);
    int i,j,l = 0;
    for(i=0;i<d;i++){
        if(i%26!=25 && i!=d - 1) continue;
        for(j=l;j<=i;j++){
            
        }
        l = i + 1;
    }
}*/

int main(){
    int i,j; cin >> d;
    for(i=0;i<26;i++) cin >> c[i];
    for(i=0;i<d;i++){
        for(j=0;j<26;j++){
            cin >> s[i][j];
        }
    }
    for(i=0;i<d;i++) ans.push_back(i%26 + 1);
    now = score(0,d,ans);
    for(j=1;j<26;j++){
        w.clear();
        for(i=0;i<d;i++) w.push_back((i + j)%26 + 1);
        int sc = score(0,d,w);
        if(sc>now){
            swap(ans,w); now = sc;
        }
    }
    for(i=0;i<=20000;i+=10) score2(i);
    for(i=0;i<d;i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 3828
#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

void Main() {
    ll H, W, N; cin >> H >> W >> N;
    ll cnt = INF;
    rep2(h, 0, H + 1){rep2(w, 0, W + 1){
        ll tmp_area = H * W - (H - h) * (W - w);
        ll tmp_cnt = h + w;
        if (tmp_area >= N){
            if (tmp_cnt < cnt){cnt = tmp_cnt;}
        }
    }}
    cout << cnt << endl;
}

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


Measured memory_bytes: 3424
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k,ans=0;
    ll a[100010],b[100010];
    cin>>n>>k;
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    // cout<<"------------"<<endl;
    rep(bit,31){
        ll sum=0;
        bool c=false;
        // if((1<<bit)>k) break;
        if((1<<bit)&k) c=true;
        ll s=k-(1<<bit);
        if(c)s=((s>>bit)<<(bit))|((1<<bit)-1);
        else s=k;
        // cout<<bit<<" "<<s<<endl;
        rep(i,n){
            // cout<<i<<" ";
            if((s|a[i])<=s){
                sum+=b[i];
                // cout<<1<<endl;
            }
            // else cout<<0<<endl;
            // bool ok=true;
            /*
            rep(j,31){
                if((1<<j)>a[i]) break;
                if(j>bit){
                    if(((1<<j)&a[i])&&!((1<<j)&k)){
                        ok=false;
                        break;
                    }
                }
                else if(bit==j){
                    if((1<<j)&a[i]){
                        ok=false;
                        break;
                    }
                }
                else{
                    if(c) continue;
                    else if(((1<<j)&a[i])&&!(1<<j)&k){
                        ok=false;
                        break;
                    }
                }
            }
            */
            // cout<<i<<" "<<ok<<endl;
            // if(ok) sum+=b[i];
        }
        // cout<<bit<<"#"<<sum<<endl;
        ans=max(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n;
long long k,to,a[200100],f[200100],l,r,kt,v;
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i],to+=a[i];
	for(int i=1;i<=n;i++) cin>>f[i];
	sort(a+1,a+n+1);
	sort(f+1,f+n+1);
	reverse(f+1,f+n+1);
	if(to==k){
		cout<<0<<endl;
		return 0; 
	}
	for(int i=1;i<=n;i++) r=max(r,a[i]*f[i]);
	while(l<r){
		kt=k;
		v=(l+r)>>1;
		for(int i=1;i<=n;i++){
			if(a[i]*f[i]>v) kt-=(a[i]-v/f[i]);
		}
		if(kt<0) l=v+1;
		else r=v;
	}
	cout<<l<<endl;
	return 0;
}


Measured memory_bytes: 6792
#  入力
n = int(input())
abcList = []
for i in range(n):
    abcList.append(list(map(int, input().split())))


#  dpテーブルの初期化
dp = [abcList[0]]

#  dpテーブルの完成
for i in range(1, n):
    dp.append(
        [
            abcList[i][0] + max(dp[-1][1], dp[-1][2]),
            abcList[i][1] + max(dp[-1][2], dp[-1][0]),
            abcList[i][2] + max(dp[-1][0], dp[-1][1]),
        ]
    )

print(max(dp[-1]))


Measured memory_bytes: 47276
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int a[3][3];
    rep(i,3)rep(j,3)cin>>a[i][j];
    int n;cin>>n;
    rep(k,n){
        int b;cin>>b;
        rep(i,3)rep(j,3){
            if(a[i][j]==b){
                a[i][j]=-1;
            }
        }
    }
    if((a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1)||(a[0][2]==-1&&a[1][1]==-1&&a[2][0]==-1))cout<<"Yes"<<endl;
    else if((a[0][0]==-1&&a[0][1]==-1&&a[0][2]==-1)||(a[1][0]==-1&&a[1][1]==-1&&a[1][2]==-1)||(a[2][0]==-1&&a[2][1]==-1&&a[2][2]==-1))cout<<"Yes"<<endl;
    else if((a[0][0]==-1&&a[1][0]==-1&&a[2][0]==-1)||(a[0][1]==-1&&a[1][1]==-1&&a[2][1]==-1)||(a[0][2]==-1&&a[1][2]==-1&&a[2][2]==-1))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

string T;
string ans;
lld maxv = 0;

void solved(string S, lld n, lld v, int before){
    if(n == T.size()){
        if(maxv < v){
            maxv = v;
            ans = S;
        }
        return;
    }
    if(T[n] == 'P'){
        solved(S+"P",n+1, v, 0);
    } else if(T[n] == 'D'){
        if(before == 0){
            solved(S+"D",n+1, v+2, 1);
        } else {
            solved(S+"D",n+1, v+1, 1);
        }
    } else {
        solved(S+"P",n+1, v, 0);
        if(before == 0){
            solved(S+"D",n+1, v+2, 1);
        } else {
            solved(S+"D",n+1, v+1, 1);
        }
    }
}

int main() {
    string T;
    cin >> T;
    
    for(int i=0;i<T.size();i++){
        if(T[i] == '?'){
            T[i] = 'D';
        }
    }
    cout << T << endl;
}

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

using namespace std;

const int N = 1e6 + 5;
const int INF = 1e9 + 5;
const double PI = acos(-1);

typedef long long ll;

const int X[] = {1, -1, 0, 0};
const int Y[] = {0, 0, 1, -1};

const int mod = 1e9 + 7;

#define int long long

int n, m, dp[55][3030], sum, a[55];

main() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = sum; j >= a[i]; j--) {
            for (int k = 1; k <= i; k++) {
                dp[k][j] += dp[k - 1][j - a[i]];
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += dp[i][i * m];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1408
d = int(input())#365
clist = list(map(int,input().split()))#満足度の下がりやすさci, clist[i-1]でci
satisfactionlist = []#satisfactionlist[d-1][i-1]でsd,i
for _ in range(d):
    satisfactionlist.append(list(map(int,input().split())))

def decrease(clist,d,lastlist):
    sum = 0
    for i in range(26):
        sum += clist[i]*(d-lastlist[i])
    return sum

def calculate(d,clist,satisfactionlist,orderlist):
    satisfaction = 0
    lastlist = [0 for _ in range(26)]#lastlist[i-1] = last(d,i)
    for j in range(d):
        i = orderlist[j]#コンテストiをd日目にやると
        satisfaction += satisfactionlist[j][i-1]
        lastlist[i-1] = j+1
        satisfaction -= decrease(clist,j+1,lastlist)
    return satisfaction

orderlist = []
lastlist = [0 for _ in range(26)]
change = 200
for day in range(change):
    combined1 = [x + y for (x, y) in zip(clist, satisfactionlist[day])]
    max_value = max(combined1)
    max_index = combined1.index(max_value)
    orderlist.append(max_index+1)
    lastlist[max_index] = day+1

for day in range(change,d):
    eval = []
    for i in range(26):
        eval.append(clist[i]*(d-lastlist[i]))
    max_value = max(eval)
    max_index = eval.index(max_value)
    orderlist.append(max_index+1)
    lastlist[max_index] = day+1

for ans in orderlist:
    print(ans)

Measured memory_bytes: 9524
N = int(input())
arr = list(map(int,input().split()))
arr2 = [0]*N
ans = [0]*N
for i in range(N):
    arr2[i] = arr[i]*2
ans[0] = arr2[0]
for i in range(1,N):
    if i % 2 == 1:
        ans[0] -= arr2[i]
    else:
        ans[0] += arr2[i]
ans[0] //= 2
for i in range(1,N):
    ans[i] = arr[i-1]*2 - ans[i-1]
print(*ans)

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


int main() {
    ll letters[30],count=1,sum=0;
    memset(letters,0,sizeof(letters));
    string s;
    cin >> s;
    int size = s.size(); 
    for(int i = 0; i < size; i++) {
        sum++;
        letters[s[i]-'a']++;
    }
    for(int i = 0; i < size; i++) {
        sum--;
        letters[s[i]-'a']--;
        ll dasum = sum - letters[s[i]-'a'];
        count += dasum;
    }
    cout << count << endl;
}


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

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

    set<int> D;
    for (int i = 0; i < N; i++) {
        int d;
        cin >> d;
        D.insert(d);
    }
    cout << D.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"YES"<<endl;
    else cout <<"NO"<<endl;
    return;
}

int main(){
    ll X;
    cin>>X;
    YN(X == 3 || X == 5 || X == 7);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,X;
ll A[100],B,C;
string S;
ll ans;
int main(){

    cin>>N;
    REP(i,N){
        cin>>A[i];
    }
    REP(i,N){
        for(int j=i+1;j<N;j++){
            ans+=A[i]*A[j];
            DEB(ans)END
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=1e9+9;
const ll inf2=1e16+9;
const ll mol=1e9+7;
const int maxn=5e6+9;
const ll maxx=1e12+9;

ll x,k,d;

int main()
{
    cin>>x>>k>>d;
    if(x<0) x=-x;
    ll c1=x/d,ans;
    if(c1>=k) ans=x-d*k;
    else
    {
        ll c2=k-c1;
        x-=c1*d;
        if(c2&1) ans=d-x;
        else ans=x;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REP(i,x,y)	for (int (i)=(x);(i)<(y);(i)++)
#define REP_(i,x,y)	for ((i)=(x);(i)<(y);(i)++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int N;
int a[200001],b[200001];
int aa[200001], bb[200001];
int ans;

int main() {
	cin >> N;
	
	REP(i, 0, N) cin >> a[i];
	REP(i, 0, N) cin >> b[i];

	int k1bit = 0x01;
	int k2bit = 0x02;
	int k3bit = 0x03;
	int k4bit = 0x04;

	REP(k,0,29) {
		int asum = 0;

		REP(i,0,N) aa[i] = a[i]%k2bit;
		REP(i,0,N) bb[i] = b[i]%k2bit;
		sort(bb, bb+N);
		REP(i,0,N) {
			asum += lower_bound(bb,bb+N,k2bit-aa[i]) -
					lower_bound(bb,bb+N,MAX(0,k1bit-aa[i]));
			asum += lower_bound(bb,bb+N,k4bit-aa[i]) -
					lower_bound(bb,bb+N,k3bit-aa[i]);
		}
		ans += (asum % 2)? k1bit : 0;

		k1bit <<= 1;
		k2bit <<= 1;
		k3bit <<= 1;
		k4bit <<= 1;
	}
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  int w,h,n; cin >> w >> h >> n;
  int maxx = w, minx = 0, maxy = h, miny = 0;
  rep(i, n) {
    int x,y,a;
    cin >> x >> y >> a;
    if(a == 1) {
      minx = max(minx, x);
    } else if (a == 2) {
      maxx = min(maxx, x);
    } else if (a == 3) {
      miny = max(miny, y);
    } else {
      maxy = min(maxy, y);
    }
  }

  int y = max(0, maxy - miny);
  int x = max(0, maxx - minx);
  cout << x * y << endl;
}


Measured memory_bytes: 256
n = int(input())
k = int(input())
len_n = len(str(n))
dp = [[[0] * (k + 1) for i in range(2)] for j in range(len_n + 1)]
dp[0][0][0] = 1

for i in range(1, len_n + 1):
    l = int(str(n)[i - 1])
    for m in range(k + 1):
        dp[i][1][m] += dp[i - 1][1][m]
        if l != 0:
            dp[i][1][m] += dp[i - 1][0][m]
        else:
            dp[i][0][m] += dp[i - 1][0][m]
        if m - 1 >= 0:
            dp[i][1][m] += 9 * dp[i - 1][1][m - 1]
            if l != 0:
                dp[i][0][m] += dp[i - 1][0][m - 1]
                dp[i][1][m] += (l - 1) * dp[i - 1][0][m - 1]

print(dp[len_n][0][k] + dp[len_n][1][k])

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void){
    
    int  A,B,H,M;
    double ans =0.0,short_rad,long_rad,omega;
 
    cin >> A >> B >> H >> M;
    
    short_rad = (double(H)+double(M/60.0))/12.0*360.0/180.0;
    long_rad = double(M)/60.0*360.0/180.0;
    
    omega = abs(short_rad-long_rad);
    
    if(omega>1) omega =abs(omega -2.0);
    
        omega = omega*3.14159265358979323846;
        ans = sqrt(pow((double(B)-A*cos(omega)),2.0)+pow(double(A)*sin(omega),2.0));
    
    cout << std::fixed;
    cout << setprecision(18)<< ans << endl;
    
    return 0;
}

Measured memory_bytes: 3972