akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main() {
	int i, j;
	int a, b, c;
	int num = 0;

	scanf("%d %d %d", &a, &b, &c);
	i = a;
	j = b;

	for (i; i <= j; i++) {
		if (c%i == 0)
			num += 1;
	}

	printf("%d\n", num);



	

	return 0;
}

Measured memory_bytes: 1852
#include <stdio.h>

int main()
{
    int a,b,r,d;
    double f;
    scanf("%d%d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %lf\n",d,r,f);
    
    return 0;
}


Measured memory_bytes: 2112
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		if(a > b){
			System.out.println("a > b");
		}else if(a == b){
			System.out.println("a == b");
		}else{
			System.out.println("a < b");
		}
	}
}

Measured memory_bytes: 26312
N = int(input())
A = list(int(input()) for i in range(N))
now=0
ok=False
while(True):
    if A[now]==-1:
        break
    else:
        temp=now
        now=A[now]-1
        A[temp]=-1
    if now==1:
        ok=True
        break
print(A.count(-1) if ok else -1)

Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
int INF=1e7;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
char t[20][20];
int d[20][20][1024];
int h,w;

void change(int a[10],int x){
  for(int i=0;i<10;i++){
    a[i]=x%2;
    x/=2;
  }
}

int change(int a[10]){
  int res=0;
  for(int i=9;i>=0;i--){
    res=res*2+a[i];
  }
  return res;
}

void init(){
  for(int i=0;i<20;i++)
    for(int j=0;j<20;j++)
      for(int k=0;k<1024;k++)
        d[i][j][k]=INF;
}

int solve(int sy,int sx,int cnt){
  queue<int> qx,qy,qbit;
  qy.push(sy);
  qx.push(sx);
  qbit.push(0);
  d[sy][sx][0]=0;
  while(!qy.empty()){
    int y=qy.front();qy.pop();
    int x=qx.front();qx.pop();
    int bit=qbit.front();qbit.pop();
    
    if(bit+1 == (1<<cnt)){
      return d[y][x][bit];
    }
    
    int a[10];
    for(int i=0;i<4;i++){
      change(a,bit);
      int ny=y+dy[i];
      int nx=x+dx[i];
      if(ny<0||nx<0)continue;
      if(ny>=h||nx>=w)continue;
      if(t[ny][nx]=='x')continue;
      if(t[ny][nx]!='.'){
        int num=t[ny][nx]-'0';
        a[num]=1;
      }
      int nbit=change(a);
      int ncost=d[y][x][bit]+1;
      if(ncost < d[ny][nx][nbit]){
        d[ny][nx][nbit]=ncost;
        qy.push(ny);
        qx.push(nx);
        qbit.push(nbit);
      }
    }
  }
  return -1;
}

int main(){
  while(1){
    cin>>w>>h;
    if(w==0&&h==0)break;
    init();
    int cnt=0,si,sj;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin>>t[i][j];
        if(t[i][j]=='*'){
          t[i][j]='0'+cnt;
          cnt++;
        }
        if(t[i][j]=='o'){
          t[i][j]='.';
          si=i;
          sj=j;
        }
      }
    }
    cout<<solve(si,sj,cnt)<<endl;
  }
  return 0;
}

Measured memory_bytes: 2916
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  long long  k;
  cin >> k;

  if (k <= 12){
    cout << k << endl;
    return 0;
  }
  long long  dp[20][11] = {0};

  for (int i = 0; i < 10; i++) {
    dp[1][i] = 1;
  }

  for (int i = 2; i < 20; i++) {
    for (int j = 0; j <= 9; j++) {
      if (j - 1 >= 0) {
        dp[i][j] += dp[i-1][j-1];
      }
      dp[i][j] += dp[i-1][j] + dp[i-1][j+1];
    }
  }

  int num = 0;
  long long ans = 0;
  long long  cnt = 0;
  int m = 0;
  bool f = false;
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= 9; j++) {
      if (cnt + dp[i][j] >= k) {
        num = i;
        ans = j * pow(10, i-1);
        m = max(0, j-1);
        f = true;
        break;
      }
      cnt += dp[i][j];
      if (cnt == k) {
        break;
      }
    }
    if (f || cnt == k) break;
  }

  for (int i = num - 1; i >= 1; i--) {
    for (int j = m; j <= 9; j++) {
      if (cnt + dp[i][j] >= k) {
        ans += j * pow(10, i-1);
        m = max(0, j-1);
        break;
      }
      cnt += dp[i][j];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//use std::cmp::*;
//use std::collections::BTreeSet;
use std::io::*;
use std::str::FromStr;
//portable utility
#[allow(dead_code)]
fn switch<T>(flag: bool, true_value: T, false_value: T) -> T {
    if flag {
        true_value
    } else {
        false_value
    }
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
#[allow(dead_code)]
fn read_string() -> Vec<char> {
    read::<String>().chars().collect()
}
#[allow(dead_code)]
fn read_vector<T: FromStr>(number: usize) -> Vec<T> {
    (0..number).map(|_| read()).collect()
}
fn main() {
    let r: f32 = read();
    println!("{}", 2.0 * r * std::f32::consts::PI);
}


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

int main() {
  int s;
  cin>>s;
  int a=s/1000;
  s -= 1000*a;
  int b=s/100;
  s -= 100*b;
  int c=s/10;
  s -= 10*c;
  int d=s;
  char op1,op2,op3;
 // cout<<a<<b<<c<<d;
  for(int i=0;i<2;i++){
    if(i%2==0) op1='+';
    else op1 ='-';
    for(int j=0;j<2;j++){
      if(j%2==0) op2='+';
      else op2 ='-';
      for(int k=0;k<2;k++){
        int sum=a;
            if(k%2==0) op3='+';
            else op3 ='-';

            if(op1=='+') sum+=b;
            if(op1=='-') sum-=b;
            if(op2=='+') sum+=c;
            if(op2=='-') sum-=c;
            if(op3=='+') sum+=d;
            if(op3=='-') sum-=d;
            if(sum==7){
              cout<<a<<op1<<b<<op2<<c<<op3<<d<<"=7"<<endl;
              return 0;
            }
      }
    }
  }

}


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

namespace ABC086A
{
    class Program
    {
        static void Main(string[] args)
        {

            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            if ((a * b) % 2 == 0)
                Console.WriteLine("Even");
            else
                Console.WriteLine("Odd");
            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 11092
n, m = map(int, input().split())
a = [i for i in range(n + 1)]
def find(a, x):
    if a[x] != x:
        a[x] = find(a, a[x])
    return a[x]
 
 
def unite(a, x, y):
    x = find(a, x)
    y = find(a, y)
    if x != y:
        a[x] = min(x, y)
        a[y] = a[x]
for i in range(m):
  x,y,z=map(int,input().split())
  unite(a,x,y)
ans = -1
for i, v in enumerate(a):
    if i == v:
        ans += 1

print(ans)


Measured memory_bytes: 70432
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  int w,a,b; cin >> w >> a >> b;
  int ans=0;
  if(a+w<b) ans=b-(a+w);
  else if(b+w<a) ans=a-(b+w);
  cout << ans << endl;
  return 0;
}

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

long long cnt;
int n, l, A[1000000];
vector<int> G;

void insertionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n) {
	for (int h = 1;;) {
		if (h > n) break;
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	cnt = 0;

	shellSort(A, n);

	cout << G.size() << endl;
	for (int i = G.size() - 1; i >= 0; i--) {
		cout << G[i];
		if (i) cout << " ";
	}
	cout << endl;
	cout << cnt << endl;
	for (int i = 0; i < n; i++) cout << A[i] << endl;
}



Measured memory_bytes: 7144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int maxn=0x7fffff;
int A[200005];
int B[200005];
int c[200005];
int n,a,b,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>A[i]>>B[i];
	}
	for(int i=0;i<m;i++){
		if(A[i]==1) c[B[i]]=1;
	}
	bool ans=0;
	for(int i=0;i<m;i++){
		if(B[i]==n&&c[A[i]]==1) ans=1;
		if(ans) break;
	}
	if(!ans) cout<<"IM";
	cout<<"POSSIBLE";
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int MD=1e9+7;
vector<int> G[N],son[N];
int n,rs[N],f[N];
int quick_pow(int x,int y) {
	int ans=1;
	while(y) {
		if(y&1) ans=1LL*ans*x%MD;
		y>>=1;
		x=1LL*x*x%MD;
	}
	return ans;
}
void dfs(int u,int fa) {
	rs[u]=1;
	for(auto v:G[u]) {
		if(v==fa) continue;
		son[u].push_back(v);
		dfs(v,u);
		rs[u]+=rs[v];
	}
}
void add(int &x,int y) {
	x+=y;
	if(x>=MD) x-=MD;
	if(x<0) x+=MD;
}
int main() {
	scanf("%d",&n);
	for(int i=1,u,v;i<n;i++) {
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,-1);
	//for(int i=1;i<=n;i++) printf("%d%c",rs[i],i==n?'\n':' ');
	f[0]=1;
	for(int i=1;i<=n;i++) f[i]=1LL*f[i-1]*2%MD;
	for(int i=0;i<=n;i++) add(f[i],-1);
	int ans=0;
	for(int i=1;i<=n;i++) {
		int t=f[n-1];
		add(t,-f[n-rs[i]]);
		for(auto v:son[i]) {
			add(t,-f[rs[v]]);
		}
		add(ans,t);
	}
	printf("%d\n",1LL*ans*quick_pow(f[n]+1,MD-2)%MD);
	return 0;
}

Measured memory_bytes: 34176
<?php
fscanf(STDIN, "%d%d", $A, $B);
$map[1] = 0;
$map[3] = 0;
$map[5] = 0;
$map[7] = 0;
$map[8] = 0;
$map[10] = 0;
$map[12] = 0;

$map[4] = 1;
$map[6] = 1;
$map[9] = 1;
$map[11] = 1;

$map[2] = 3;

echo $map[$A] == $map[$B] ? "Yes" : "No";


Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

const int A = 0, G = 1, C = 2, T = 3;

// AGCT
int dp[110][4][4][4];

void solve(long long N){
    dp[0][T][T][T] = 1;

    for(int i = 1; i <= N; ++i) {
        for(int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                for(int l = 0; l < 4; ++l) {
                    for(int m = 0; m < 4; ++m) {
                        if (j == A && k == G && m == C || j == A && l == G && m == C) {
                            continue;
                        }
                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % MOD;
                    }
                }
            }
        }
        dp[i][A][G][C] = dp[i][G][A][C] = dp[i][A][C][G] = 0;
    }

    int res = 0;
    for(int i = 0; i < 4; ++i) for(int j = 0; j < 4; ++j) for(int l = 0; l < 4; ++l) res = (res + dp[N][i][j][l]) % MOD;

    cout << res << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var inputs  = stdin.toString().split(' ').map(Number);
  var a = inputs[0];
  var b = inputs[1];

  var d = Math.floor(a / b);
  var r = a % b;
  var f = a / b;

  console.log(d,r,Number(f.toFixed(5)));


}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15932
using System;
using System.Linq;
 
class Program
{
    static void Main(string[] args)
    {
      int[] N =new int[2];
        N = Console.ReadLine().Split().Select(int.Parse).ToArray();
      if((N[0]*N[1])%2==1){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
    }
}

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

int main(void)
{
	int n = 1, ans = 0;
	
	cin >> n;
	while (n > 0) {
		vector<string> s(n);
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}

		for (int i = 0; i < n-1; i++) {
			if (s[i][1] == s[i+1][1]) {
				ans++;
			}
		}
		cout << ans << endl;
		ans = 0;

		cin >> n;
	}

	return 0;
}


Measured memory_bytes: 3168
use std::io::*;
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
  let a: i32 = read();
  let b: i32 = read();
  let c: i32 = read();
  let x: i32 = read();
  let mut sum = 0;
  for i_a in 0..a+1 {
    for i_b in 0..b+1 {
      let left = x - 500 * i_a - 100 * i_b;
      if left / 50 <= c && left / 50 >= 0{
        //println!("{}, {}", i_a, i_b);
        sum += 1;
      }
    }
  }
  println!("{}", sum);
}


Measured memory_bytes: 4352
// たなこふ先生の input マクロ (´･_･`)
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn search(x: i64, v: &Vec<i64>) -> (i64, i64) {
    match v.binary_search(&x) {
        Ok(i) => (v[i], v[i]),
        Err(i) => if i == 0 {
            (v[i], v[i])
        } else if i == v.len() {
            (v[i-1], v[i-1])
        } else {
            (v[i-1], v[i])
        }
    }
}

fn solv(x: i64, ss: &Vec<i64>, ts: &Vec<i64>) -> i64 {
    let (s0, s1) = search(x, ss);
    let (t0, t1) = search(x, ts);

    [(s0, t0), (s0, t1), (s1, t0), (s1, t1)].into_iter().map(|&(t, s)| {
        std::cmp::min((x - s).abs(), (x - t).abs()) + (s - t).abs()
    }).min().unwrap()
}

fn main() {
    input! {
        a: usize,
        b: usize,
        q: usize,
        ss: [i64; a],
        ts: [i64; b],
        xs: [i64; q],
    }

    for x in xs {
        println!("{:?}", solv(x, &ss, &ts));
    }
}


Measured memory_bytes: 11256
fun main(args: Array<String>) {
    a61(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a61(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val (min, max, num) = args[0].split(" ").map { it.toInt() }
    println(if (num in (min..max)) "Yes" else "No")
}

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

using namespace std;

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

        if (n[0] == '7' || n[1] == '7' || n[2] == '7'){
                cout << "Yes" << endl;
        }
        else {
                cout << "No" << endl;
        }
        return 0;
}

Measured memory_bytes: 3640
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

/********************************************************/

ll dp[100005];
vll g[100005];

ll f(ll x)
{
	if(sz(g[x])==0) return dp[x]=1;
	if(dp[x]==-1)
	{
		for(auto q:g[x])
			dp[x]=max(dp[x],f(q));
		dp[x]+=1;
	}
	return dp[x];
}


int main()
{
	SPEED;
	ll n,k,t,c=0,i,j,m,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>m;
		// n=s.length();
		// ll a[n];
		memset(dp,-1,sizeof(dp));
		rep(i,m)
		{
			cin>>j>>k;
			g[j].pb(k);
		}
		repe(i,1,n+1)
		{
			if(dp[i]==-1)
				c=max(c,f(i));
		}
		cout<<c-1;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

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

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

#define all(x) begin(x), end(x)



void solve() {
    int n;
    cin >> n;
    
    ull ans = 0;
    
    vector<ull> dp(n + 1, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; i * j <= n; ++j) {
            dp[i * j]++;
        }
    }
    
    for (int i = 1; i <= n; ++i) ans += dp[i] * i;
    cout << ans << endl;
}







    
    
    
    
    
    
    
    
int main() {
    solve();
}

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

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define sint int32_t
#define int long long int
#define all(v) v.begin() , v.end()
#define vii vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;




// void answer()
// {




// }




int32_t main()
{   fastio;

    // int t;
    // cin>>t;
    // while(t--)
    // {
    //     answer();
    // }
    string s;
    cin>>s;
    if(s.back() == 's')cout<<s<<"es"<<"\n";
    else cout<<s<<"s"<<"\n";
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arrA = new int[n];
		for (int i = 0; i < n; i++) {
		    arrA[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] arrB = new int[m];
		for (int i = 0; i < m; i++) {
		    arrB[i] = sc.nextInt();
		}
		for (int i = 0; i < n && i < m; i++) {
		    if (arrA[i] < arrB[i]) {
		        System.out.println(1);
		        return;
		    } else if (arrA[i] > arrB[i]) {
		        System.out.println(0);
		        return;
		    }
		}
		if (n < m) {
		    System.out.println(1);
		} else {
		    System.out.println(0);
		}
	}
}



Measured memory_bytes: 31976
/* include */
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    boost::sort(x);  \
    (x).erase(unique(all(x)), (x).end())
#define mp make_pair
#define r0 return 0

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    int cnt=0;
    int max=0;
    string s;
    string front, end;
    string::size_type pos;
    cin >> n >> s;
    REP(i, 1, n)
    {
        front = s.substr(0, i);
        end = s.substr(i);
        eunique(front);
        rep(i,front.size()){
            pos=end.find(front[i]);
            if(pos!=string::npos){
                cnt++;
            }
        }
        if(max<cnt){
            max=cnt;
        }
        cnt=0;
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 256
import fractions
import sys
input = sys.stdin.readline# 最小公倍数

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)    
a, b, c, d = map(int, input().split())
e = lcm(c, d)
#print("e: {}".format(e))
#print("c: {} - {}".format(b // c, (a - 1) // c))
#print("d: {} - {}".format(b // d, (a - 1) // d))
#print("e: {} - {}".format(b // e, (a - 1) // e))
count_c = b // c - (a - 1) // c
count_d = b // d - (a - 1) // d
count_e = b // e - (a - 1) // e
# b - a の中から d の倍数の個数を取得
#print("count_c: {}".format(count_c))
#print("count_d: {}".format(count_d))
#print("count_e: {}".format(count_e))
print(b - a + 1 - (count_c + count_d - count_e))

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

int main() {

  int h, w;
  while(1){
    cin >> h >> w;
    if(h == 0 && w == 0){
      break;
    }
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        if((i+j)%2 == 0){
          cout << "#";
        }else{
          cout << ".";
        }
      }
      cout << endl;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3088
'use strict';
 
function Main(INPUT) {
    const A = INPUT.split(" ").map(n => Number(n));
    A.sort((a, b) => a - b);
    console.log((A[1] - A[0]) + (A[2] - A[1]));
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){
  int even,odd;
  cin>>even>>odd;
  cout<<even*(even-1)/2+odd*(odd-1)/2<<"\n";  
  return 0;
}

Measured memory_bytes: 256
// test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s,  t;
	cin >> s >> t;
	t.append(s);
	cout << t;
	
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int x, y;
    cin >> x >> y;
    if(y & 1) {
        cout << "No" << endl;
        return 0;
    }
    y /= 2;
    int help = x * 2;
    if(help >= y && help - y <= x) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}




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

int main() {
  int a, b;
  cin >> a >> b;
  int num1 = a % 3;
  int num2 = b % 3;
  int num3 = (a + b) % 3;
  if (num1 == 0 || num2 == 0 || num3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys


def log(s):
    # print("| " + str(s), file=sys.stderr)
    pass


def output(x):
    print(x, flush=True)


def input_ints():
    return list(map(int, input().split()))


def f(n, b, d):
    digits = []
    for _ in range(d):
        digits.append(n % b)
        n //= b
    return reversed(digits)


def main():
    n = int(input()) - 1

    b = 0
    i = 1
    while n >= b + 26**i:
        b += 26**i
        i += 1

    print("".join([chr(k+97) for k in f(n - b, 26, i)]))


main()


Measured memory_bytes: 8992
import collections
import itertools

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N = Z()
    P = [ZZ() for _ in range(N)]
    vecs = set()
    d = collections.defaultdict(int)
    output = 1
    if N == 1:
        print(output)
        return

    for i, j in itertools.combinations(range(N), 2):
        dx, dy = P[i][0] - P[j][0], P[i][1] - P[j][1]
        if dx < 0: dx, dy = -dx, -dy
        vecs.add((dx, dy))

    c = 0
    for v in list(vecs):
        cc = 0
        for i, j in itertools.combinations(range(N), 2):
            if (P[i][0] - P[j][0] == v[0] and P[i][1] - P[j][1] == v[1]) or (P[i][0] - P[j][0] == -v[0] and P[i][1] - P[j][1] == -v[1]):
                cc += 1
        c = max(c, cc)
    output = (N - c)
    print(output)
    return

if __name__ == '__main__':
    main()


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

typedef long long int LL;
typedef unsigned long long uLL;
const int inf = (int)1e9;
const LL INF = (LL)2e18;
const int N = 100005;
const int mod = 1000000007;
const double eps = 1e-8;
const double pi = acos( -1.0 );

int ara[ N ];
int par[ N ];

void makeset( int n ) {
    for( int i = 1; i <= n; i++ ) par[i] = i;
}
int Find( int x ) {
    if( par[x] == x ) return x;
    return par[x] = Find( par[x] );
}
void Union( int a , int b ) {
    int u = Find( a ) , v = Find( b );
    if( u != v ) {
        par[u] = v;
    }
}
int main( int argc, char const *argv[] ) {
    int n , k;
    cin >> n >> k;
    for( int i = 1; i <= n; i++ ) cin >> ara[i];

    makeset( n );

    for( int i = 1; i <= k; i++ ) {
        int u , v;
        cin >> u >> v;
        if( Find(u) != Find(v) ) Union( u , v );
    }
    int ans = 0;
    for( int i = 1; i <= n; i++ ) {
       if( ara[i] == i ) ans++;
       else {
         if( Find(i) == Find(ara[i])) ans++;
       }
    }
    cout << ans << endl;
    return 0;
}








Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<ll> p(51), b(51);

ll f(ll n, ll x) {
	if (x == 0) return 0;
	if (n == 0) return 1;
	if (x <= 1 + b[n-1])
		return f(n-1, x-1);
	// else if (x == (2 + b[n-1]))
	// 	return p[n-1] + 1;
	else
		return p[n-1] + 1 + f(n-1, x-2-b[n-1]);
	// else if (x <= 2 + 2 * b[n-1])
	// 	return p[n-1] + 1 + f(n-1, x-2-b[n-1]);
	// return 2 * p[n-1] + 1;
}

int main() {
	ll n; cin >> n;
	ll x; cin >> x;
	p[0] = b[0] = 1;
	for (int i = 0; i < 50; i++) {
		b[i+1] = b[i] * 2 + 3;
		p[i+1] = p[i] * 2 + 1;
	}
	cout << f(n, x) << '\n';
	return 0;
}


Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int keta(int n){
    int ret = 0;
    while(n/2){
        ret++;
        n/=2;
    }
    return ret;
}

bool check(int a, int b){
    int bit, m = keta(max(a,b));
    rep(bit,m+1){
        if((a & (1 << bit)) && (b & (1 << bit))){
            return false;//same
        }
    }
    return true;

}

int main(void) {
    int i,j;
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin >> a[i];

    long long ans = 0;
    j = 0;
    int xo = a[0];
    loop(i,1,n){

        if(check(xo,a[i]) == false){
            //i-j個から2個えらぶ

            for(;j<=i;j++){
                ans += (i-j);
                xo = xo ^ a[j];
                if(check(xo,a[i])){
                    j++;
                    break;
                }
            }

        }
        xo ^= a[i];

    }
    ans += (ll)(i-j)*(i-j+1)/2;
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
	ll n,x,a,b,ans;
	scanf("%lld%lld",&n,&x);
	ans=n;
	a=x,b=n-x;
	while(1)
	{
		if(a<b)
			swap(a,b);
		ans+=a/b*b*2;
		a%=b;
		if(a==0)
			break;
	}
	ans-=b;
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 128
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int s,w;
  cin >> s >> w;
  if(s <= w) printf("unsafe\n");
  else printf("safe\n");
  return 0;
}


Measured memory_bytes: 3584
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 5000005
#define M 1000000007
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"Yes\n";
#define N cout<<"No\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve()
{
    lli x,k,d;
    cin>>x>>k>>d;
    if(x<0) x=-1*x;
    lli mini = x/d;
    if(k<=mini)
    {
        // er
        x=x-k*d;

        cout<<x;
        return ;
    }

    k=k-mini;

    if(k%2==0)
    {
        x=x-mini*d;
    }
    else
    {
         x=(x-(mini+1)*d);
        
    }

    x=abs(x);


    cout<<x;

    




}
int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";


Measured memory_bytes: 3648
def tax(p,x):
    return p*(100+x) // 100
def solve(X,Y,S):
    best = 0
    for a in range(1,S):
        for b in range(1,S):
            sum = tax(a,X)+tax(b,X)
            if sum == S:
                new = tax(a,Y)+tax(b,Y)
                best = max(best,new)
            if sum > S:
                break
    return best
while True:
    X,Y,S = map(int, input().strip().split( ))
    if X == 0:
        break
    print(solve(X,Y,S))



Measured memory_bytes: 5600
#include <stdio.h>
#include <string.h>

char s[100005];
char ans[100005];

int simulate(int len, char start,char goal){
	int i;
	for(i=1;i<=len-2;i++){
		if(ans[i]=='S'){
			if(s[i]=='o'){
				if(ans[i-1]=='S'){
					ans[i+1]='S';
				}
				else{
					ans[i+1]='W';
				}
			}
			else{
				if(ans[i-1]=='S'){
					ans[i+1]='W';
				}
				else{
					ans[i+1]='S';
				}
			}
		}
		else{
			if(s[i]=='o'){
				if(ans[i-1]=='S'){
					ans[i+1]='W';
				}
				else{
					ans[i+1]='S';
				}
			}
			else{
				if(ans[i-1]=='S'){
					ans[i+1]='S';
				}
				else{
					ans[i+1]='W';
				}
			}
		}
	}


	if(ans[len-1]=='S'){
		if(s[len-1]=='o'){
			if(ans[len-2]=='S'){
				ans[0]='S';
			}
			else{
				ans[0]='W';
			}
		}
		else{
			if(ans[len-2]=='S'){
				ans[0]='W';
			}
			else{
				ans[0]='S';
			}
		}
	}
	else{
		if(s[len-1]=='o'){
			if(ans[len-2]=='S'){
				ans[0]='W';
			}
			else{
				ans[0]='S';
			}
		}
		else{
			if(ans[len-2]=='S'){
				ans[0]='S';
			}
			else{
				ans[0]='W';
			}
		}
	}
	if(ans[0]==start&&ans[len-1]==goal){
	return 1;
	}
	else{
	return 0;
	}
}

int main(){

	int N;

	scanf("%d",&N);
	scanf("%s",s);

	int i;
	int len=strlen(s);

	if(s[0]=='o'){
		ans[0]='S';
		ans[len-1]='S';
		ans[1]='S';
		int ret=simulate(len,ans[0],ans[len-1]);
		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

		ans[0]='S';
		ans[len-1]='W';
		ans[1]='W';
		ret=simulate(len,ans[0],ans[len-1]);

		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

		ans[0]='W';
		ans[len-1]='S';
		ans[1]='W';
		ret=simulate(len,ans[0],ans[len-1]);

		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

		ans[0]='W';
		ans[len-1]='W';
		ans[1]='S';
		ret=simulate(len,ans[0],ans[len-1]);

		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

	}
	else{
		ans[0]='S';
		ans[len-1]='S';
		ans[1]='W';
		int ret=simulate(len,ans[0],ans[len-1]);
		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

		ans[0]='S';
		ans[len-1]='W';
		ans[1]='S';
		ret=simulate(len,ans[0],ans[len-1]);

		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

		ans[0]='W';
		ans[len-1]='S';
		ans[1]='S';
		ret=simulate(len,ans[0],ans[len-1]);

		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}

		ans[0]='W';
		ans[len-1]='W';
		ans[1]='W';
		ret=simulate(len,ans[0],ans[len-1]);

		if(ret==1){
			for(i=0;i<len;i++){
			printf("%c",ans[i]);
			}
			printf("\n");
			return 0;
		}
	}

	printf("-1\n");

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vector<ll> b(a);
    reverse(a.begin(),a.end());
    map<ll,ll> rem;
    for(int i = 0; i < n; i++){
        rem[a[i]]++;
    }
    vector<ll> pow2;
    ll p2 = 2;
    while(p2<2*1e9){
        pow2.push_back(p2);
        p2 *= 2;
    }
    reverse(pow2.begin(),pow2.end());

    int ptr = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(rem[a[i]]==0){
            continue;
        }
        while(a[i]*2<pow2[ptr]){
            ptr++;
        }
        ll target = pow2[ptr] - a[i];
        if(binary_search(b.begin(),b.end(),target)){
            if( (a[i] != target && rem[target]>0) || (a[i] == target && rem[target]>1) ){
                ans++;
                rem[target]--;
                rem[a[i]]--;
            }
        }
    }


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


Measured memory_bytes: 15872
#include <stdio.h>
int main(){
  int i ,n ,m;
long long int total=0 ,ave;
  scanf( "%d" ,&m );
  for( i=0 ; i<m ; i++ ){
    scanf( "%d" ,&n );
    total += n;
  }
  ave = total / m;
  printf( "%lld\n" ,ave );
  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	char a;
	set<char> s;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		s.insert(a);
	}
	if(s.size()==3)cout<<"Three";
	if(s.size()==4)cout<<"Four";
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x = [0] * n
y = [0] * n
for i in range(n):
    x[i], y[i] = map(int, input().split())

import itertools
import math

allx = list(itertools.permutations(x,2))
ally = list(itertools.permutations(y,2))


anslist = []

for (a,b) in zip(allx,ally):
    anslist.append(math.sqrt(pow(a[0] - a[1],2) + pow(b[0] - b[1],2)))

nn = n - 1
lastans = sum(anslist) * nn / len(anslist)

print(lastans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

char S[MAX_N + 1];

void solve()
{
  stack<char> stu;
  int i = 0;
  char prev;
  int cnt = 0;
  while (S[i] != '\0') {
    if (!stu.empty()) {
      // 一致してなければ追加せずに取り出ししてジャンプする
      if (S[i] != stu.top()) {
        cnt += 2;
        stu.pop();
        i++;
        continue;
      }
    }
    stu.push(S[i]);
    i++;
  }
  int ans = cnt;
  // 逆からのパターン
  i = strlen(S);
  stack<char> stb;
  while (S[i] != '\0') {
    if (!stu.empty()) {
      // 一致してなければ追加せずに取り出ししてジャンプする
      if (S[i] != stu.top()) {
        cnt += 2;
        stu.pop();
        i--;
        continue;
      }
    }
    stu.push(S[i]);
    i--;
  }
  ans = max(ans, cnt);
  cout << ans << endl;
}

int main(void)
{
  cin >> S;
  solve();
  return 0;
}


Measured memory_bytes: 512
from bisect import bisect_left
import sys
input = sys.stdin.readline
M = 200001
n = int(input())
l = [None] * n
ans = 10 ** 18
for i in range(n):
    x, y, u = input().split()
    u = ('R', 'D', 'L', 'U').index(u)
    l[i] = (int(x), int(y), u)
for _ in range(3):
    l.sort(key=lambda x: x[0])
    xy = [[] for _ in range(M * 2 - 1)]
    yx = [[] for _ in range(M * 2 - 1)]
    xs = [[] for _ in range(M)]
    k = []
    for i, t in enumerate(l):
        x, y, u = t
        u %= 4
        if u == 3:
            xy[x + y].append(x)
        elif u == 1:
            yx[x - y + M - 1].append(x)
        elif u == 2:
            xs[y].append(x)
        elif u == 0:
            k.append((x, y))
        l[i] = (y, -x + M - 1, u + 1)
    for x, y in k:
        idx = bisect_left(xs[y], x)
        if idx < len(xs[y]):
            ans = min(ans, (xs[y][idx] - x) * 5)
        idx = bisect_left(xy[x + y], x)
        if idx < len(xy[x + y]):
            ans = min(ans, (xy[x + y][idx] - x) * 10)
        idx = bisect_left(yx[x - y + M - 1], x)
        if idx < len(yx[x - y + M - 1]):
            ans = min(ans, (yx[x - y + M - 1][idx] - x) * 10)
if ans == 10 ** 18:
    print('SAFE')
else:
    print(ans)


Measured memory_bytes: 273976
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    string s;
    cin >> s;

    rep(i, 3) cout << s[i];
    cout << endl;

    return 0;
}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToList();

            var b = new int[n];
            var l = a.Count % 2 == 0;
            int begin = 0, end = b.Length - 1;
            for (var i = n - 1; i >= 0; i--)
            {
                var ind = 0;
                if ((i % 2 == 0 && l) || (i % 2 == 1 && !l))
                    ind = end--;
                else
                    ind = begin++;

                b[ind] = a[i];
            }

            Console.WriteLine(string.Join(' ', b));
        }
    }
}


Measured memory_bytes: 62412
#include<stdio.h>
#include<stdlib.h>
int main(void) {
	char S[4]; char B[4]="ABC";
	
	scanf("%s", &S);
	if (strcmp(B, S)==0) {
		printf("ARC");
	}
	else {
		printf("ABC");
	}
	return 0;
}

Measured memory_bytes: 2124
N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7

ans = 1
cnt = [0, 0, 0]
for a in A:
    if a not in cnt:
        ans = 0
        break
    ans = ans * cnt.count(a) % mod
    cnt[cnt.index(a)] += 1
print(ans)


Measured memory_bytes: 86516
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p=0,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n)   cin >> a[i];
    rep(i,n){
        sum+=a[i];
    }
    rep(i,n){
        if((double)sum/(4*m)<=(double)a[i]) p++;
    }
   // cout<<sum/(4*m)<<" "<<p<<endl;
    if(p>=m) cout<<"Yes";
    else cout<<"No";

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5+7;
const ll mod = 1e9+7;
int a[N];
int n,ans;
struct hh
{
    int x,id;
    bool operator <(hh t)
    {
        if(x==t.x)return id<t.id;
        return x<t.x;
    }
}b[N],c[N];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        if(i&1){
            b[a[i]].x++;
        }
        else{
            c[a[i]].x++;
        }
    }
    int m=100000;
    for(int i=1;i<=m;i++){
        b[i].id=i;
        c[i].id=i;
    }
    sort(b+1,b+1+m);
    sort(c+1,c+1+m);
    if(b[m].id==c[m].id){
        ans=n-max(b[m].x+c[m-1].x,b[m-1].x+c[m].x);
    }
    else{
        ans=n-b[m].x-c[m].x;
    }
    cout<<ans<<endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> n;
    REP(i, 1, 50010) {
        double price = (double) i * 1.08;
        if (floor(price) == n) {
            END(i)
        }
    }

    MSG(":(")
}


Measured memory_bytes: 3596
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
map<ll,vpll> adj;
map<ll,int> d,color;
void dijkstra(ll st){
	priority_queue<pll> PQ;//辺の長さのオーバーフローに注意！
	d[st]=0;
	color[st]=1;
	PQ.push(mp(0,st));
	while(!PQ.empty()){
		pll f=PQ.top();
		PQ.pop();
		ll u=f.second;
		color[u]=2;
		if(d[u]< -f.first) continue;
		rep(j,adj[u].size()){
			ll v=adj[u][j].first;
			if(color[v]==2) continue;
			if(d[v]>d[u]+adj[u][j].second){
				d[v]=d[u]+adj[u][j].second;
				PQ.push(mp(-d[v],v));
				color[v]=1;
			}
		}
	}
}
int main(){
	ll N,M;
	scan(N>>M);
	set<int> starail[100001];
	rep(i,M){
		int p,q,c;
		scan(p>>q>>c);
		p--; q--; c--;
		adj[p+N*c].push_back({q+N*c,0});
		adj[q+N*c].push_back({p+N*c,0});
		starail[p].insert(c);
		starail[q].insert(c);
		d[p+N*c]=INF;
		d[q+N*c]=INF;
	}
	rep(i,N){
		d[i+N*1000000]=INF;
		if(!starail[i].empty()){
			for(auto c:starail[i]){
				adj[i+N*1000000].push_back({i+N*c,0});
				adj[i+N*c].push_back({i+N*1000000,1});
			}
		}
	}
	dijkstra(N*1000000);
	/*for(auto x:d){
		printf("%lld : %d\n",x.first+1,x.second);
	}*/
	if(d[N-1+N*1000000]!=INF) prin(d[N-1+N*1000000]);
	else prin(-1);

	return 0;
}


Measured memory_bytes: 170256