akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Graph {
    int N;
    vector<vector<int>> edge;
    vector<vector<int>> dp;

public:
    Graph(int N) : N(N), edge(N) {}
    void add(int a, int b) {
        edge[a].emplace_back(b);
        edge[b].emplace_back(a);
    }
    int dfs(int i, int state) {
        if (dp[i][state]) return dp[i][state];
        if (state == (1 << N) - 1) {
            return dp[i][state] = 1;
        }
        for (auto &j : edge[i]) {
            if (!(state >> j & 1)) {
                dp[i][state] += dfs(j, state | (1 << j));
            }
        }
        return dp[i][state];
    }
    int ans() {
        dp = vector<vector<int>>(N, vector<int>(1 << N));
        return dfs(0, 1);
    }
};

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

    int N, M;
    cin >> N >> M;
    Graph graph(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        graph.add(a, b);
    }
    cout << graph.ans() << endl;

    return 0;
}


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

int main(){
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for( int i=0; i < 3; i++){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = sum(a)
for i in range(n):
    if b[i]>=a[i]+a[i+1]:
        a[i]=0
        a[i+1]=0
    elif b[i]>=a[i]:
        a[i+1]-=b[i]-a[i]
        a[i]=0
    else:
        a[i]-=b[i]
print(c-sum(a))

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
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;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<bool> ans(N+10, false);
  vector<int>  wa(N+10, 0);
  int cor = 0, wrg = 0;
  rep(i, M) {
    int p; string s;
    cin >> p >> s;
    if(ans[p] == false) {
      if(s == "WA") { wa[p]++; }
      else { ++cor; ans[p]=true; }
    }
  }
  rep(i, N+5) {
    if(ans[i]) wrg+=wa[i];
  }
  cout << cor << " " << wrg;
}

Measured memory_bytes: 640
# coding: utf-8
# Your code here!

import math
import itertools

N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A2 = list(itertools.combinations(A, 2))
A3 = [list(A2[_]) for _ in range(len(A2))]
length = 0
array1, array2, t_array = [], [], []

for x in range(len(A3)):
    t_array = A3[x]
    length = math.sqrt(pow(t_array[0][0] - t_array[1][0], 2) + pow(t_array[0][1] - t_array[1][1], 2))
    array1.append(length)

for k in range(len(array1) - 1):
    array2.append(array1[k] + array1[k + 1])
array2.append(array1[0] + array1[-1])
print(sum(array2) / N)

Measured memory_bytes: 3064
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "limits.h"
#include "bitset"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define ll long long int
#define sp ' '
using namespace std;

ll x;
ll ans;


int main(){
	cin >> x;
	ans = (x / 11) * 2;
	if (x % 11 != 0) {
		if (x % 11 <= 6)
			ans++;
		else ans += 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int N;cin>>N;
    float sol=0;
    typedef pair<float, string> value_type;
    vector<value_type> v(N);
    for(int i=0;i<N;i++){
        cin >> v[i].first >> v[i].second;
    }
    for(int i=0;i<N;i++){
        if(v[i].second == "JPY"){
            sol += v[i].first;
        } else{
            sol += v[i].first * 380000.0;
        }
    }
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int i, x, n;
	
	scanf("%d",&n);
	
	for(i = 1; i <= n; i++){
		
		if(i % 3 == 0){
			
			printf(" %d",i);
		}
		
		else{
			for(x = i; x >= 1; x /= 10){
				
				if(x % 10 == 3){
					
					printf(" %d",i);
					break;
				}
			}
		}
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 600
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        String[] str=buf.readLine().split(" ");
        
        int x=Integer.parseInt(str[0]);
        int y=Integer.parseInt(str[1]);
        int ans=0,flg=1;
        if(x==y){
            System.out.println(x);
            flg=0;
        }
        while(flg==1){
            ans=x%y;
            x=y;
            y=ans;
            if(x%y==0){
                System.out.println(ans);break;
            }
        }
    }
}

Measured memory_bytes: 24272
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T>using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;

int main() {
  int in(N); int in(M);

  vector<int> A(N), B(N);
  priority_queue_rev<pair<int, int>> ab;
  rep(i, N) {
    int in(a); int in(b);
    ab.emplace(a, b);
  }

  priority_queue<int> q;
  int ans = 0;
  rep(i, M) {
    // i+1日前
    while (!ab.empty() && ab.top().first == i+1) {
      q.push(ab.top().second); ab.pop();
    }
    if (!q.empty()) {
      ans += q.top();
      q.pop();
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2676
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
es = []
for _ in range(N):
    x, l = mapint()
    es.append((x+l, x-l))

es.sort()
now = -10**18
idx = 0
ans = 0
while 1:
    if idx==N:
        break
    end, start = es[idx]
    if start>=now:
        now = end
        ans += 1
    idx += 1

print(ans)

Measured memory_bytes: 22816
import std.conv, std.functional, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum MO = 998244353L;
enum LIM = 610;

int M, N;
int[][] A;

void main() {
  auto two = new long[LIM];
  two[0] = 1;
  foreach (i; 1 .. LIM) {
    two[i] = (two[i - 1] * 2) % MO;
  }
  
  try {
    for (; ; ) {
      M = readInt();
      N = readInt();
      A = new int[][](M, N);
      foreach (i; 0 .. M) foreach (j; 0 .. N) {
        A[i][j] = readInt();
      }
      
      auto a = new int[][](M, N);
      foreach (i; 0 .. M) foreach (j; 0 .. N) {
        a[i][j] = A[i][j];
      }
      int r;
      foreach (h; 0 .. N) {
        foreach (i; r .. M) {
          if (a[i][h]) {
            swap(a[r], a[i]);
            break;
          }
        }
        if (r < M && a[r][h]) {
          foreach (i; r + 1 .. M) {
            if (a[i][h]) {
              foreach (j; h .. N) {
                a[i][j] ^= a[r][j];
              }
            }
          }
          ++r;
        }
      }
      debug {
        writeln("rank = ", r);
      }
      long ans;
      ans += two[M + N - 1];
      ans -= two[M + N - 1 - r];
      ans = (ans % MO + MO) % MO;
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}

Measured memory_bytes: 8060
#include <stdio.h>

int main(){
  char s[128], p[128];
  scanf("%s", s);
  scanf("%s", p);
  int plen, slen;
  for(plen = 0; p[plen] != '\0'; plen++){}
  for(slen = 0; s[slen] != '\0'; slen++){}
  for(int i = 0; i < slen; i++){
    int sum = 0;
    int sind = i;
    for(int j = 0; j < plen; j++){
      if(s[sind] == p[j]) sum++;
      else break;
      sind++;
      if(sind >= slen) sind = 0;
    }
    if(sum == plen){
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}



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

ll neutral=0;
struct fenewicktree
{
    vector<ll> bit;
    ll n;
    fenewicktree(ll n)
    {
        //zero based-indexing
        this->n =n;
        bit.assign(n,neutral);

        // one based idexing
        // this->n=n+1;
        // bit.assign(n+1,neutral);
    }
    void build(vector<ll> &v)
    {
        for(int i=0;i<v.size();i++)
            add(i,v[i]);
    }

    ll sum(ll r)
    {
        ll ret=0;
        // zero based indexing
        for(;r>-1;r= (r&(r+1))-1)
        {
            //cout<<" sum "<<r<<endl;
            ret+=bit[r];
        }

        // one based
        // for(++r;r>0;r-= (r& -r))
        //     ret+=bit[r];
        return ret;

    }

    ll sum(ll l,ll r)
    {
        return sum(r)-sum(l-1);
    }

    void add(ll idx,ll delta)
    {
        //zero based
        for(;idx<n;idx=(idx|(idx+1)) )
        {
            //cout<<" add2 "<<idx<<endl;
            bit[idx]+=delta;
        }

        //one based
        // for(++idx;idx<n;idx+= (idx& -idx))
        //     bit[idx]+=delta;
    }
    void show()
    {
        for(auto a:bit) cout<<a<<" ";
        cout<<endl;
    }

};

bool comp(pair<ll,pair<ll,ll>> &p1,pair<ll,pair<ll,ll>> &p2)
{
    return p1.second.second<p2.second.second;
}

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

    ll n,q; cin>>n>>q;
    ll arr[n];for(int i=0;i<n;i++) cin>>arr[i];
    vector<pair<ll,pair<ll,ll>>> v(q);
    for(int tt=0;tt<q;tt++)
    {
        cin>>v[tt].second.first>>v[tt].second.second;
        v[tt].second.first--;
        v[tt].second.second--;
        v[tt].first=tt;
    }
    sort(v.begin(),v.end(),comp);
    //for(auto a:v) cout<<a.second.first<<" "<<a.second.second<<endl;
    ll k=0;
    int last[500001]; memset(last,-1,sizeof last);
    fenewicktree ft(500001);
    map<int,int> mp;
    for(int i=0;i<n;i++)
    {
        if(last[arr[i]]!=-1) ft.add(last[arr[i]],-1);
        last[arr[i]]=i;
        ft.add(i,1);
        while(k<v.size() && v[k].second.second==i)
        {
            mp[v[k].first]= ft.sum(v[k].second.first,v[k].second.second);
            k++;
        }
    }
    for(int i=0;i<v.size();i++) cout<<mp[i]<<"\n";
}


Measured memory_bytes: 48684
#!/usr/bin/env python3
n, k = map(int, input().split())
if k % 2:
    ans = (n // k) ** 3
    print(ans)
else:
    # 全て偶数、or 全て奇数
    ans = ((n + k // 2) // k) ** 3 + (n // k) ** 3
    print(ans)


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

int main(){
  int i,j,cnt=0;
  int n,m;
  cin>>n>>m;
  int p=(int)round(sqrt(m));
  int mi=INT_MAX;
  for(i=1;i<=p;i++){
    if(m%i==0){
      if(i>=n)mi=min(i,mi);
      if(m/i>=n)mi=min(m/i,mi);
    }
  }
  if(mi==INT_MAX)return 1;
  else cout<<m/mi;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
PY = []
for i in range(M):
    PY.append(list(map(int, input().split())))
P_dict = {}
res_dict = {}
for i in range(1, N+1):
    P_dict[i] = []
    res_dict[i] = []
for n, i in enumerate(PY):
    P_dict[i[0]].append((i[1], n))
res = []
for i in range(1, N+1):
    P_dict[i] = sorted(P_dict[i], key=lambda x:x[0])
    tmp_P_num = '{}'.format(i).zfill(6)
    res += [(tmp_P_num + '{}'.format(nn+1).zfill(6), n[1]) for nn, n in enumerate(P_dict[i])]
res = sorted(res, key=lambda x:x[1])
for i in res:
    print(i[0])

Measured memory_bytes: 83544
// Tazoe

#include <iostream>
using namespace std;

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

	long long sum = 0;
	for(int i=0; i<n; i++){
		int m;
		cin >> m;

		sum += (long long)m;
	}

	cout << sum/(long long)n << endl;

	return 0;
}

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

const int cmax = 31;
const int nmax = 501;

int d[cmax][cmax];
int fld[nmax][nmax];

int main() {
    int n, c;
    cin >> n >> c;
    for(int i = 0; i < c; i++) for(int j = 0; j < c; j++) cin >> d[i][j];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            cin >> fld[i][j];
            fld[i][j]--;
        }
    }

    int sum[3][cmax] = {{0}};
    for(int k = 0; k < c; k++) {
        for(int x = 0; x < n; x++) {
            for(int y = 0; y < n; y++) {
                sum[((x+y)%3)][k] += d[fld[x][y]][k];
            }
        }
    }

    int ans = 1e9+1;
    for(int i = 0; i < c; i++) {
        for(int j = 0; j < c; j++) {
            for(int k = 0; k < c; k++) {
                if(i == j || j == k || k == i) continue;
                ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
/*
    24.03.2019 15:00:34
*/

#include <bits/stdc++.h>

using namespace std;

#ifdef HOME
#define TAG_LENGTH 45
#define LR_LEFT left
#define LR_RIGHT right
#define LR_VALUE value
#define LR_SECOND_VALUE mn
#include "C:/C++ libs/print.cpp"
#define showl cout << endl;
#define shows cout << string(5, ' ') + string(TAG_LENGTH, '-') << endl;
#else
#define show(...) 42;
#define showt(...) 42;
#define showl 42;
#define shows 42;
#define print(...) 42;
#define printTree(...) 42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#endif

int main() {
    string s;
    cin >> s;
    for (auto& c : s) {
        if (c == 'T') c = 'A';
        else if (c == 'A') c = 'T';
        else if (c == 'G') c = 'C';
        else if (c == 'C') c = 'G';
    }
    cout << s << '\n';
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
B = lr()
remain = 0
answer = 0
for i in range(N):
    attack = min(A[i], remain)
    answer += attack
    A[i] -= attack
    if A[i] > 0:
        attack = min(A[i], B[i])
        answer += attack
        B[i] -= attack
    remain = B[i]

answer += min(A[N], remain)
print(answer)


Measured memory_bytes: 19172
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
5 6
  2
  |
5-1-3
  |
  4

5 3
1-2-3-4-5
1-2
 -3
 -4
 -5
 -6...をつくっておいて、Kによって辺を増やしていくとか？
(n-1)C2通り
毎回最短検索するとして
100^3*100
1本ふやせば1通りへるっぽい
*/
int main(){
  ll N,K; cin>>N>>K;
  ll high=((N-1)*(N-2))/2;
  if(K>high){
    cout<<-1<<endl;
    return 0;
  }
  vector<pair<ll,ll>> ans(0,make_pair(0,0));
  //最初に線入れ
  for(ll i=2; i<=N; i++) ans.emplace_back(1,i);
  ll i=2, j=3;
  while(K<high){
    if(j>N){
      i++;
      j=i+1;
    }
    ans.emplace_back(i,j);
    j++;
    high--;
  }
  ll asz=ans.size();
  cout<<asz<<endl;
  for(ll i=0; i<asz; i++) cout<<ans[i].first<<" "<<ans[i].second<<endl;
}

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

using namespace std;

int N, T, mod = 1e9 + 7, x[200009];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int Pow (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

/*void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = Pow (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}*/

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &T);
for (int i=1; i<=N; i++)
    scanf ("%d", &x[i]);
int ans = T, dr = T;
for (int i=2; i<=N; i++)
{
    if (x[i] > dr) ans += T;
    else ans += x[i] + T - dr;
    dr = x[i] + T;
}
printf ("%d\n", ans);

return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int A = scan.nextInt();
    int B = scan.nextInt();
    int NA = N * A;
    if (NA > B) {
      System.out.println(B);
    }else {
      System.out.println(NA);
    }
  }
}


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

int main()
{
        int n;
        cin >> n;
        int ans = 0;
        int arr[n+1];
        int b[n+1];
        int c[n+1];
        for(int i = 1; i <= n; i++){
                cin >> arr[i];
        }
        arr[0]=-5;
        for(int i = 0; i < n; i++){
                int x;
                cin >> x;
                ans+=x;
        }
        c[0]=0;
        for(int i = 1; i <= n-1; i++){
                cin >> c[i];
        }
        for(int i = 1; i <= n; i++){
                if((arr[i]-1) == arr[i-1]){
                        ans+=c[arr[i-1]];
                }
        }
        cout << ans << endl;
}


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

 do{
   scanf("%d",&a);  
 }while(a>10000||a<1);

 do{
   scanf("%d",&b);  
 }while(b>10000||b<1);

 do{
   scanf("%d",&c);  
 }while(c>10000||c<1);

if(a>b){
 tmp=a;
 a=b; 
 b=tmp;
}

if(b>c){
 tmp=c;
 c=b; 
 b=tmp;
}

if(a>b){
 tmp=a;
 a=b; 
 b=tmp;
}
printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
N = int(input())

T = 0
X = Y = 0
Flag = 'Even'

for n in range(N):
    Ti,Xi,Yi = [int(x) for x in input().split()]
    if abs(Xi-X) + abs(Yi-Y) > (Ti-T):
        print('No')
        break
    else:
        if Flag == 'Even':
            if (Ti-T) % 2 == 0:#Even and Even = Even
                if (Xi + Yi) % 2 == 0:
                    X = Xi
                    Y = Yi
                    T = Ti
                    continue
                else:
                    print('No')
                    break
            else:#Even and Odd = Odd
                if (Xi + Yi) % 2 == 0:
                    print('No')
                    break
                else:
                    X = Xi
                    Y = Yi
                    T = Ti
                    Flag = 'Odd'
                    continue
        else:#Odd
            if (Ti - T) % 2 == 0: #Odd and Even = Odd
                if(Xi + Yi)% 2 == 0:
                    print('No')
                    break
                else:
                    X = Xi
                    Y = Yi
                    T = Ti
                    continue
            else: #Odd and Odd = Even
                if(Xi + Yi) % 2 == 0:
                    X = Xi
                    Y = Yi
                    T = Ti
                    Flag = 'Even'
                    continue
                else:
                    print('No')
                    break
else:
    print('Yes')

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		for(int i = 0;i<num;i++){
			int a=scan.nextInt();
			int max = a;
			int b=scan.nextInt();
			if(b>max)max=b;
			int c=scan.nextInt();
			if(c>max)check(c,a,b);
			else if(max==b) check(b,a,c);
			else check(a,b,c);
		}
	}
	private static void check(int max,int a,int b){
		if(a==0||b==0||max==0)
			System.out.println("NO");
		else if(max*max==(a*a)+(b*b))
			System.out.println("YES");
		else
			System.out.println("NO");
	}
}

Measured memory_bytes: 23352
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include <ios>
#include <iomanip>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef tuple<ll,ll,ll> Tl;

int atcoder(){
    //入力
    int a,b,c;
    cin >> a >> b >> c;
    cout << min(b/a,c) << ENT;
    return 0;
}

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


Measured memory_bytes: 256
n=int(input())
a,b=map(int,input().split())
for i in range(n-1):
    e,f=map(int,input().split())
    if (a//e+(1 if a%e!=0 else 0))*f>=b:
        b=f*(a//e+(1 if a%e!=0 else 0))
        a=e*(a//e+(1 if a%e!=0 else 0))
    else:
        a=e*(b//f+(1 if b%f!=0 else 0))
        b=f*(b//f+(1 if b%f!=0 else 0))
print(a+b)

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

int main() {
  int n;
  cin >> n;
  int s,k;
  s = n/2;
  k = n%2;
  cout << s + k << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int isprime(int n) { 
	for(int i=2;i*i<=n;i++) { 
		if(n%i==0)return 0; 
	} 
	return 1; 
}
int main() { 
	const int MAX_V=10000;
	int prime[MAX_V+1];
	int i,k,v,n,p1,q1; 
	for(i=2;i<=MAX_V;i++) { 
		prime[i]=isprime(i);
	}  
	while(1) { 
		scanf("%d",&n);
		if(n==0)break;
		for(i=2;i<=n;i++){
			if(prime[i-2] && prime[i]){
				p1=i-2;
				q1=i;
			}
		}
		printf("%d %d\n",p1,q1);
	} 
	return 0; 
}

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

int n, x;
int odd, even, four;
int main(){
	cin>>n;
	while(n --){
		cin>>x;
		if (x % 4 == 0)four++;
		else if (x % 2 == 0)even ++;
		else odd ++;
	}
	string ans;
	if(even == 0){
		if (odd <= four + 1)ans = "Yes";
		else ans = "No";
	}else{
		if(odd <= four)ans = "Yes";
		else ans = "No";
	}
	cout <<ans <<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
weight = list(map(int, input().split()))

s = [0] * (n+1)
total = 0
for i in range(0, n):
    s[i+1] = s[i] + weight[i]
    total += weight[i]

minimum_weight = total

for i in range(1, n):
    minimum_weight = min(minimum_weight, abs(s[i] - (total - s[i])))

print(minimum_weight)

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

long long a, b, c, d, e;

long long gcd(long long x, long long y){
    while(y > 0){
        long long z = x;
        x = y;
        y = z % y;
    }
    return x;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> a >> b >> c >> d;
    long long ile = 0;
    
    long long _a = a;
    if(a % c != 0)
        _a += c - a % c;
    if( _a <= b ){
        ile++;
        ile += (b - _a) / c;
    }
    
    e = c / gcd(c, d) * d;
    _a = a;
    if(a % e != 0)
        _a += e - a % e;
    if( _a <= b ){
        ile--;
        ile -= (b - _a) / e;
    }
    
    _a = a;
    if(a % d != 0)
        _a += d - a % d;
    if( _a <= b ){
        ile++;
        ile += (b - _a) / d;
    }
    
    cout << b - a - ile + 1 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  if(a%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  vector<char>vec(a/2);
  vector<char>veco(a/2);
  for(ll i=0;i<a/2;i++)cin>>vec.at(i);
  for(ll i=0;i<a/2;i++)cin>>veco.at(i);
  if(vec==veco){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
  
}
     


Measured memory_bytes: 3596
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String[] list = s.split("");
		int b1=0,w1=0,b2=0,w2=0;
		for(int i = 0; i < list.length; i++) {
			if(i%2 != 0) {
				if(list[i].equals("0")) {
					b1++;
				}else{
					w1++;
				}
			}else {
				if(list[i].equals("0")) {
					b2++;
				}else {
					w2++;
				}
			}
		}

		if((Math.abs(list.length-b1-w2))>Math.abs(list.length-b2-w1)) {
			System.out.println(Math.abs(list.length-b2-w1));
		}else {
			System.out.println(Math.abs(list.length-b1-w2));
		}
	}
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<int>();
		}
		for(int i=0;i<M;i++){
			E[U[i]].Add(i);
			E[V[i]].Add(i);
		}
		
		long[] A = new long[N];
		long[] B = new long[N];
		
		bool[] used = new bool[N];
		
		A[0] = 1; B[0] = 0;
		used[0] = true;
		
		var Q = new Queue<int>();
		Q.Enqueue(0);
		while(Q.Count > 0){
			var now = Q.Dequeue();
			foreach(var ne in E[now]){
				var nxt = U[ne] == now ? V[ne] : U[ne];
				if(used[nxt]) continue;
				long na = A[now] * -1;
				long nb = S[ne] - B[now];
				A[nxt] = na;
				B[nxt] = nb;
				used[nxt] = true;
				Q.Enqueue(nxt);
			}
		}
		
//Console.WriteLine(String.Join(" ",A));		
//Console.WriteLine(String.Join(" ",B));		
		
		HashSet<long> H = new HashSet<long>();
		long[] min = new long[N];
		long[] max = new long[N];
		long Inf = (long) 1e18;
		for(int i=0;i<N;i++){
			min[i] = - Inf;
			max[i] = Inf;
		}
		
		for(int i=0;i<M;i++){
			int u = U[i];
			int v = V[i];
			long s = S[i];
			
			if(A[u] + A[v] == 0){
				if(B[u] + B[v] != s){
					Console.WriteLine(0);
					return;
				}
				if(A[u] > 0){
					min[u] = Math.Max(min[u],-B[u]);
				} else {
					max[u] = Math.Min(max[u],B[u]);
				}
				if(A[v] > 0){
					min[v] = Math.Max(min[v],-B[v]);
				} else {
					max[v] = Math.Min(max[v],B[v]);
				}
			} else {
				if((s - B[u] - B[v]) % 2 != 0){
					Console.WriteLine(0);
					return;
				}
				var x = (s - B[u] - B[v]) / (A[u] + A[u]);
				H.Add(x);
		
				if(H.Count >= 2){
					Console.WriteLine(0);
					return;
				}
			}
		}
		
		long ma = Inf;
		for(int i=0;i<N;i++) ma = Math.Min(ma, max[i]);
		long mi = -Inf;
		for(int i=0;i<N;i++) mi = Math.Max(mi, min[i]);
		
		
		if(H.Count == 0){
			Console.WriteLine(Math.Max(0, ma - mi - 1));
		} else {
			var xx = (H.ToList())[0];
			Console.WriteLine((xx < ma && xx > mi) ? 1 : 0);
		
		}
		
		
		
		
	}
	
	
	
	int N,M;
	int[] U, V;
	long[] S;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		U = new int[M];
		V = new int[M];
		S = new long[M];
		for(int i=0;i<M;i++){
			d = ria();
			U[i] = d[0] - 1;
			V[i] = d[1] - 1;
			S[i] = d[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 32120
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

#include <cassert>
#include <complex>
#include <vector>
namespace fft {

using Real = long double;
using Complex = std::complex<Real>;
using VecC = std::vector<Complex>;
const Real PI = 3.1415926535897932384626433832795028841971;
void FFT(VecC &a, bool inv = false) {
  int n = a.size();
  int h = 0;
  while ((1 << h) < n)
    h++;
  assert((1 << h) == n);
  // ビットリバース順に
  for (int i = 0; i < n; i++) {
    int j = 0;
    for (int k = 0; k < h; k++) {
      j |= (i >> k & 1) << (h - 1 - k);
    }
    if (i < j) {
      swap(a[i], a[j]);
    }
  }
  // バタフライ演算
  for (int b = 1; b < n; b <<= 1) {
    for (int j = 0; j < b; j++) {
      Complex w =
          std::polar((Real)1.0, (2 * PI) / (2 * b) * j * (inv ? -1 : 1));
      for (int k = 0; k < n; k += b * 2) {
        Complex s = a[j + k];
        Complex t = a[j + k + b] * w;
        a[j + k] = s + t;
        a[j + k + b] = s - t;
      }
    }
  }
  if (inv) {
    for (int i = 0; i < n; i++) {
      a[i] /= n;
    }
  }
}

VecC Conv(VecC a, VecC b) {
  int m = a.size() + b.size() - 1;
  int sz = 1;
  while (m > sz)
    sz <<= 1;
  a.resize(sz);
  b.resize(sz);
  FFT(a);
  FFT(b);
  for (int i = 0; i < sz; i++) {
    a[i] *= b[i];
  }
  FFT(a, true);
  a.resize(m);
  return a;
}

std::vector<ll> Conv(std::vector<ll> &a, std::vector<ll> &b) {
  VecC ac(a.size()), bc(b.size());
  for (int i = 0; i < a.size(); i++)
    ac[i] = Complex(a[i], 0);
  for (int i = 0; i < b.size(); i++)
    bc[i] = Complex(b[i], 0);
  auto c = Conv(ac, bc);
  std::vector<ll> res(c.size());
  for (int i = 0; i < c.size(); i++) {
    res[i] = (ll)(c[i].real() + 0.1);
  }
  return res;
}
} // namespace fft
using ll = long long;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(1e5 + 1, 0);
  for (int i = 0; i < n; i++) {
    int ai;
    cin >> ai;
    a[ai]++;
  }
  auto c = fft::Conv(a, a);
  ll ans = 0;
  for (ll i = c.size() - 1; i >= 0; i--) {
    if (m >= c[i]) {
      ans += c[i] * i;
      m -= c[i];
    } else {
      ans += m * i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 26824
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;
int res = 0;
vector <vector <int>> adj(9);
int n;
void dfs(int i, vector <bool> visited)
{
	visited[i] = true;

	bool flag = false;
	for (auto iter : adj[i])
	{
		if (visited[iter] == false)
		{
			flag = true;
			dfs(iter, visited);
		}
	}

	if (flag == false)
	{
		for (int i = 1; i <= n; i++)
		{
			if (visited[i] == false)
			{
				return;
			}
		}
		res++;
		return;
	}
}
int main(void)
{
	int m, a, b;
	vector <bool> visited(9, false);

	cin >> n >> m;

	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	dfs(1, visited);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		d=b;b=a;a=d;
	}
	if(b>c){
		d=c;c=b;b=d;
	}
	if(a>b){
		d=b;b=a;a=d;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		try (Scanner s = new Scanner(System.in)) {
			int n = s.nextInt();
			int[] array = new int[n];
			for (int i = 0; i < n; i++) {
				array[i] = s.nextInt();
			}
			Arrays.sort(array);
			int start = array[0];
			int end = array[n - 1];
			int min = Integer.MAX_VALUE;
			for (int i = start; i <= end; i++) {
				int sum = 0;
				for (int j = 0; j < n; j++) {
					sum += pow2(array[j] - i);
				}
				if (min > sum) {
					min = sum;
				}
			}
			System.out.println(min);
		}
	}
	private static int pow2(int x) {
		return x * x;
	}
}


Measured memory_bytes: 25428
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
using namespace std;

int main(void) {
	string s,t;
	int p;
	cin >> s;
	t.push_back(s[0]);
	FOR(i, 1, s.size() - 1) {
		if (s[i] == 'S') {
			t.push_back(s[i]);
		}
		else {
			if (t[t.size()-1] == 'S') {
				t.pop_back();
			}
			else {
				t.push_back(s[i]);
			}
		}
	}
	cout << t.size() << endl;
	return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n, a[19], r[3], s[3], ans;

void dfs(int hn, int c)
{
	if (hn == n) {
		int p = 0;
		for (int i = 0; i < 3; i++) {
			if (s[i] == 0) return;
			p += abs(r[i] - s[i]);
		}
		ans = min(ans, p + 10 * (c - 3));
		return;
	}
	for (int i = 0; i < 3; i++) {
		s[i] += a[hn];
		dfs(hn + 1, c + 1);
		s[i] -= a[hn];
	}
	dfs(hn + 1, c);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < 3; i++)
		cin >> r[i];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	ans = 1000000000;
	dfs(0, 0);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


int main()
{
    int a;
    cin>>a;
    int cnt=0;
    for(int i=1;i<=a;i++)
    {
        if(i%2!=0)
            cnt++;
    }
    cout<<(double)cnt/a<<endl;
    return 0;
}






Measured memory_bytes: 256
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define forsaken
#ifdef forsaken
  #define dbg(args...) do {cout << #args << " : "; err(args);} while (0)
#else
  #define dbg(...)
#endif
void err() {std::cout << std::endl;}
template<typename T, typename...Args>
void err(T a, Args...args){std::cout << a << ' '; err(args...);}
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const int inf=0x3f3f3f3f;
const int max_n=105;
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
	inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
int n;
int b[max_n];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",b+i);
    vector<int> ans;
    vector<int> v,t;
    for(int i=0;i<n;i++)v.push_back(i);
    while(!v.empty())
    {
        int id=-1;
        for(int i=0;i<v.size();i++)if(i+1==b[v[i]])id=i;
        if(id==-1)return printf("-1\n"),0;
        ans.push_back(b[v[id]]);
        t.clear();
        for(int i=0;i<v.size();i++)
        {
            if(i==id)continue;
            t.push_back(v[i]);
        }
        v=t;
    }
    reverse(ans.begin(),ans.end());
    for(auto x:ans)printf("%d\n",x);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void chemthan() {
    int test; cin >> test;
    while (test--) {
        long long a, b, c, d; cin >> a >> b >> c >> d;
        if (a < b || b > d) {
            cout << "No\n";
            continue;
        }
        if (b - 1 <= c) {
            cout << "Yes\n";
            continue;
        }
        long long g = __gcd(b, d);
        a %= g;
        long long lo = c + 1 - a + g - 1;
        if (lo < 0) lo = -1; else lo /= g;
        long long hi = b - 1 - a;
        if (hi < 0) hi = -1; else hi /= g;
        if (lo <= hi) {
            cout << "No\n";
        }
        else {
            cout << "Yes\n";
        }
    }
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

const int MAX = 1e6 + 8;
const int SQRTMAX = 1002; 
bool is_prime[MAX];

void sieve() {
  REP(i, MAX) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;

  for (int i = 2; i < SQRTMAX; i++) {
    if (!is_prime[i]) { continue; }
    for (int j = 2 * i; j < MAX; j += i) {
      is_prime[j] = false;
    }
  }
}

int solve(int a, int d, int n) {
  int a_n = a;
  int count = 0;
  while (count != n) {
    if (is_prime[a_n]) { count++; }
    a_n += d;
  }
  return a_n - d;
}

int main() {
  sieve();

  int a, d, n;
  while (cin >> a >> d >> n and a) {
    cout << solve(a, d, n) << endl;
  }
}

Measured memory_bytes: 2136
A, B, C = map(int, input().split())

if A == B == C and A%2 == B%2 == C%2 == 0:
    print(-1)
else:
    ans = 0
    while A%2 == B%2 == C%2 == 0:
        A, B, C = (B+C)//2, (C+A)//2, (A+B)//2
        ans += 1
    print(ans)


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

int main(){
  string S;
  cin >> S;
  int L=S.size();
  int a=-1;
  int b=-1;
  for(int i=0; i<L-1; i++){
    if(S.at(i)==S.at(i+1)){
      a=i+1;
      b=i+2;
      break;
    }
  }
  if(a==-1){
    for(int i=0; i<L-2; i++){
      if(S.at(i)==S.at(i+2)){
        a=i+1;
        b=i+3;
        break;
      }
    }
  }
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 512
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: u128,
        m: u128,
        h: [u128;n],
        com: [[u128;2];m]
    }

    let mut bad_peaks = HashMap::new();

    for i in 0..com.len() {
        // println!("{}", h[com[i][0] as usize - 1]);
        // println!("{}", h[com[i][1] as usize - 1]);
        if h[com[i][0] as usize - 1] > h[com[i][1] as usize - 1] {
            bad_peaks.entry(com[i][1]).or_insert(1);
        } else if h[com[i][0] as usize - 1] == h[com[i][1] as usize - 1] {
            bad_peaks.entry(com[i][1]).or_insert(1);
            bad_peaks.entry(com[i][0]).or_insert(1);
        } else {
            bad_peaks.entry(com[i][0]).or_insert(1);
        }
    }

    // println!("{:?}", bad_peaks);

    println!("{}", n - bad_peaks.len() as u128);
}


Measured memory_bytes: 15304
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    boolean[] a = new boolean[n+1];
    for(int i = 1; i < n + 1; i++){
      a[i] = (i == sc.nextInt());
    }
    long count = 0;
    for(int i = 1; i < n + 1; i++){
      if(!a[i]){
        continue;
      }else{
        count++;
        if(i != n && a[i+1]){
          i++;
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 50408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
    ll n,c,k;cin >>n >> c >> k;
    ll ans=0;
    vl v(n);
    rep(i,n)cin >> v[i];
    sort(all(v));
    rep(i,n){
        ll pre=v[i];
        ll p=i;
        while(i+1-p<c&&v[i+1]-pre<=k)i++;
        ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 1024
import bisect
N=int(input())
A=list(map(int,input().split(' ')))
A_sort = sorted([A[i]-i for i in range(N)])
ans = 0
for n,i in enumerate(A):
    ans += bisect.bisect_right(A_sort,-(n+i))-bisect.bisect_left(A_sort,-(n+i))
print(ans)

Measured memory_bytes: 32300
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, K;
  cin >> N >> K;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int ans = 2100000000, a = 2100000000;
  for (int i = 0; i < N - K + 1; i++) {
    if ((data.at(i) <= 0 && data.at(i + K - 1) <= 0) || (data.at(i) >= 0 && data.at(i + K - 1) >= 0)) {
      if(abs(data.at(i)) <=abs(data.at(i + K - 1))) a = abs(data.at(i + K - 1));
      else a = abs(data.at(i));
      //cout << ans << endl;
    } else {
      if(abs(data.at(i)) <=abs(data.at(i + K - 1))) a = 2 * abs(data.at(i)) + abs(data.at(i + K - 1));
      else a = 2 * abs(data.at(i + K - 1)) + abs(data.at(i));
    }
    if (ans > a) ans = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int w, h;
	int[][] map;
	int[] pen;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) { 
			w = sc.nextInt();
			h = sc.nextInt();
			if( (w|h) == 0 ) break;
			
			map = new int[h][w];
			for(int i=0;i<h;i++) for(int j=0;j<w;j++) {
				map[i][j] = sc.nextInt();
			}
			
			pen = new int[4];
			for(int i=0;i<4;i++) pen[i] = sc.nextInt();
			
			System.out.println(dijkstra());
		}
	}
	
	int[] dx = {-1,0,1,0};
	int[] dy = {0,-1,0,1};
	
	int dijkstra() {
		PriorityQueue<E> que = new PriorityQueue<E>();
		int[][][] c = new int[h][w][4];
		que.add(new E( new P(0,0,2), 0));
		for(int[][] a: c) for(int[] b: a) fill(b, INF);
		c[0][0][2] = 0;
		
		for(;;) {
			E now = que.poll();
			P p = now.p;
			if( isG(p) ) return now.c;
			if( c[p.y][p.x][p.d] != now.c ) continue;
			
			for(int d=0;d<4;d++) {
				int nd = (d + p.d) % 4;
				int nx = p.x + dx[nd];
				int ny = p.y + dy[nd];
				if( nx < 0 || nx >= w || ny < 0 || ny >= h ) continue;
				int nc = now.c + (map[p.y][p.x] == d? 0: pen[d]);
				if( c[ny][nx][nd] > nc ) {
					c[ny][nx][nd] = nc;
					que.add(new E(new P(nx, ny, nd), nc));
				}
			}
		}
		
	}
	
	boolean isG(P p) {
		return p.x == w-1 && p.y == h-1;
	}
	
	class P {
		int x, y, d;
		P(int x, int y, int d) {
			this.x = x;
			this.y = y;
			this.d = d;
		}
	}
	
	class E implements Comparable<E> {
		P p;
		int c;
		E( P p, int c) {
			this.p = p;
			this.c = c;
		}
		@Override
		public int compareTo(E o) {
			// TODO Auto-generated method stub
			return c - o.c;
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main() {

  char a[1];

  scanf("%s", a);
  if (strcmp(a, "A") == 0 ) {
    printf("T");
  } else if (strcmp(a, "C") == 0) {
    printf("G");
  } else if (strcmp(a, "G") == 0) {
    printf("C");
  } else {
    printf("A");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, k; cin >> n >> k;
	if (k == 0) {
		cout << (ll)n*n << endl; return 0;
	}
	ll out = 0;
	rep1(b, n) {
		if (b <= k)continue;
		int d = n / b; out += d * (b - k);
		d = n % b; if (d >= k)out += d - k + 1;
	}
	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    long H, W;
    cin >> H >> W;
    if(H % 3 == 0 || W % 3 == 0){
        cout << 0;
        return 0;
    }
    long mindiff = min(H,W);

    for(int i = 0; i < 2; i++){    
        {
            //3分の1より小さいとき
            long l = floor(W / 3.0) * H;
            long r1 = (W - floor(W / 3.0)) * floor(H/2.0);
            long r2 = (W - floor(W / 3.0)) * ceil(H/2.0);//大きい
//            cout << l << " " << r1 << " " << r2 << endl;
            mindiff = min(mindiff, abs(r2-l));
        }
        {
            long l = ceil(W / 3.0) * H;
            long r1 = (W - ceil(W / 3.0)) * floor(H/2.0);
            long r2 = (W - ceil(W / 3.0)) * ceil(H/2.0);//大きい
//            cout << l << " " << r1 << " " << r2 << endl;
            mindiff = min(mindiff, abs(r1-l));
        }
        long tmp = H;
        H = W;
        W = tmp;
    }
    cout << mindiff << endl;
}


Measured memory_bytes: 256
n = int(input())
ss = []
dic = dict()
for i in range(n):
    s = input().rstrip()
    t = "".join(sorted(s))
    if t in dic:
        dic[t] += 1
    else:
        dic[t] = 1
ans = 0
for key in dic.keys():
    ans += (dic[key] * (dic[key]-1)) // 2

print(ans)

Measured memory_bytes: 17888