akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;

const int N=2e5+5;

pair<int,int> btree[4*N];
int lazy[4*N];
int arr[N],pos[N];
set<int> ss;
int n;

pair<int,int> merge(pair<int,int> a,pair<int,int> b)
{
	return {min(a.F,b.F),min(a.S,b.S)};
}

void build(int node,int l,int r)
{
	if(l==r)
	{
		if(l%2==0)
			btree[node]={arr[l],(1<<30)};
		else
			btree[node]={(1<<30),arr[l]};
		return;
	}
	int mid=(l+r)>>1;
	build(node<<1,l,mid);
	build((node<<1)|1,mid+1,r);
	btree[node]=merge(btree[node<<1],btree[(node<<1)|1]);
}

void push(int node,int l,int r)
{
	if(!lazy[node]) return;
	swap(btree[node].F,btree[node].S);
	if(l!=r)
	{
		lazy[node<<1]^=1;
		lazy[(node<<1)|1]^=1;
	}
	lazy[node]=0;
}

void update(int node,int l,int r,int ind)
{
	if(lazy[node]) push(node,l,r);
	if(ind<l||ind>r) return;
	if(l==r)
	{
		btree[node]={(1<<30),(1<<30)};
		return;
	}
	int mid=(l+r)>>1;
	update(node<<1,l,mid,ind);
	update((node<<1)|1,mid+1,r,ind);
	btree[node]=merge(btree[node<<1],btree[(node<<1)|1]);
}

void update(int node,int l,int r,int ql,int qr)
{
	if(lazy[node]) push(node,l,r);
	if(r<ql||qr<l) return;
	if(ql<=l&&r<=qr)
	{
		lazy[node]=1; push(node,l,r); return;
	}
	int mid=(l+r)>>1;
	update(node<<1,l,mid,ql,qr);
	update((node<<1)|1,mid+1,r,ql,qr);
	btree[node]=merge(btree[node<<1],btree[(node<<1)|1]);
}

pair<int,int> query(int node,int l,int r,int ql,int qr)
{
	if(lazy[node]) push(node,l,r);
	if(r<ql||qr<l) return {(1<<30),(1<<30)};
	if(ql<=l&&r<=qr) return btree[node];
	int mid=(l+r)>>1;
	return merge(query(node<<1,l,mid,ql,qr),query((node<<1)|1,mid+1,r,ql,qr));
}

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
		pos[arr[i]]=i;
	}
	build(1,0,n-1);
	ss.insert(n);
	for(int i=0;i<n;i+=2)
	{
		int x=query(1,0,n-1,0,n-1).F;
		int e=*ss.lower_bound(pos[x]);
		int y=query(1,0,n-1,pos[x],e-1).S;
		update(1,0,n-1,pos[x]); update(1,0,n-1,pos[y]);
		update(1,0,n-1,pos[x],pos[y]);
		ss.insert(pos[x]); ss.insert(pos[y]);
		printf("%d %d ",x,y);
	}
	puts("");
}

Measured memory_bytes: 20908
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,x,y;
	cin >> N >> M >> x >> y;
	printf("%lf %d\n",double(N)*double(M)/2.0,(2*x==N&&2*y==M));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin>>A;
    cin>>B;
      if(A==1 and B==2||B==1 && A==2)
          cout<<"3";
      else if(A==2 && B==3||B==2 && A==3)
           cout<<"1";
          
      else if(A==3 && B==1||B==3 && A==1)
           cout<<"2";
          return 0;}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B := sc.nextInt(), sc.nextInt()
	if A%3 == 0 || B%3 == 0 || (A+B)%3 == 0 {
		fmt.Fprintln(wtr, "Possible")
	} else {
		fmt.Fprintln(wtr, "Impossible")
	}
	wtr.Flush()
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n; cin>>n;
    map<pair<ll,ll>,ll> cnt;
    vector<pair<ll,ll>> b(n);
    rep(i,n){
        ll x,y; cin>>x>>y;
        b[i]=mk(x,y);
    } 
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if(i==j) continue;
        ll dx=b[i].first-b[j].first;
        ll dy=b[i].second-b[j].second;
        if(!(cnt.count(mk(dx,dy)))) cnt[mk(dx,dy)]=0;
        cnt[mk(dx,dy)]++;
    }
    ll maxcnt=0;
    for(auto q:cnt){
        maxcnt=max(maxcnt,q.second);
    }
    cout<<n-maxcnt<<endl;
}

Measured memory_bytes: 384
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto &i:a)
#define rvl(a,n) vl a;FOR(i,0,n){IN(in); a.pb(in);}
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
void solve()
{
	string s;
	cin >> s;
	cout << s;
	if (s[s.length() - 1] == 's')
		cout << "es";
	else
		cout << "s";
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
	ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
	
	if(n < 1200)
		cout << "ABC" << endl;
	else if(n < 2800)
		cout << "ARC" << endl;
	else
		cout << "AGC" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//r s p
//s p r
void solve()
{
	int n,k;
	cin>>n>>k;
	map<string,int> mp;
	cin>>mp["s"]>>mp["p"]>>mp["r"];
	string a;
	cin>>a;
	ll ans=0;
	for(int i=0; i<k; i++)
	{
		bool t=0;
		for(int j=i; j<n; j+=k)
		{
			if(t && j!=i && a[j]==a[j-k])
				t=0;
			else
			{
				string c=a.substr(j,1);
				ans+=(ll)mp[c];
				t=1;
			}
		}
	}
	cout<<ans<<'\n';
}

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

Measured memory_bytes: 512
n_drop, cloth = int(input()), [[int(i) for i in input().split()] for _ in range(10)]
n_stain = sum(sum(i) for i in cloth)
n = (n_stain - 5 * n_drop) // 4

drops_candidate = []
dl = 0
while 2 * dl <= n:
    dm = n - 2 * dl
    ds = n_drop - dm - dl
    if ds >= 0:
        drops_candidate.append([ds, dm, dl])
    dl += 1

dx = (0, -1, 1, 0, 0, -1, -1, 1, 1, -2, 2, 0, 0)
dy = (0, 0, 0, -1, 1, -1, 1, -1, 1, 0, 0, -2, 2)
dd = (5, 9, 13)


def find(cloth, drops, pointer):
    global dy, dx, dd
    for p in range(pointer, 100):
        if cloth[p // 10][p % 10]:
            break
        pointer += 1
    for d in range(3):
        if not drops[d]:
            continue
        dn = dd[d]
        mir = int(d == 2)
        mar = 9 - mir
        for i in range(dn):
            x, y = pointer % 10 + dx[i], pointer // 10 + dy[i]
            if not mir < x < mar or not mir < y < mar:
                continue
            for j in range(dn):
                if not cloth[y + dy[j]][x + dx[j]]:
                    break
            else:
                for j in range(dn):
                    cloth[y + dy[j]][x + dx[j]] -= 1
                drops[d] -= 1
                if sum(drops):
                    result = find(cloth, drops, pointer)
                    if result:
                        result.append((x, y, d + 1))
                        return result
                    for i in range(dn):
                        cloth[y + dy[i]][x + dx[i]] += 1
                    drops[d] += 1
                else:
                    return [(x, y, d + 1)]
    return False


for drops in drops_candidate:
    history = find(cloth, drops, 0)
    if history != False:
        for h in history:
            print(*h)
        break

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

ll dfs(vector<int> graph[], int start, vector<bool> &vis, vector<ll> &dp) {
    vis[start] = true;
    ll pathLen = 0;
    for (int neigh: graph[start]) {
        if (!vis[neigh]) pathLen = max(pathLen, dfs(graph, neigh, vis, dp) + 1);
        else pathLen = max(pathLen, dp[neigh] + 1);
    }
    dp[start] = pathLen;
    return pathLen;
}

ll longestPath(vector<int> graph[], int n) {
    ll ans = LLONG_MIN;
    vector<bool> vis(n, false);
    vector<ll> dp(n, LLONG_MIN);
    for (int i = 0; i < n; i++)
        if (!vis[i])
            ans = max(ans, dfs(graph, i, vis, dp));
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> graph[n];
    for (int i = 0; i < m; i++) {
        int u, v; cin >> u >> v;
        graph[u-1].push_back(v-1);
    }
    cout << longestPath(graph, n) << endl;
    return 0;
}

Measured memory_bytes: 12848
def solve(a, k):
    a.sort()
    min_dist = k
    for i in range(len(a)):
        start = a[i]
        end = a[(i + len(a) - 1) % len(a)]
        if start > end:
            end += k
        min_dist = min(min_dist, end - start)
    return min_dist


if __name__ == "__main__":
    k, n = map(int, input().split())
    a = [int(x) for x in input().split()]
    print(solve(a, k))

Measured memory_bytes: 26444
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::string S, std::string T){
    REP(i, N){
        cout<<S[i]<<T[i];
    }cout<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


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

Measured memory_bytes: 2732
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;

ll check(ll n, ll k){
	while(n%k==0){
		n /= k;
	}
	if (n % k == 1) return 1;
	return 0;
}


int main(){
	ll n, coun1 = 0, coun2 = 0;
	cin >> n;
	for (int i = 1; i <= sqrt(n-1); i++){
		if ((n-1) % i == 0){
			if ((n-1)/i == i) coun1++;
			else coun1 += 2;
		}
	}
	for (int i = 2; i <= sqrt(n); i++){
		if (n%i == 0){
			if (n/i == i){
				coun2 += check(n, i);
			}else{
				coun2 += check(n, n/i);
				coun2 += check(n, i);
			}
		}
	}
	cout << coun1 + coun2 << endl;
	return 0;
}

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


if A%D==0:
    tk=A//D
else:
    tk=A//D+1

if C%B==0:
    ao=C//B
else:
    ao=C//B+1

if tk>=ao:
    print("Yes")
else:
    print("No")



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

int main() {
    string s;
    int x, y, i, j, r = 0, cnt;
    cin >> s >> x >> y;
    queue<int> v, h;
    for (i = 0; i < s.size() && s[i] != 'T'; i++) r++;
    while (i < s.size()) {
        for (cnt = 0, i++; i < s.size() && s[i] != 'T'; i++, cnt++)
            ;
        v.push(cnt);
        for (cnt = 0, i++; i < s.size() && s[i] != 'T'; i++, cnt++)
            ;
        h.push(cnt);
    }
    int vs = v.size(), hs = h.size();
    bool dpv[vs + 1][16001] = {}, dph[hs + 1][16001] = {};
    dpv[0][8000] = true;
    for (i = 0; i < vs; i++) {
        cnt = v.front();
        v.pop();
        for (j = 0; j <= 16000; j++){
            if (dpv[i][j]) dpv[i + 1][j + cnt] = dpv[i + 1][j - cnt] = true;
        }
    }
    dph[0][8000 + r] = true;
    for (i = 0; i < hs; i++) {
        cnt = h.front();
        h.pop();
        for (j = 0; j <= 16000; j++)
            if (dph[i][j]) dph[i + 1][j + cnt] = dph[i + 1][j - cnt] = true;
    }
    cout << (dph[hs][x + 8000] && dpv[vs][y + 8000] ? "Yes" : "No") << endl;
    return 0;
}


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

int countDivisibles(int A, int B, int M) 
{  
	int counter = 0; 
	for (int i = A; i <= B; i++) 
		if (i % M == 0) 
			counter++; 

	return counter; 
} 


int main() 
{ 
	 int A, B, M;
	 cin >> A >> B >> M;
	cout << countDivisibles(A, B, M) << endl; 
	return 0; 
} 


Measured memory_bytes: 3588
#include <bits/stdc++.h>
//#include "./libb/lib.hpp"

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

using namespace std;
const uint64_t MOD = 1000000007;
const double PI = acos(-1);

int main()
{
    uint32_t x[5] = {0, 0, 0, 0, 0};
    
    for(int i = 0; i < 5; i++){
      cin >> x[i];
    }

    int k = 0;
    while(x[k] != 0){
      k++;
    }

    cout << (k + 1) << endl;
    return 0;
}


/* void dfs(int depth, int num){
    if(depth==n){
      ll sum=0;
      for(int i=0; i<q; i++)
        if(A[b[i]-1]-A[a[i]-1]==c[i]) sum += d[i];
      ans = max(ans, sum); return;
    }
    for(int i=num; i<=m; i++){
      A[depth] = i;
      dfs(depth+1, i);
    }
} */

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

typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
//mt19937_64 mrand(42);
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define al(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define asdd cout<<"okok"<<endl;
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define pr(v) for(auto i:v) cout<<i<<" ";cout<<endl
#define prt(a, l, r) for(auto i=l;i<=r;++i) cout<<a[i]<<" ";cout<<endl;
#define pc(x) __builtin_popcount(x)
#define pb push_back

int vis[105];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i=1;i<=k;++i) {
        int t;
        cin>>t;
        while(t--) {
            int x;
            cin>>x;
            vis[x]=1;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;++i) if(!vis[i]) ++cnt;
    cout<<cnt<<endl;
}

Measured memory_bytes: 3568
N = int(input())
a_list = []
for i in range(N):
    a_list.append(int(input()))
    
def gcd(a, b):
    if b > a:
        a, b = b, a
    while b != 0:
        tmp = a % b
        a, b = b, tmp
    return a

def lcm(a, b):
    return a*b // gcd(a, b)

ans = a_list[0]
for i in range(1, N):
    ans = lcm(ans, a_list[i])
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	int a;cin>>a;
	string s;cin>>s;
	if(a>=3200)cout<<s;
	else cout<<"red";
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
public class Main {

	public static void main(String[] args)throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String strARY[] = str.split(" ");
		int a = Integer.parseInt(strARY[0]);
		int b = Integer.parseInt(strARY[1]);
		int c = Integer.parseInt(strARY[2]);
		int x = 0;
		
		ArrayList<Integer> ary = new ArrayList<Integer>();
		
		ary.add(a);
		ary.add(b);
		ary.add(c);
		
		Collections.sort(ary);
		
		System.out.println(ary.get(0) + " " + ary.get(1) + " " + ary.get(2));
	}

}

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

struct Edge {
    int to, id;
    Edge(int to, int id) : to(to), id(id) {}
};

vector<Edge> g[55];

vector<int> es;

bool dfs(int v, int tv, int p = -1) {
    if(v == tv) return true;
    for(Edge e : g[v]) {
        if(e.to == p) continue;
        if(dfs(e.to, tv, v)) {
            es.push_back(e.id);
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
    }
    int m;
    cin >> m;
    vector<long long> eset(m);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        es = vector<int>();
        dfs(a, b);
        for(auto&& e : es) {
            eset[i] |= (1LL << e);
        }
    }
    long long ans = 0;
    for(int i = 0; i < (1 << m); i++) {
        long long mask = 0;
        for(int j = 0; j < m; j++) {
            if(i >> j & 1) mask |= eset[j];
        }
        int white = __builtin_popcountll(mask);
        long long now = 1LL << (n - 1 - white);
        if(__builtin_popcountll(i) % 2 == 0) ans += now;
        else ans -= now;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int k,a,b;
    cin>>k;
    cin>>a>>b;
    int num=0;
    while(num<=b){
        if(num>=a && num<=b){
            cout<<"OK"<<endl;
            return 0;
        }
        num+=k;
    }
    cout<<"NG"<<endl;
    return 0;
}

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

word_count = {}
for _ in range(N):
    s = input()
    if s in word_count:
        word_count[s] += 1
    else:
        word_count[s] = 1

key = lambda x: x[1]
word_count_sorted = sorted(word_count.items(), key=key, reverse=True)

words = []
count = ""
for val in word_count_sorted:
    if not count:
        count = val[1]
    if count == val[1]:
        words.append(val[0])

words.sort()
for word in words:
    print(word)

Measured memory_bytes: 48312
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
typedef long long ll;
typedef pair<ll,ll> p;
template<class t> inline bool chmax(t& a, t b) { if (a < b) { a = b; return 1; } return 0; }
template<class t> inline bool chmin(t& a, t b) { if (a > b) { a = b; return 1; } return 0; }
const ll mod=1000000007;
const ll linf=1ll<<60;
const int inf=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    int n,q;cin >> n >> q;
    for (int i = 0; i < q; i++) {
        int v,w;
        scanf("%d %d",&v,&w);
        if(n==1){
            cout << min(v,w) << endl;
            continue;
        }
        while(v){
            while(v < w){
                w = (w + n - 2) / n;
            }
            if(v == w){
                cout << w << "\n";
                break;
            }
            v = (v + n - 2) / n;
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>  
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const ll MAXN = 1e18;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int r,d,x;
	cin >> r >> d >> x;
	int n = 10;
	int preva = x;
	for(int i=0; i<n; i++){
		int suma = r*preva-d;
		cout << suma << endl;
		preva = suma;
	}
	return 0;
}



Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int v5=0,v7=0;
  if(a==5) v5++;
  if(a==7) v7++;
  if(b==5) v5++;
  if(b==7) v7++;
  if(c==5) v5++;
  if(c==7) v7++;
  cout<<((v5==2 && v7==1)? "YES":"NO")<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    contest = N // 1000
    if contest >= 1:
        print('ABD')
    else:
        print('ABC')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int x;
  cin >> x;
  cout << (x < 30 ? "No" : "Yes") << endl;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
union = list(range(N + 1))
dist = [0] * (N + 1)
rec = [0] * (N + 1)

def ascend(anc):
	count = 0
	while anc != union[anc]:
		rec[count] = anc
		anc = union[anc]
		count += 1
	rec[count] = anc
	for i in range(count - 1, -1, -1):
		dist[rec[i]] += dist[rec[i + 1]]
		union[rec[i]] = anc
	return anc

def connect(l, r, d):
	l_anc = ascend(l)
	r_anc = ascend(r)
	if l_anc != r_anc:
		union[l_anc] = r_anc
		dist[l_anc] = dist[r] + d - dist[l]

def is_union(l, r):
	return ascend(l) == ascend(r)

def check(l, r, d):
	return dist[r] + d == dist[l]

for i in range(M):
	l, r, d = map(int, input().split())
	if is_union(l, r):
		if not check(l, r, d):
			print("No")
			break
	else:
		connect(l, r, d)
else:
	print("Yes")


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

int main()
{
    int k;
    cin >> k;
    int d = k / 2;
    int r = k - d;
    int ans = d * r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
xM = LIST()
xM.sort()

gaps = [0] * (M-1)
for i in range(M-1):
    gaps[i] = xM[i+1] - xM[i]

gaps.sort(reverse=True)
print(sum(gaps[N-1:]))


Measured memory_bytes: 16064
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include<vector>

using namespace std;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long int lli;

int main()
{
  char c;
  cin>>c;
  char n=char((int)c+1);
  cout<<n<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce
from itertools import product
K=int(input())
gcd=0.
for i in range(K):
    for j in range(K):
        a=math.gcd(i+1,j+1)
        for k in range(K):
            gcd+=math.gcd(a,k+1)
print(int(gcd)) 

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

int main() {
    while (true) {
        int e;
        cin >> e;
        if (e == 0) {
            break;
        }
        int result = 1 << 30;
        for (int z = 0; z * z * z <= e; z++) {
            for (int y = 0; y * y <= e - z * z * z; y++) {
                int x = e - y * y - z * z * z;
                if (x + y + z < result) {
                    result = x + y + z;
                }
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 864
use proconio::{fastout, input};

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}
#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }

    let mut ans = a[0];
    for i in 1..a.len() {
        ans = gcd(ans, a[i]);
    }

    println!("{}", ans);
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string s,t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    vector<int> x[26];
    for (int i = 0;i < n;++i) x[s[i]-'a'].push_back(i);
    int ans = 0,p = -1;
    for (int i = 0;i < m;++i) {
        int c = t[i]-'a';
        if (x[c].empty()) {
            cout << "-1" << endl;
            return 0;
        }
        auto it = upper_bound(x[c].begin(),x[c].end(),p);
        if (it == x[c].end()) {
            ans++;
            p = x[c][0];
        } else {
            p = *it;
        }
    }
    cout << (ll)ans*n+p+1 << endl;
    return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl;
#define coYES cout << "YES" << endl;
#define coyes cout << "yes" << endl;
#define coNo cout << "No" << endl;
#define coNO cout << "NO" << endl;
#define cono cout << "no" << endl;
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    int a,b,k,c=0;
    cin >> a >> b >> k;
    vector<int> x(max(a,b));
    rep1(i,x.size()){
        if(a%i==0 and b%i==0){
            x[c]=i;
            c++;
        }
    }
    sort(x.begin(),x.end(),greater<int>());
    cout << x[k-1] << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    string w[109];
    int l=0;
    char t[9];
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> w[i];
        l = w[i].size() - 1;
        
        t[1] = w[i].at(0);
        
        if(i>=2&&t[0]!=t[1]){
            
            cout << "No" << endl;
            return 0;
            
        }
        
        t[0] = w[i].at(l);
        
    }
    
    for(int j=1; j<=n-1; j++){
        
        for(int k=j+1; k<=n; k++){
            
            if(w[j]==w[k]){
                
                cout << "No" << endl;
                return 0;
                
            }
            
        }
        
    }
    
    cout << "Yes" << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    //vector<pair<ll,ll>> vec; 
    vector<ll> vec(394); 
    rep(i, n){
        ll s, l, p; cin >> s >> l >> p;
        for(ll j = s; j <= l; j++){
            //vec.push_back({j, p});
            vec[j] = max(vec[j], p);
        }
    }
    vector<pair<ll,ll>> vec2; 
    
    rep(i, 394){
        if(vec[i] > 0){
            vec2.push_back(make_pair(i, vec[i]));
        }
    }
    /*
    rep(i, vec2.size()){
        cout << vec2[i].first << " " << vec2[i].second << endl;
    }
    */
    

    vector<vector<ll>> dp(vec2.size()+1, vector<ll>(394, -1));
    dp[0][0] = 0;
    dp[1][0] = 0;

    for(ll i = 0; i < vec2.size(); i++){
        for(ll j = 0; j <= 393; j++){
            if(j - vec2[i].first >= 0 && dp[i + 1][j - vec2[i].first] != -1){
            //if(j - i >= 0 && dp[i + 1][j - i] != -1){
                dp[i+1][j] = max(dp[i][j], dp[i + 1][j - vec2[i].first] + vec2[i].second);
                //dp[i+1][j] = max(dp[i][j], dp[i + 1][j - i] + vec[i]);
            }else{
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            }
        }
    }

    ll m; cin >> m;
    vector<ll> ans;
    rep(i, m){
        ll w; cin >> w;
        ans.push_back(dp[vec2.size()][w]);
        
        if(dp[vec2.size()][w] == -1){
            cout << -1 << endl;
            return 0;
        }
        
    }
    
    rep(i, m){
        cout << ans[i] << endl;
    }
    

}


Measured memory_bytes: 4208
dist = [0] * 6
for i in range(int(raw_input())):
    height = float(raw_input())
    if height < 165: dist[0] += 1
    elif height < 170: dist[1] += 1
    elif height < 175: dist[2] += 1
    elif height < 180: dist[3] += 1
    elif height < 185: dist[4] += 1
    else: dist[5] += 1
for i in range(6):
    print "%d:%s" % (i + 1, '*' * dist[i])

Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,ans=0,count;
    cin >> n;
    for(int i=1;i<=n;i+=2){
        count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0) count++;
        }
        if(count==8) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;

class Problem {
    public static void Main() {
        var list = new bool[4, 52];
        var n = int.Parse(Console.ReadLine());
        for (var i = 0; i < n; i++) {
            var data = Console.ReadLine().Split();
            switch (data[0]) {
                case "S": list[0, int.Parse(data[1]) - 1] = true; break;
                case "H": list[1, int.Parse(data[1]) - 1] = true; break;
                case "C": list[2, int.Parse(data[1]) - 1] = true; break;
                case "D": list[3, int.Parse(data[1]) - 1] = true; break;
            }
        }
        for (var i = 0; i < 4; i++)
            for (var j = 0; j < 13; j++)
                if (!list[i, j])
                    Console.WriteLine( (i == 0 ? "S" :
                                        i == 1 ? "H" :
                                        i == 2 ? "C" : "D")
                                      + " "
                                      + (j + 1));
    }
}


Measured memory_bytes: 9160
#include<cstdio>
#include<set>
#include<algorithm>
using namespace std;
#define N 100500
#define mod 1000000007
multiset<int> tp;
int n,v[N],l[N],r[N],s[N],m,a;
struct node{int l,r,su;}e[N*4];
void pushup(int x){e[x].su=(e[x<<1].su+e[x<<1|1].su)%mod;}
void build(int x,int l,int r){e[x].l=l;e[x].r=r;if(l==r)return;int mid=(l+r)>>1;build(x<<1,l,mid);build(x<<1|1,mid+1,r);}
void add(int x,int s,int v){if(e[x].l==e[x].r){e[x].su=(e[x].su+v)%mod;return;}int mid=(e[x].l+e[x].r)>>1;if(mid>=s)add(x<<1,s,v);else add(x<<1|1,s,v);pushup(x);}
int que(int x,int l,int r){if(e[x].l==l&&e[x].r==r)return e[x].su;int mid=(e[x].l+e[x].r)>>1;if(mid>=r)return que(x<<1,l,r);else if(mid<l)return que(x<<1|1,l,r);return (que(x<<1,l,mid)+que(x<<1|1,mid+1,r))%mod;}
bool cmp(int i,int j){return l[i]==l[j]?r[i]>r[j]:l[i]<l[j];}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	tp.insert(-1e9-10);tp.insert(2e9+5);
	for(int i=1;i<=m;i++)scanf("%d",&a),tp.insert(a);
	for(int i=1;i<=n;i++)
	{
		multiset<int>::iterator it=tp.lower_bound(v[i]);
		r[i]=*it-v[i];it--;l[i]=v[i]-*it;s[i]=i;v[i]=r[i];
	}
	sort(s+1,s+n+1,cmp);sort(v+1,v+n+2);
	build(1,1,n+1);add(1,1,1);
	for(int i=1;i<=n;i++)
	if(l[s[i]]!=l[s[i-1]]||r[s[i]]!=r[s[i-1]])
	{
		int t=lower_bound(v+1,v+n+2,r[s[i]])-v;
		if(r[s[i]]>1e9||l[s[i]]>1e9)continue;
		add(1,t,que(1,1,t-1));
	}
	printf("%d\n",que(1,1,n+1));
}

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

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}

int main() {
  long long n,k,sum=0,a=0,b=0,c=0,d=0,ans=0;
  long long MOD = 1000000007;
  long long INF = 1LL << 60;
  string S="";
  cin >> n;
  vector<long long> A(n);
  ans = 0;
  for (long long i=0;i<n;i++){
    cin >> a;
    ans = gcd(a,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long d[100000];
long long bor = 1000000000000000000;


int main() {
  long long res =1;
  long long a;
  string b;
  cin >> a >> b;
 long long c = 100*(b[0] - '0') + 10*(b[2] - '0') + (b[3] - '0') ;
 //cout << b[0]  << " " << b[1] << " " << b[2] << endl;
 cout << a*c/100 << endl;
}


Measured memory_bytes: 3596
// Shinchan Loves Coding :)))
#include<bits/stdc++.h>

using namespace std;

#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define double long double
#define en "\n"
#define no 1e5
#define big 1e7+1
#define fi first
#define se second
#define modulo 1e9+7
#define MP make_pair
#define PB push_back
typedef vector<int> vi;
typedef pair<int,int> vii;

signed main()
{
    night_rider
  //  freopen("input.txt","r",stdin);
  //  freopen("output.txt","w",stdout);

    string s;
    cin>>s;
    for(int i=0 ; i<s.length() ; i++)
    {
        if(s[i]=='7')
            return cout<<"Yes",0;
    }
        cout<<"No";
}



Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

void swap(int *a, int *b) {
  int *tmp = a;
  a = b;
  b = tmp;
}

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
ll INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  ll ans = 0;
  ll max_num = 0;
  ll min_num = 0;

  rep(i, n + 1) {
    max_num += (n - i);
    min_num += i;
    if (k <= i+1) ans += (max_num - min_num + 1);
  }

  cout << ans % ll(1e9+7) << endl;


  return 0;
}


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


char field[25][25];
int dist[25][25];

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


int main(){
	int H,W;
	cin >> H >> W;
	
	rep(i,H){
		rep(j,W){
			cin >> field[i][j];
		}
	}
	
	rep(i,H){
		rep(j,W){
			dist[i][j] = -1;
		}
	}
	
	queue<pair<int,int>> que;
	
	int ans = 0;
	
	
	//スタートの位置を全探査、そこから最も離れたところをゴールにすれば良い。
	rep(i,H){
		rep(j,W){
			if(field[i][j] == '.'){
			que.push(make_pair(i,j));
			dist[i][j] = 0;
			
			while(!que.empty()){
			pair<int,int> p = que.front();
			que.pop();
			
			rep(i,4){
				int nx = p.second + dx[i];
				int ny = p.first + dy[i];
				
				//すでに訪れていたら飛ばす
				if (dist[ny][nx] != -1) continue;
				
				if(0 <= nx && nx < W && 0 <= ny && ny < H && field[ny][nx] != '#'){
					que.push(make_pair(ny,nx));
					dist[ny][nx] = dist[p.first][p.second] + 1;
				}
			}
			}
			
			//distの中で最も大きいものを探す。
			int temp = 0;
			rep(k,H){
				rep(l,W){
					temp = max(temp,dist[k][l]);
				}
			}
			ans = max(ans,temp);
			rep(k,H){
				rep(l,W){
					dist[k][l] = -1;
				}
			}
		}
		}
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, m) = readLongList()
    val devisor = devisor(m)
    var ans = 0L
    for (d in devisor) {
        if (d * n <= m) {
            ans = Math.max(ans, d)
        }
    }
    out.println(ans)
}

fun devisor(n: Long): List<Long> {
    val devisor = mutableListOf<Long>()
    var i = 1L
    while (i * i <= n) {
        if (n % i == 0L) {
            devisor.add(i)
            if (i * i != n) { devisor.add(n / i) }
        }
        i++
    }
    devisor.sort()
    return devisor
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37828
(N , M) = gets.split.map(&:to_i)
array = []
Evaluation = Struct.new(:x,:y,:z)
N.times { (x,y,z) = gets.split.map(&:to_i); array.push(Evaluation.new(x,y,z)) }
ret = [0]
m = [1,-1]
m.each {|tmp1| m.each {|tmp2| m.each{|tmp3| ret.push(array.map {|r| r.x*tmp1+r.y*tmp2+r.z*tmp3 }.sort {|a,b| b <=> a }[0...M].inject(:+)) if M > 0 }}}
puts ret.max

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

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

  for (int i = 0; i < s.size() / 2; i++) {
    if (s[i] != s[s.size() - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  for (int i = 0; i < s.size() / 4; i++) {
    if (s[i] != s[s.size() / 2 - 1 - i]) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536870912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// bit: &/and, |/or, ^/xor, ~/not

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	// S: Bridge Table, Cross section shows bridge between island row and column
	vector<vector<bool>> S(N, vector<bool> (N, false));
	// B: Bridge array, List of islands connected to the island
	vector<vector<int>> B(N, vector<int> (0));
	for (int i=0; i<N; i++)
		for (int j=0; j<N; j++) {
			char c;
			cin >>c;
			if ('1'==c) {
				S.at(i).at(j)=true;
				B.at(i).push_back(j);
			}
		}
	// Check if in 2 groups
	// G: Group 0/1, -1=unknown
	vector<int> G(N, -1);
	G.at(0)=1;
	vector<bool> GDone(N, false);
	vector<int> q={0};
	int ixq=0;
	while (ixq<q.size()) {
		int src=q.at(ixq);
		if (!GDone.at(src)) {
			vector<int> B1=B.at(src);
			if (B1.size()>1) {
				for (int j=0; j<B1.size(); j++) {
					int dest=B1.at(j);
					if (G.at(dest)==G.at(src)) {
						cout <<-1 <<endl;
						return 0;
					}
					G.at(dest)=1-G.at(src);
					if (!GDone.at(dest))
						q.push_back(dest);
				}
			}
			GDone.at(src)=true;
		}
		ixq++;
	}
	vector<vector<int>> D(N, vector<int> (N, INF));
	for (int i=0; i<N; i++)
		D.at(i).at(i)=0;
	for (int i=0; i<N; i++) {
		for (int j=0; j<B.at(i).size(); j++) {
			int dest=B.at(i).at(j);
			D.at(i).at(dest)=1;
			D.at(dest).at(i)=1;
		}
	}
	for (int i=0; i<N; i++)
		for (int j=0; j<N; j++) {
			for (int k=0; k<N; k++) {
				D.at(j).at(k)=min(D.at(j).at(k), D.at(j).at(i)+D.at(i).at(k));
				D.at(k).at(j)=D.at(j).at(k);
			}
		}
	int Distance=0;
	for (int i=0; i<N-1; i++)
		for (int j=i+1; j<N; j++)
			Distance=max(Distance, D.at(i).at(j));
	cout <<Distance+1 <<endl;
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<int,int>b[4100];
long long dp[4100][4100];
int ra[4100];
int sa[4100];
int ss[4100];
long long sum[4100];
int lb[4100];
inline long long calc(int a,int l,int r){
	if(l>r)return 0;
	long long ret=0;
	if(l<lb[a]){
		ret+=(long long)sa[a]*(lb[a]-l)-(sum[lb[a]]-sum[l]);
	}
	if(r+1<lb[a]){
		ret-=(long long)sa[a]*(lb[a]-r-1)-(sum[lb[a]]-sum[r+1]);
	}
	if(r>=lb[a]){
		ret+=(sum[r+1]-sum[lb[a]])-(long long)sa[a]*(r-lb[a]+1);
	}
	if(l>lb[a]){
		ret-=(sum[l]-sum[lb[a]])-(long long)sa[a]*(l-lb[a]);
	}
	//printf("%d %d %d: %lld\n",a,l,r,ret);
	return ret;
}
void solve(int t,int a,int b,int c,int d){
	if(a>=b)return;
	int M=(a+b)/2;
	long long val=999999999999999LL;
	int at=-1;
	for(int i=c;i<d&&i<=M;i++){
		if(M-i>ss[t])continue;
		long long cost=dp[t][i]+calc(t,i,M-1);
		if(val>cost){
			val=cost;at=i;
		}
	}
	dp[t+1][M]=val;
	solve(t,a,M,c,at+1);
	solve(t,M+1,b,at,d);
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			int p,q;scanf("%d%d",&p,&q);
			b[i]=make_pair(p,q);
		}
		std::sort(b,b+a);
		long long ret=b[a-1].first-b[0].first;
		int R=0;
		int S=0;
		int st=0;
		for(int i=0;i<a;i++){
			int req=2;
			if(i==0||i==a-1)req--;
			if(req<b[i].second){
				sa[S]=b[i].first;
				ss[S++]=b[i].second-req;
			}else if(req>b[i].second){
				ra[R++]=b[i].first;
			}
			st+=b[i].second;
		}
		if(st<2*a-2){
			printf("-1\n");continue;
		}
		for(int i=0;i<=R;i++)sum[i]=0;
		for(int i=0;i<R;i++)sum[i+1]=sum[i]+ra[i];
		for(int i=0;i<S;i++){
			lb[i]=lower_bound(ra,ra+R,sa[i])-ra;
		}
		for(int i=0;i<=S;i++){
			for(int j=0;j<=R;j++)dp[i][j]=99999999999999LL;
		}
		dp[0][0]=0;
		int now=0;
		for(int i=0;i<S;i++){
			solve(i,0,R+1,0,R+1);
		//	now+=ss[i];
		//	if(now>=R)now=R;
		//	for(int j=0;j<=now;j++)printf("%lld ",dp[i+1][j]);
		//	printf("\n");
		}
		ret+=dp[S][R];
		printf("%lld\n",ret);
	}
}

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

using namespace std;

const int mod = 1e9 + 7;

int h, w;
int dp[1010][1010];
string a[1010];

bool chk(int r, int c) {
    return (r >= 0 && c >= 0 && a[r][c] == '.');
}

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

    
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (chk(i - 1, j)) dp[i][j] += dp[i - 1][j];
            if (chk(i, j - 1)) dp[i][j] += dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }

    cout << dp[h - 1][w - 1] << '\n';
}

Measured memory_bytes: 5248