akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;

int main() {

    string s;
    cin >> s;

    bool ans=false;
    rep(i, s.size()-1) {
        if (s[i] == s[i+1]) {
            cout << i+1 << ' ' << i+2 << endl;
            ans=true;
            break;
        }
    }

    if (!ans) {
        rep(i, s.size()-2) {
            if (s[i] == s[i+2]) {
                cout << i+1 << ' ' << i+3 << endl;
                ans=true;
                break;
            }
        }
    }

    if (!ans) cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		string s = Console.ReadLine();
		string ans = "";
		string AAA = "ABC";
		string aaa = "abc";
		for(var i=0;i<A;i++){
			string s1 = s.Substring(i,1);
			int a1 = AAA.IndexOf(s1);
			if(i+1==B){
				ans += aaa.Substring(a1,1);
			} else {
				ans += s1;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13280
#include <iostream>
using namespace std;
int main(){
    int i, n, s[13], h[13], c[13], d[13];
    cin >> n;
    for(i = 0; i < 13; i++){
        s[i] = 1;
        h[i] = 1;
        c[i] = 1;
        d[i] = 1;
    }
    string m;
    int t;
    for(i = 0; i < n; i ++){
        cin >> m >> t;
        if(m == "S"){
            s[t-1] = 0;
        }else if(m == "H"){
            h[t-1] = 0;
        }else if(m == "C"){
            c[t-1] = 0;
        }else if(m == "D"){
            d[t-1] = 0;
        }
    }
    for(i = 0; i < 13; i++){
        if(s[i]){cout << "S " << i+1 << endl;}
    }
    for(i = 0; i < 13; i++){
        if(h[i]){cout << "H " << i+1 << endl;}
    }
    for(i = 0; i < 13; i++){
        if(c[i]){cout << "C " << i+1 << endl;}
    }
    for(i = 0; i < 13; i++){
        if(d[i]){cout << "D " << i+1 << endl;}
    }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  cout<<800*n-200*(n/15)<<endl;
}

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

using namespace std;

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

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

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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == i) {
			if (i == 0) {
				int tmp = a[i];
				a[i] = a[i+1];
				a[i+1] = tmp;
			} else if (i == n-1) {
				int tmp = a[i];
				a[i] = a[i-1];
				a[i-1] = tmp;
			} else {
				if (a[i+1] == i+1) {
					int tmp = a[i];
					a[i] = a[i+1];
					a[i+1] = tmp;
				} else {
					int tmp = a[i];
					a[i] = a[i-1];
					a[i-1] = tmp;
				}
			}
			ans++;
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(v) v.begin(),v.end()

template<class T>
inline bool chmin(T& a, T b) {
  if(a>b){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

const ll INF=1e11;

//string dp[3010][3010];
//この方針だと　tle mle が発生したから
//dpの復元を試みる。
const ll maxv=100010;

ll dp[3010][3010]={0};

int main(){
  string s1,s2;
  cin >> s1 >> s2;
  rep(i,s1.size()){
    rep(j,s2.size()){
      if(s1[i]==s2[j]){
        dp[i+1][j+1]=dp[i][j]+1;
      }else{
        if(dp[i][j+1]<dp[i+1][j]){
          dp[i+1][j+1]=dp[i+1][j];
        }else{
          dp[i+1][j+1]=dp[i][j+1];
        }
      }
    }
  }
  //cout << dp[s1.size()][s2.size()] <<endl;
  string ans="";
  ll i=s1.size(),j=s2.size();
  while(i>0 && j>0){
    if(dp[i][j]==dp[i-1][j]){
      --i;
    }else if(dp[i][j]==dp[i][j-1]){
      --j;
    }else if(dp[i][j]==dp[i-1][j-1]+1){
      ans=s1[i-1] + ans;
      --i;
      --j;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 70784
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
M=sum(A2)+A1[0]
now=M
for n in range(N-1):
  now=now+A1[n+1]-A2[n]
  if M<now:
    M=now
print(M)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

ll a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
/*    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    cin>>a;
    for(int i=9;i>=1;i--){
    	if(a%i==0&&a/i<=9){
    		cout<<"Yes"<<endl;
    		return 0;
    		
    	}
    }
    cout<<"No"<<endl;
    

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int x, a, b;
    cin >> x >> a >>b;
    int s = abs(x-a);
    int t = abs(x-b);
    if(s<t) {
        puts("A");
    }else{
        puts("B");
    }
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000

using vi = vector<int>;


int main() {

	int N;

	cin >> N;

	string ans = "Christmas";

	for (int i = 25; i > N; i--)
	{
		ans += " Eve";
	}

	cout << ans << endl;


	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    int count0 = 0, count1 = 0;
    for (int i = 0; i < len; i++)
    {
        if (s[i] == '0')
        {
            count0++;
        }
        else
        {
            count1++;
        }
    }
    cout << min(count0, count1) * 2 << endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
   int N,k;
   cin>>N;
   if(N%1000==0)
   {
       cout<<"0";
   }
   else {
        k=0;
        while(1) {
            if(k>N) break;
            k+=1000;
        }
        cout<<k-N<<"\n";
    }   
}


Measured memory_bytes: 3600
import collections

N = int(input())
A = [int(i) for i in input().split()]

u = collections.Counter(A)
sum = 0
for j, c in u.items():
    sum += int(c * (c - 1) / 2)

s = ""
for k in A:
    s += str(sum - u[k] + 1) + "\n"
print(s)


Measured memory_bytes: 26772
fun main(args : Array<String>) {
    val (r, D, x2000) = readLine()!!.split(" ").map { it.toInt() }

    val x = Array(11, { 0 })
    x[0] = x2000
    (1..10).forEach {
        x[it] = r * x[it-1] - D
        println(x[it])
    }
}

Measured memory_bytes: 37432
from collections import deque

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

dist = [[0 for _ in range(N)] for _ in range(N)]
ans = [0 for _ in range(N)]

for i in range(N):
    for j in range(N):
        tmp1 = abs(i - X + 1) + abs(j - Y + 1) + 1
        tmp2 = abs(i - Y + 1) + abs(j - X + 1) + 1

        dist[i][j] = min(abs(i - j), tmp1, tmp2)
        dist[j][i] = min(abs(i - j), tmp1, tmp2)

for i in range(N):
    for j in range(i+1, N):
        ans[dist[i][j]-1] += 1

for i in range(N - 1):
    print(ans[i])

Measured memory_bytes: 108232
yy, mm, dd = input().split('/')

last_yy, last_mm, last_dd = '2019/04/30'.split('/')
if last_yy < yy:
    ans = 'TBD'
else:
    if last_mm < mm:
        ans = 'TBD'
    else:
        if last_dd < dd:
            ans = 'TBD'
        else:
            ans = 'Heisei'

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define rep2(i,a,b) for (int i=a;i>=b;i--)
#define mod 1000000007
#define INF  1e9+5
#define fr first
#define se second
#define int long long
#define ll long long
#define PI 3.1415926535 
#define pll pair <ll,ll>
#define vl vector <ll>
#define mll map<ll,ll>
#define mci map<char,int>
#define msi map<string,int>
#define vb  vector <bool>
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Senky_Bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 100005;
int height[N];
bool vis[N];
vl adj[N];
ll r=100,c=100;
ll r1,c1;
ll M[100][100];
ll level[N];
bool visited[100][100];
void dfs(ll M[][100], ll R, ll C, bool visited[][100]) 
{
    visited[R][C]=true;
    ll row[] = {-1,-1,-1,0,0,1,1,1};
    ll col[] = {-1,0,1,-1,1,-1,0,1};
    for(int k=0;k<8;k++)
    {
       if(R+row[k]>=0 && R+row[k]<=r1 && C+col[k]>=0 && C+col[k]<=c1 && M[R+row[k]][C+col[k]] && visited[R+row[k]][C+col[k]]==0)
       dfs(M,R+row[k],C+col[k],visited);
    }
}
void bfs(ll s)
{
   queue<ll>q;
   q.push(s);
   vis[s]=true;
   level[s]=0;
   while(!q.empty())
   {
       ll p= q.front();
       q.pop();
       for(int i=0;i<adj[p].size();i++)
       {
           if(vis[adj[p][i]]==false)
           {
               level[adj[p][i]]=level[p]+1;
               vis[adj[p][i]]=true;
               q.push(adj[p][i]);
           }
       }
   }
}
ll power(ll a,ll b,ll c)
{
    ll result=1;
    while(b)
   {
    if(b&1) result=(result*b)%c;
    a=(a*a)%c;
    b=b/2;
   }
   return result%c;
}
signed main()
{
    Senky_Bansal
    IIIT_ALLAHABAD
    ll count[5];
    for(int i=0;i<5;i++)
    	count[i]=0;
    for(int i=0;i<3;i++)
    {
    	ll a,b;
    	cin>>a>>b;
    	count[a]++;
    	count[b]++;
    }
    for(int i=1;i<=4;i++)
    {
    	if(count[i]>2)
        {
        	cout<<"NO"<<endl;
        	return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 3456
import java.util.*;
 
public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	if(A==1){A+=13;}
	if(B==1){B+=13;}
	if(A==B){
	    System.out.println("Draw");
	}else if(A>B){
	    System.out.println("Alice");
	}else{
	    System.out.println("Bob");
	}
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  int x;
  int counter=0;
  std::cin >> a>>b>>c>>x;
  for (int i = 0; i < a+1; i++) {
    /* code */
    for (int j = 0; j < b+1; j++) {
      /* code */
      for (int k = 0; k < c+1; k++) {
        /* code */
        if(i*500+j*100+k*50==x)counter++;
      }
    }
  }
  std::cout << counter << std::endl;
}

Measured memory_bytes: 256
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string,std::to_string(C++11)
#include <vector>			//std::vector
#include <valarray>			//std::valarray
#include <algorithm>		//std::sort
#include <ctime>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs,std::pow,sqrt,sin,cos,round,floor,ceil
#include <fstream>			//std::ifstream,std::ofstream
#include <iomanip>			//std::setprecision,std::setw,std::setfill
#include <random>			//std::random(C++11)
#include <numeric>			//std::accumulate
#include <functional>		//std::greater
#include <chrono>			//std::chrono(C++11)
#include <bitset>			//std::bitset
#include <queue>			//std::queue
#include <stack>			//std::stack

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());
	//std::ofstream ofs("456.csv");
	//std::chrono::system_clock::time_point t_st = std::chrono::system_clock::now();

	std::string temp;
	int n1 = 0, n2 = 0;
	std::stack<int> A;

	while (std::cin >> temp) {
		switch (temp[0]) {
		case '+':
			n1 = A.top(); A.pop();
			n2 = A.top(); A.pop();
			A.push(n1 + n2);
			break;
		case '-':
			n1 = A.top(); A.pop();
			n2 = A.top(); A.pop();
			A.push(n2 - n1);
			break;
		case '*':
			n1 = A.top(); A.pop();
			n2 = A.top(); A.pop();
			A.push(n1 * n2);
			break;
		default:
			A.push(std::stoi(temp));
		}
	}
	std::cout << A.top() << std::endl;
	
	//std::chrono::system_clock::time_point t_ed = std::chrono::system_clock::now();
	//std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t_ed - t_st).count() << "ms" << std::endl;

}

Measured memory_bytes: 3160
N=int(input())
red=sorted([list(map(int,input().split())) for i in range(N)], key=lambda x:-1*x[1])
blue=sorted([list(map(int,input().split())) for i in range(N)])
red = sorted(red, key = lambda x:x[1] * -1)
count=0
for i in red:
    for n,j in enumerate(blue):
        if i[0]<j[0] and i[1]<j[1]:
            count+=1
            del blue[n]
            break
print(count)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    while(1){
        cin>> x >> y;
        if(x==0&&y==0)break;
        if(x>y){
            cout << y << " " << x << endl;
        }else{
            cout << x << " " << y << endl;
        }
    }// Your code here!
    
}



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

bool judge(vector<double> p, vector<double> q){

  int x = 0; 
  for(int i=0; i<p.size(); i++)
    x += pow(p.at(i)-q.at(i),2.0);
  
  if((int)pow(x,0.5) == pow(x,0.5)){
    return true;
  }
  else
    return false;
}


int main(){
  int N, D;
  cin >> N >> D;
  
  int count = 0;
  
  vector<vector<double>> p(N,vector<double>(D));
  
  for(int i=0; i<N; i++){
  
    for(int j=0; j<D; j++){
    
      cin >> p.at(i).at(j);
      
    }
  
  }
  
  for(int i=0; i<N-1; i++){
  
    for(int j=i+1; j<N; j++){

      if( judge(p.at(i),p.at(j)) )
        count++;
    
    }
    
  }

  cout << count << endl;
}

Measured memory_bytes: 384
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next();
  var ans = xArray(0,n);
  var c = nextm(n-1,3);
  for(var i = 0; i < n-1; i++){
    for(var j = 0; j <= i; j++){
      if(ans[j] < c[i][1])ans[j] = c[i][1];
      ans[j] = Math.ceil(ans[j] / c[i][2]) * c[i][2] + c[i][0];
    }
  }
  return ans.join("\n");
}

Measured memory_bytes: 8268
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<functional>
using namespace std;

const int dev = 1e9+7;
typedef unsigned long long ull;

int main(){
    int N, T, A;
    cin >> N;
    ull Ttotal=1, Atotal=1;
    for(int i=0;i<N;i++){
        cin >> T >> A;
        ull Ttimes = (Ttotal-1)/T + 1;
        ull Atimes = (Atotal-1)/A + 1;
        ull Times = max(Ttimes, Atimes);
        Ttotal = T*Times;
        Atotal = A*Times;
    }
    cout << Ttotal+Atotal << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <functional> // greater

using namespace std;

int main(){
    int N, i, a, b, tmp;
    long long ans;
    cin >> N;
    vector<pair<int, int> > pairs_org(N);
    vector<pair<int, int> > pairs_sum(N);

    for (int i = 0; i < N; i++) {
        cin >> a;
        cin >> b;
        pairs_org[i] = make_pair(a, b);
        pairs_sum[i] = make_pair(a+b, i);
    }

    sort(pairs_sum.begin(), pairs_sum.end());

    ans = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2){ //Aoki
            tmp = pairs_sum[N - 1 - i].second;
            ans -= pairs_org[tmp].second;
        }

        else{ //Takahashi
            tmp = pairs_sum[N - 1 - i].second;
            ans += pairs_org[tmp].first;
        }
    }
    cout << ans << '\n'; 
    
}

   

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll > P;
typedef pair<P,ll>Q;

int main(void){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int water = 0;
    int sato = 0;
    for(int i=0;i<=30;i++){
        for(int j=0;j<=30;j++){
            if(i==0 && j==0)continue;
            int t = 100*(a*i+b*j);
            if(t>f)continue;
            int lim = e*(a*i+b*j);
            for(int k=0;k<lim;k++){
                for(int l=0;l<lim;l++){
                    int s = c*k+d*l;
                    if(s>lim)continue;
                    int sum = t+s;
                    if(sum>f)continue;
                    if(water==0 && sato==0){
                        water = t;
                        sato = s;
                        continue;
                    }
                    else{
                        if(t*sato<s*water){
                            sato = s;
                            water = t;
                        }
                    }
                }
            }
        }
    }
    cout<<water+sato<<" "<<sato<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define P 1000000007

int main(){
    int H, W;
    char a[1000][1000];
    int dp[1000][1000];
    cin >> H >> W;
    for(int i = 0; i < H ; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    if(a[0][0] == '.') dp[0][0] = 1;
    else dp[0][0] = 0;
    for(int i = 1; i < W; i++){
        if(a[0][i] == '.') dp[0][i] = dp[0][i-1];
        else dp[0][i] = 0;
    }
    for(int i = 1; i < H ; i++){
        if(a[i][0] == '.') dp[i][0] = dp[i-1][0];
        else dp[i][0] = 0;
        for(int j = 1; j < W; j++){
            if(a[i][j] == '.') dp[i][j] = (dp[i-1][j]+dp[i][j-1])%P;
            else dp[i][j] = 0;
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  map<int, int> mp;
  int mn = 1e9+1;
  rep(i, N) {
    if(A[i] > mn)
      mp[A[i]-mn]++;
    else
      mn = A[i];
  }
  int ans = mp.rbegin()->second;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

vll divisor(ll n) {
    vll ans;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            ans.push_back(i);
            if (i*i != n) ans.push_back(n/i);
        }
    }
    sort(all(ans));
    return ans;
}

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

    int ans = 0;
    rep(i, n) if (i%2 == 0 && divisor(i+1).size() == 8) ans++;

    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int maxn=2e5+10;
int head[maxn],dis[maxn],vis[maxn],num;
struct Le
{
	int nt,to,dis;
}edge[maxn];

void add(int f,int t,int d){
	edge[++num].nt=head[f];
	edge[num].to=t;
	edge[num].dis=d;
	head[f]=num;
} 

int k;

void spfa(int s) {
	queue<int> q;
	memset(dis,0x3f,sizeof(dis));
	dis[s]=1;
	q.push(s);
	vis[s]=1;
	while(!q.empty()) {
		int u=q.front();
		q.pop();vis[u]=0;
		for(int i=head[u];i;i=edge[i].nt) {
			int v=edge[i].to;
			if(dis[v]>dis[u]+edge[i].dis) {
				dis[v]=dis[u]+edge[i].dis;
				if(!vis[v]) {
					q.push(v);
					vis[v]=1;
				}
			}
		}
	}
}

int main() {
	scanf("%d",&k);
	for(int i=0;i<k;++i) {
		add(i,(i+1)%k,1);
		add(i,i*10%k,0);
	}
	spfa(1);
	cout<<dis[0]<<"\n";
	return 0;
}


Measured memory_bytes: 4608
def main():
    suu="abcdefghijklmnopqrstuvwxyz"#26
    n=int(input())
    puts=""
    if n<27:#その数より小さい
        print(suu[n-1])
        return
    while True:
        temp=n%26
        n//=26
        puts=suu[temp-1]+puts
        if temp==0:#補正
            n-=1
        if n<27:
            puts=suu[n-1]+puts
            break
    print(puts)
if __name__ == "__main__":
    main()

Measured memory_bytes: 9156
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int x;
	int t;
	int sqr;
	int max = 0;
	cin >> x;
	sqr = sqrt(x);
	
	for (int i = 2; i <= sqr; i++) {
		t = i;
		for(int j = 0;; j++) {
			t *= i;		
			if (t*i > x)break;
		}
		if (max < t)max = t;
	}
	if (x == 1)cout << 1 << endl;
	else cout << max << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,a,b;
  int numa;

  scanf("%d %d %d",&n,&a,&b);
  numa = a*n;
  
  if(numa>b){
    printf("%d",b);
      }else{
    printf("%d",numa);
  }
  return 0;
}

  


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

int main(void){
  int n, x, m, minm = INT_MAX, i;
  cin >> n >> x;
  for(i = 0; i < n; i++){
    cin >> m;
    x -= m;
    if(m < minm) minm = m;
  }
  cout << n+x/minm << endl;
  return 0;
}


Measured memory_bytes: 256
// Problem: C - Walking Takahashi
// Contest: AtCoder - AtCoder Beginner Contest 175
// URL: https://atcoder.jp/contests/abc175/tasks/abc175_c
// Parsed on: 2020-09-02 13:00:09
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);

using namespace std;

int main() {
    using ll = long long;
    ll x, k, d;
    cin >> x >> k >> d;
    ll absx = abs(x);

    ll req = absx / d;
    if (absx % d) req++;

    if (req > k) {
        cout << absx - (k * d);
    } else {
        int req2 = req - 1;
        if ((k - req2) % 2 == 0) {
            cout << absx - (d * req2);
        } else {
            cout << (d * req) - absx;
        }
    }
    return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll a,b;
  cin >> a >> b;

  if(a%3==0 || b%3==0 || (a+b)%3==0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	ll ans=1LL;
	cin >>n;
	V t(n);
	rep(i,n){
		cin>>t[i];
		ans*=t[i]/__gcd(t[i],ans);
	}
	cout<<ans<<endl;
}

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

int main() {
	map<string, string> mp;
	mp["A"] = "T";
	mp["T"] = "A";
	mp["C"] = "G";
	mp["G"] = "C";
	string S;
	cin >> S; 
	auto itr = mp.find(S);
	cout << itr->second << endl;
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
#define clrg(i, l, r) for(int i=(int)(l);i<(int)(r);i++)vis[i]=0,v[i].clear();
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<< endl;}}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<"\n";
#define ln length()
#define sz size()
#define mod 1000000007
#define elif else if
int32_t main(){
   int n; cin>>n;
   vector<int> v;
   rep(i,0,n){
      int t; cin>>t;
      v.pub(t);
   }
   int mx=0,ans=0;
   rep(i,0,n){
      mx=max(mx,v[i]);
      if(v[i]<mx)ans+=mx-v[i];
   }
   cout<<ans<<"\n";
   return 0;
}
/*
Edge cases? n=1? a[i]<=0?
long vs int? 1LL? 64bits?
Re-read question. Is it as easy as it seems?
KEEP CORRECTING AND SUBMITTING!
*/


Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

int main(){
    ll X, Y, A, B, C;
    cin>>X>>Y>>A>>B>>C;
    ll p[A], q[B], r[C];
    rep(i, A){
        cin>>p[i];
    }
    rep(i, B){
        cin>>q[i];
    }
    rep(i, C){
        cin>>r[i];
    }
    sort(p, p+A, greater<ll>());
    sort(q, q+B, greater<ll>());
    sort(r, r+C, greater<ll>());
    ll ans=0;
    ll pc, qc, rc=0;
    if(X>A){
        rep(i, X-A){
            ans+=r[i];
        }
        rep(i, A){
            ans+=p[i];
        }
        rc+=X-A;
        pc=A-1;
    }
    else{
        rep(i, X){
            ans+=p[i];
        }
        pc=X-1;
    }
    if(Y>B){
        rep(i, Y-B){
            ans+=r[i+rc];
        }
        rep(i, B){
            ans+=q[i];
        }
        rc+=Y-B;
        qc=B-1;
    }
    else{
        rep(i, Y){
            ans+=q[i];
        }
        qc=Y-1;
    }
    int check=0;
    while(min(p[pc], q[qc])<r[rc]){
        ans+=r[rc]-min(p[pc], q[qc]);
        if(rc==C-1){
            check=0;
            break;
        }
        else{
        rc++;
        }
        if(p[pc]<q[qc]){
            if(pc!=0){
                pc--;
            }
            else{
                check=1;
                goto pat1;
            }
        }
        else{
            if(qc!=0){
            qc--;
            }
            else{
                check=2;
                goto pat2;
            }
        }
    }

    pat1:;
    if(check==1){
    while(q[qc]<r[rc]){
        ans+=r[rc]-q[qc];
        if(rc==C-1){
            break;
        }
        else{
        rc++;
        }
        if(qc!=0){
            qc--;
        }
        else{
            break;
        }
    }}
    pat2:;
    if(check==2){
    while(p[pc]<r[rc]){
        ans+=r[rc]-p[pc];
        if(rc==C-1){
            break;
        }
        else{
        rc++;
        }
        if(pc!=0){
            pc--;
        }
        else{
            break;
        }
    }}
    cout<<ans<<endl;


}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int A,B,C,D;cin >> A >> B >> C >> D;
    while(1){
        C -= B;
        if(C<=0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if(A<=0){
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
Vi accum(Vi v){Vi ret((v).size());ret[0]=v[0];REP(i,1,(v).size()) ret[i]=ret[i-1]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
    int n,k;
    cin>>n>>k;
    if(k>(n-1)*(n-2)/2){
        cout<<-1<<endl;
        return 0;
    }
    VPii ans;
    REP(i,0,n-1){
        ans.pb(mp(i,n-1));
    }
    
    int count=0;
    REP(i,0,n-2){
        if(count==(n-1)*(n-2)/2-k) break;
        REP(j,i+1,n-1){
            ans.pb(mp(i,j));
            count++;
            if(count==(n-1)*(n-2)/2-k) break;
        }
        if(count==(n-1)*(n-2)/2-k) break;
    }
    cout<<ans.size()<<endl;
    REP(i,0,ans.size()){
        cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
    }

}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    while (!(a == 0 && b == 0))
    {
        for (int i = 0; i < a; i++)
        {
            for (int j = 0; j < b; j++)
            {
                printf("#");
            }
            printf("\n");
        }
            printf("\n");
        scanf("%d%d", &a, &b);
        
    }

    return 0;
}


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

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

	int n;
	cin >> n;
	vector<int> xs(n);
	for (int& x : xs) {
		cin >> x;
	}

	int a, b;
	{
		vector<int> tmp(xs.begin(), xs.end());
		sort(tmp.begin(), tmp.end());
		a = tmp[n-1];
		b = tmp[n-2];
	}

	for (int x : xs) {
		cout << (x == a ? b : a) << '\n';
	}

	return 0;
}



Measured memory_bytes: 2416
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

x = int(read())
cumsum = list(itertools.accumulate([i for i in range(45000)]))
for i in range(45000):
    if cumsum[i] >= x:
        print(i)
        exit()


Measured memory_bytes: 6680
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cctype>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

intmax_t apply(intmax_t lhs, char op, intmax_t rhs) {
  switch (op) {
  case '+': return lhs+rhs;
  case '-': return lhs-rhs;
  case '*': return lhs*rhs;
  }
  assert(false);
}

intmax_t parse(
    const std::string &s, size_t &i, const std::vector<std::string> &ops,
    size_t preced=0) {

  if (preced == ops.size()) {
    if (s[i] == '(') {
      intmax_t res=parse(s, ++i, ops, 0);
      assert(s[i] == ')');
      ++i;
      return res;
    }
    if (isdigit(s[i])) {
      intmax_t res=s[i]-'0';
      while (++i < s.length() && isdigit(s[i])) 
        res = res*10+s[i]-'0';
      return res;
    }
    assert(false);
  }
  intmax_t res=parse(s, i, ops, preced+1);
  while (i < s.length()) {
    char op=s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    intmax_t tmp=parse(s, ++i, ops, preced+1);
    res = apply(res, op, tmp);
  }
  return res;
}

int main() {
  char buf[256];
  scanf("%s", buf);
  std::string s=buf;
  intmax_t res=INTMAX_MIN;
  for (int i=0; i<3; ++i)
    for (int j=0; j<3; ++j)
      for (int k=0; k<3; ++k) {
        std::vector<std::string> tmp(3);
        tmp[i].push_back('+');
        tmp[j].push_back('-');
        tmp[k].push_back('*');
        std::vector<std::string> ops;
        for (const auto &op: tmp)
          if (!op.empty()) ops.emplace_back(op);

        size_t ind=0;
        res = std::max(res, parse(s, ind, ops));
      }
  printf("%jd\n", res);
}



Measured memory_bytes: 2868
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll x, k, d;
	cin >> x >> k >> d;

	if(x != 0){
		x = abs(x);
		ll jumps = x/d;
		if(jumps >= k){
			cout << (x - k*d); 
		}
		else{
			ll pos1 = x - jumps * d;
			ll pos2 = x - (jumps + 1) * d;
			if(pos1 <= abs(pos2)){
				k -= jumps;
				if(k & 1){
					cout << min(pos1 + d, abs(pos1 - d));
				}
				else{
					cout << pos1;
				}
			}
			else{
				if(abs(pos2) <= x){
					k -= (jumps + 1);
					if(k & 1){
						cout << min(pos2 + d, abs(pos2 - d));
					}
					else{
						cout << abs(pos2);
					}
				}
				else{
					if(k & 1){
						cout << min(x+d, abs(x-d));
					}
					else{
						cout << x;
					}
				}
			}
		}
	}
	if(x == 0){
		if(k & 1){
			cout << d;
		}
		else{
			cout << x;
		}
	}

	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    if (islower(c)) cout << 'a';
    else cout << 'A';
}


Measured memory_bytes: 3660
#include<stdio.h>

int main(void){
  int s;
  double w,h;
  double BMI;
  while(scanf("%d,%lf,%lf",&s,&w,&h)!=EOF){
    BMI = w/h/h;
    if(BMI>=25.0){ printf("%d\n",s); }
  }
  return 0;
}



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

using namespace std;

vector<bool> isPrime;
vector<int> prime;
vector<int> sieve(int n) {
    for (int i=0;i<=n;i++) {
        isPrime.push_back(true);
    }

    for (int i=2;i<=n;i++) {
        if (isPrime[i]) {
            for (int j=i*2;j<=n;j+=i) {
                isPrime[j]=false;
            }

            prime.emplace_back(i);
        }
    }

    return prime;
}

int main() {
    vector<int> p = sieve(1e6);
    int X; cin>>X;

    for (auto i : p) {
        if (i >= X) {
            cout << i << endl;
            break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    int n;cin >> n;
    vector<int> v(3*n);
    rep(i,3*n)cin>>v[i];
    sort(all(v));
    ll ans = 0;
    rep(i,n){
        ans += v[3*n-2-(i)*2];
    }
    cout << ans << endl;
}



Measured memory_bytes: 1536
// ????§???¢???2???a,b??¨?????????????§?C?????????????§???¢?????¢???S???
// ??¨?????????L???a???????????¨????????¨????????????h????±???????
// a,b,???C????????????????????§????????????

#include <iostream>
#include <cmath>
#define PI 3.14159265358979323

using namespace std;

int main(){
    
    int a, b, C; 
    double S, L, h, rad;
    cin >> a >> b >> C;
    
    rad = C * PI / 180.0;
    
    S = 1.0 / 2.0 * a * b * sin(rad);
    L = a + b + sqrt(pow(a,2) + pow(b,2) - 2 * a * b * cos(rad));
    h = b * sin(rad);
    
    cout << fixed << S << endl;
    cout << fixed << L << endl;
    cout << fixed << h << endl;
    return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;


int main() {
    ll N, D; cin >> N >> D;
    ll pos = 1;
    ll time = 0;
    ll d = 0;
    ll ans = 0;

    REP(i, N) {
        ll t, f; cin >> t >> f;
        if (abs(f - pos) > t - time) {
            cout << -1 << endl;
            return 0;
        }

        if (d > 0 && time + pos + f - 2 <= t) {
            ans += (pos - 1) * d;
            pos = f;
            d = 1;
            time = t;
        } else {
            ans += (t - time) * d;
            pos = f;
            d += 1;
            time = t;
            if (d > D) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    ans += (pos - 1) * d;
    cout << ans << endl;
}

Measured memory_bytes: 3120
import java.io.*;
public class Main {

	public static void main (String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while ((line = br.readLine()) != null) {
			String[] numbers = line.split(" ");
			double[] coef = new double[6];
			
			for(int i = 0; i < 6; i++){
				coef[i] = Double.parseDouble(numbers[i]);
			}
			
			double x = (coef[2]*coef[4]-coef[1]*coef[5])/(coef[0]*coef[4]-coef[1]*coef[3]);
			double y = (coef[0]*coef[5]-coef[2]*coef[3])/(coef[0]*coef[4]-coef[1]*coef[3]);
			
			if(x == 0.0){
				x = Math.abs(x); 
			}
			
			if(y == 0.0){
				y = Math.abs(y); 
			}
			
            System.out.printf("%.3f %.3f\n", x, y);
        }
	}
}

Measured memory_bytes: 16972
#include <iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;

int main() {
	int n,m;cin>>n>>m;
	vector<vector<int>> v(n+1,vector<int>(n+1,0));
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		v[a][b]=v[b][a]=1;
	}
	vector<int> p(n-1);
	iota(p.begin(),p.end(),2);
	int ans=0;
	do{
		int ex=1;
		int flag=1;
		for(int i=1;i<n;i++){
			if(v[ex][p[i-1]]==0){
				flag=0;
				break;
			}
			ex=p[i-1];
		}
		if(flag)ans++;
	}while(next_permutation(p.begin(),p.end()));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
ll  n,a;
vector<ll> v(100);
ll dp[51][51][3000];
ll f(ll i,ll c,ll sum)
{
    if(i==n)
        return ((a*c==sum)&&(c!=0));
    if(dp[i][c][sum]!=-1)
        return dp[i][c][sum];
    dp[i][c][sum]=f(i+1,c+1,sum+v[i])+f(i+1,c,sum);
    return dp[i][c][sum];
}
int main()
{       
    IOS;
    cin>>n>>a;
    for(ll i=0;i<n;i++)
        cin>>v[i];
    memset(dp,-1,sizeof(dp));
    cout<<f(0,0,0);
}   

Measured memory_bytes: 61312
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;




int main() {
    int a;
    cin>>a;
    long long dp[100010][3];
    long long data[100010][3];
    rep(i,a){
        rep(j,3){
            cin>>data[i][j];
        }
    }
    rep(i,a){
        rep(j,3){
            rep(k,3){
                if(j!=k){
                    chmax(dp[i+1][k],dp[i][j]+data[i][k]);
                }
            }
        }
    }
    long long res=0;
    rep(i,3){
        chmax(res,dp[a][i]);
    }
    cout<<res<<endl;
}


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

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

int dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);

	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]), dp[i-1]+abs(a[i]-a[i-1]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024